Re: Page allocator: Single Zone optimizations

Andrew Morton
2006-10-18T19:38:40Z

On Wed, 18 Oct 2006 21:15:35 +1000
Nick Piggin <nickpiggin@yahoo.com.au> wrote:

> > @@ -458,7 +461,8 @@ static inline int is_highmem(struct zone
> >
> > static inline int is_normal(struct zone *zone)
> > {
> > - return zone == zone->zone_pgdat->node_zones + ZONE_NORMAL;
> > + return SINGLE_ZONE ||
> > + zone == zone->zone_pgdat->node_zones + ZONE_NORMAL;
> > }
>
> I don't know if these are any better than ifdef elseif endif. I think
> the goal is not ifdef removal at any cost, but avoiding ifdefs in
> complex functions and within control flow because it makes the code
> less readable.

Certainly readability is a concern.

But the other problem with ifdefs is

#ifdef SOMETHING_WHICH_IS_USUALLY_DEFINED
stuff_which_works();
#else
stuff_which_doesnt_compile_or_which_generates_warnings();
#endif

And we do that quite a lot.

Whereas

if (SOMETHING_WHICH_IS_ZERO_OR_ONE)
stuff_which_works();
else
stuff_which_doesnt_compile_or_which_generates_warnings();

not only loooks heaps better, but the compiler checks it all for us too.

But you knew all that.