Re: [PATCH] for_each_zone / for_each_pgdat

Linus Torvalds (torvalds@transmeta.com)
Mon, 15 Apr 2002 14:08:54 -0700 (PDT)


On Mon, 15 Apr 2002, Rik van Riel wrote:
>
> However, I really don't like the fact of teaching now-simple
> VM code about pgdats again ;)

Well, you don't actually have to teach it about pgdats, but try out how
much simpler the actual implementation is if you were to just add a
"endzone" macro, allowing the macros to do nesting.

Once you do that, you can basically expand the thing any which way,
something like

#define for_each_zone(zone) \
do { pg_data_t * __pgdat; \
for (__pgdat = pgdat_list; __pgdat; __pgdat = __pgdat->next) { \
int __i; \
for (i = 0; i < MAX_ZONES; i++) { \
zone = pgdat->node_zones; \
if (!zone->size) \
break; \
do { \

#define end_zone \
while (0); \
} \
} \
} while (0)

Which requires the user to use something like

for_each_zone(zone) {
...
} end_zone;

but doesn't need changing the double loop into a artificial single loop.

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/