show_mem.c 1.4 KB

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