show_mem.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Generic show_mem() implementation
  3. *
  4. * Copyright (C) 2008 Johannes Weiner <hannes@saeurebad.de>
  5. * All code subject to the GPL version 2.
  6. */
  7. #include <linux/mm.h>
  8. #include <linux/nmi.h>
  9. #include <linux/quicklist.h>
  10. void show_mem(unsigned int filter)
  11. {
  12. pg_data_t *pgdat;
  13. unsigned long total = 0, reserved = 0, highmem = 0;
  14. printk("Mem-Info:\n");
  15. show_free_areas(filter);
  16. if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
  17. return;
  18. for_each_online_pgdat(pgdat) {
  19. unsigned long flags;
  20. int zoneid;
  21. pgdat_resize_lock(pgdat, &flags);
  22. for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
  23. struct zone *zone = &pgdat->node_zones[zoneid];
  24. if (!populated_zone(zone))
  25. continue;
  26. total += zone->present_pages;
  27. reserved = zone->present_pages - zone->managed_pages;
  28. if (is_highmem_idx(zoneid))
  29. highmem += zone->present_pages;
  30. }
  31. pgdat_resize_unlock(pgdat, &flags);
  32. }
  33. printk("%lu pages RAM\n", total);
  34. printk("%lu pages HighMem/MovableOnly\n", highmem);
  35. printk("%lu pages reserved\n", reserved);
  36. #ifdef CONFIG_QUICKLIST
  37. printk("%lu pages in pagetable cache\n",
  38. quicklist_total_size());
  39. #endif
  40. }