show_mem.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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/quicklist.h>
  9. #include <linux/cma.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. for_each_online_pgdat(pgdat) {
  17. unsigned long flags;
  18. int zoneid;
  19. pgdat_resize_lock(pgdat, &flags);
  20. for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
  21. struct zone *zone = &pgdat->node_zones[zoneid];
  22. if (!populated_zone(zone))
  23. continue;
  24. total += zone->present_pages;
  25. reserved += zone->present_pages - zone->managed_pages;
  26. if (is_highmem_idx(zoneid))
  27. highmem += zone->present_pages;
  28. }
  29. pgdat_resize_unlock(pgdat, &flags);
  30. }
  31. printk("%lu pages RAM\n", total);
  32. printk("%lu pages HighMem/MovableOnly\n", highmem);
  33. #ifdef CONFIG_CMA
  34. printk("%lu pages reserved\n", (reserved - totalcma_pages));
  35. printk("%lu pages cma reserved\n", totalcma_pages);
  36. #else
  37. printk("%lu pages reserved\n", reserved);
  38. #endif
  39. #ifdef CONFIG_QUICKLIST
  40. printk("%lu pages in pagetable cache\n",
  41. quicklist_total_size());
  42. #endif
  43. #ifdef CONFIG_MEMORY_FAILURE
  44. printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
  45. #endif
  46. }