[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090316164550.GL24293@csn.ul.ie>
Date: Mon, 16 Mar 2009 16:45:50 +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/35] Convert gfp_zone() to use a table of
precalculated values
On Mon, Mar 16, 2009 at 12:19:06PM -0400, Christoph Lameter wrote:
> On Mon, 16 Mar 2009, Mel Gorman wrote:
>
> > diff --git a/init/main.c b/init/main.c
> > index 8442094..08a5663 100644
> > --- a/init/main.c
> > +++ b/init/main.c
> > @@ -573,6 +573,7 @@ asmlinkage void __init start_kernel(void)
> > * fragile until we cpu_idle() for the first time.
> > */
> > preempt_disable();
> > + init_gfp_zone_table();
> > build_all_zonelists();
> > page_alloc_init();
> > printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line);
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index bc491fa..d76f57d 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -70,6 +70,7 @@ EXPORT_SYMBOL(node_states);
> > unsigned long totalram_pages __read_mostly;
> > unsigned long totalreserve_pages __read_mostly;
> > unsigned long highest_memmap_pfn __read_mostly;
> > +int gfp_zone_table[GFP_ZONEMASK] __read_mostly;
> > int static_num_online_nodes __read_mostly;
> > int percpu_pagelist_fraction;
> >
> > @@ -4569,7 +4570,7 @@ static void setup_per_zone_inactive_ratio(void)
> > * 8192MB: 11584k
> > * 16384MB: 16384k
> > */
> > -static int __init init_per_zone_pages_min(void)
> > +static int init_per_zone_pages_min(void)
> > {
> > unsigned long lowmem_kbytes;
> >
> > @@ -4587,6 +4588,39 @@ static int __init init_per_zone_pages_min(void)
> > }
> > module_init(init_per_zone_pages_min)
> >
> > +static inline int __init gfp_flags_to_zone(gfp_t flags)
> > +{
> > +#ifdef CONFIG_ZONE_DMA
> > + if (flags & __GFP_DMA)
> > + return ZONE_DMA;
> > +#endif
> > +#ifdef CONFIG_ZONE_DMA32
> > + if (flags & __GFP_DMA32)
> > + return ZONE_DMA32;
> > +#endif
> > + if ((flags & (__GFP_HIGHMEM | __GFP_MOVABLE)) ==
> > + (__GFP_HIGHMEM | __GFP_MOVABLE))
> > + return ZONE_MOVABLE;
> > +#ifdef CONFIG_HIGHMEM
> > + if (flags & __GFP_HIGHMEM)
> > + return ZONE_HIGHMEM;
> > +#endif
> > + return ZONE_NORMAL;
> > +}
> > +
> > +/*
> > + * For each possible combination of zone modifier flags, we calculate
> > + * what zone it should be using. This consumes a cache line in most
> > + * cases but avoids a number of branches in the allocator fast path
> > + */
> > +void __init init_gfp_zone_table(void)
> > +{
> > + gfp_t gfp_flags;
> > +
> > + for (gfp_flags = 0; gfp_flags < GFP_ZONEMASK; gfp_flags++)
> > + gfp_zone_table[gfp_flags] = gfp_flags_to_zone(gfp_flags);
> > +}
> > +
>
> This is all known at compile time. The table can be calculated at compile
> time with some ifdefs and then we do not need the init_gfp_zone_table().
>
The last discussion didn't come up with something that could generate such
a table and still be correct in all cases. I guess someone could do it all
by hand but it was going to be an error prone exercise. I left the patch
as-is as a result.
--
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