show_mem.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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, shared = 0,
  14. nonshared = 0, highmem = 0;
  15. printk("Mem-Info:\n");
  16. show_free_areas(filter);
  17. for_each_online_pgdat(pgdat) {
  18. unsigned long i, flags;
  19. pgdat_resize_lock(pgdat, &flags);
  20. for (i = 0; i < pgdat->node_spanned_pages; i++) {
  21. struct page *page;
  22. unsigned long pfn = pgdat->node_start_pfn + i;
  23. if (unlikely(!(i % MAX_ORDER_NR_PAGES)))
  24. touch_nmi_watchdog();
  25. if (!pfn_valid(pfn))
  26. continue;
  27. page = pfn_to_page(pfn);
  28. if (PageHighMem(page))
  29. highmem++;
  30. if (PageReserved(page))
  31. reserved++;
  32. else if (page_count(page) == 1)
  33. nonshared++;
  34. else if (page_count(page) > 1)
  35. shared += page_count(page) - 1;
  36. total++;
  37. }
  38. pgdat_resize_unlock(pgdat, &flags);
  39. }
  40. printk("%lu pages RAM\n", total);
  41. #ifdef CONFIG_HIGHMEM
  42. printk("%lu pages HighMem\n", highmem);
  43. #endif
  44. printk("%lu pages reserved\n", reserved);
  45. printk("%lu pages shared\n", shared);
  46. printk("%lu pages non-shared\n", nonshared);
  47. #ifdef CONFIG_QUICKLIST
  48. printk("%lu pages in pagetable cache\n",
  49. quicklist_total_size());
  50. #endif
  51. }