patch-2.4.20 linux-2.4.20/include/linux/mmzone.h
Next file: linux-2.4.20/include/linux/mtd/ftl.h
Previous file: linux-2.4.20/include/linux/mii.h
Back to the patch index
Back to the overall index
- Lines: 71
- Date:
Thu Nov 28 15:53:15 2002
- Orig file:
linux-2.4.19/include/linux/mmzone.h
- Orig date:
Fri Aug 2 17:39:45 2002
diff -urN linux-2.4.19/include/linux/mmzone.h linux-2.4.20/include/linux/mmzone.h
@@ -158,6 +158,60 @@
extern pg_data_t contig_page_data;
+/**
+ * for_each_pgdat - helper macro to iterate over all nodes
+ * @pgdat - pg_data_t * variable
+ *
+ * Meant to help with common loops of the form
+ * pgdat = pgdat_list;
+ * while(pgdat) {
+ * ...
+ * pgdat = pgdat->node_next;
+ * }
+ */
+#define for_each_pgdat(pgdat) \
+ for (pgdat = pgdat_list; pgdat; pgdat = pgdat->node_next)
+
+
+/*
+ * next_zone - helper magic for for_each_zone()
+ * Thanks to William Lee Irwin III for this piece of ingenuity.
+ */
+static inline zone_t *next_zone(zone_t *zone)
+{
+ pg_data_t *pgdat = zone->zone_pgdat;
+
+ if (zone - pgdat->node_zones < MAX_NR_ZONES - 1)
+ zone++;
+
+ else if (pgdat->node_next) {
+ pgdat = pgdat->node_next;
+ zone = pgdat->node_zones;
+ } else
+ zone = NULL;
+
+ return zone;
+}
+
+/**
+ * for_each_zone - helper macro to iterate over all memory zones
+ * @zone - zone_t * variable
+ *
+ * The user only needs to declare the zone variable, for_each_zone
+ * fills it in. This basically means for_each_zone() is an
+ * easier to read version of this piece of code:
+ *
+ * for(pgdat = pgdat_list; pgdat; pgdat = pgdat->node_next)
+ * for(i = 0; i < MAX_NR_ZONES; ++i) {
+ * zone_t * z = pgdat->node_zones + i;
+ * ...
+ * }
+ * }
+ */
+#define for_each_zone(zone) \
+ for(zone = pgdat_list->node_zones; zone; zone = next_zone(zone))
+
+
#ifndef CONFIG_DISCONTIGMEM
#define NODE_DATA(nid) (&contig_page_data)
@@ -169,7 +223,9 @@
#include <asm/mmzone.h>
/* page->zone is currently 8 bits ... */
+#ifndef MAX_NR_NODES
#define MAX_NR_NODES (255 / MAX_NR_ZONES)
+#endif
#endif /* !CONFIG_DISCONTIGMEM */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)