lkml.org 
[lkml]   [2002]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] for_each_zone / for_each_pgdat

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/

\
 
 \ /
  Last update: 2005-03-22 13:25    [W:0.065 / U:0.384 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site