mmzone.c 873 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * linux/mm/mmzone.c
  3. *
  4. * management codes for pgdats and zones.
  5. */
  6. #include <linux/config.h>
  7. #include <linux/stddef.h>
  8. #include <linux/mmzone.h>
  9. #include <linux/module.h>
  10. struct pglist_data *first_online_pgdat(void)
  11. {
  12. return NODE_DATA(first_online_node);
  13. }
  14. EXPORT_SYMBOL(first_online_pgdat);
  15. struct pglist_data *next_online_pgdat(struct pglist_data *pgdat)
  16. {
  17. int nid = next_online_node(pgdat->node_id);
  18. if (nid == MAX_NUMNODES)
  19. return NULL;
  20. return NODE_DATA(nid);
  21. }
  22. EXPORT_SYMBOL(next_online_pgdat);
  23. /*
  24. * next_zone - helper magic for for_each_zone()
  25. */
  26. struct zone *next_zone(struct zone *zone)
  27. {
  28. pg_data_t *pgdat = zone->zone_pgdat;
  29. if (zone < pgdat->node_zones + MAX_NR_ZONES - 1)
  30. zone++;
  31. else {
  32. pgdat = next_online_pgdat(pgdat);
  33. if (pgdat)
  34. zone = pgdat->node_zones;
  35. else
  36. zone = NULL;
  37. }
  38. return zone;
  39. }
  40. EXPORT_SYMBOL(next_zone);