lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 18 Mar 2009 15:35:08 +0000
From:	Mel Gorman <mel@....ul.ie>
To:	Christoph Lameter <cl@...ux-foundation.org>
Cc:	Linux Memory Management List <linux-mm@...ck.org>,
	Pekka Enberg <penberg@...helsinki.fi>,
	Rik van Riel <riel@...hat.com>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Johannes Weiner <hannes@...xchg.org>,
	Nick Piggin <npiggin@...e.de>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Lin Ming <ming.m.lin@...el.com>,
	Zhang Yanmin <yanmin_zhang@...ux.intel.com>,
	Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH 24/27] Convert gfp_zone() to use a table of
	precalculated values

On Wed, Mar 18, 2009 at 10:15:26AM -0400, Christoph Lameter wrote:
> On Wed, 18 Mar 2009, Mel Gorman wrote:
> 
> > On Mon, Mar 16, 2009 at 03:12:50PM -0400, Christoph Lameter wrote:
> > > On Mon, 16 Mar 2009, Mel Gorman wrote:
> > >
> > > > +int gfp_zone_table[GFP_ZONEMASK] __read_mostly;
> > >
> > > The gfp_zone_table is compile time determinable. There is no need to
> > > calculate it.
> > >
> >
> > The cost of calculating it is negligible and the code is then freed later
> > in boot. Does having a const table make any difference?
> 
> Should it not enable the compiler to determine the value at
> compile time and therefore make things like gfp_zone(constant) a
> constant?
> 

Yeah, you're right. I didn't think it would but a test program showed
that code accessing const fields like this are calculated at compile
time.

> > > const int gfp_zone_table[GFP_ZONEMASK] = {
> > > 	ZONE_NORMAL,		/* 00 No flags set */
> > > 	ZONE_DMA,		/* 01 Only GFP_DMA set */
> > > 	ZONE_HIGHMEM,		/* 02 Only GFP_HIGHMEM set */
> > > 	ZONE_DMA,		/* 03 GFP_HIGHMEM and GFP_DMA set */
> > > 	ZONE_DMA32,		/* 04 Only GFP_DMA32 set */
> > > 	ZONE_DMA,		/* 05 GFP_DMA and GFP_DMA32 set */
> > > 	ZONE_DMA32,		/* 06 GFP_DMA32 and GFP_HIGHMEM set */
> > > 	ZONE_DMA,		/* 07 GFP_DMA, GFP_DMA32 and GFP_DMA32 set */
> > > 	ZONE_MOVABLE,		/* 08 Only ZONE_MOVABLE set */
> > > 	ZONE_DMA,		/* 09 MOVABLE + DMA */
> > > 	ZONE_MOVABLE,		/* 0A MOVABLE + HIGHMEM */
> > > 	ZONE_DMA,		/* 0B MOVABLE + DMA + HIGHMEM */
> > > 	ZONE_DMA32,		/* 0C MOVABLE + DMA32 */
> > > 	ZONE_DMA,		/* 0D MOVABLE + DMA + DMA32 */
> > > 	ZONE_DMA32,		/* 0E MOVABLE + DMA32 + HIGHMEM */
> > > 	ZONE_DMA		/* 0F MOVABLE + DMA32 + HIGHMEM + DMA
> > > };
> > >
> > > Hmmmm... Guess one would need to add some #ifdeffery here to setup
> > > ZONE_NORMAL in cases there is no DMA, DMA32 and HIGHMEM.
> > >
> >
> > Indeed, as I said, this is somewhat error prone which is why the patch
> > calculates the table at run-time instead of compile-time trickery.
> 
> One would need to define some macros to make it simpler I guess
> 
> Write something like
> 
> #ifdef CONFIG_ZONE_DMA
> #define TZONE_DMA ZONE_DMA
> #else
> #define TZONE_DMA ZONE_NORMAL
> #endif
> 
> for each configurable item. Then just add the T to the above table.
> 

If you don't mind, I'd like to postpone writing such a patch until a second
or third pass at improving the allocator. I don't think I'll have the time
in the short-term to put together a const-initialised-table patch that will
definitily be correct.

Alternatively, I can drop this patch entirely from the set.

-- 
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ