show_mem.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. printk("%lu pages reserved\n", reserved);
  34. #ifdef CONFIG_CMA
  35. printk("%lu pages cma reserved\n", totalcma_pages);
  36. #endif
  37. #ifdef CONFIG_QUICKLIST
  38. printk("%lu pages in pagetable cache\n",
  39. quicklist_total_size());
  40. #endif
  41. #ifdef CONFIG_MEMORY_FAILURE
  42. printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
  43. #endif
  44. }