Linux Audio

Check our new training course

Linux kernel drivers training

May 6-19, 2025
Register
Loading...
v3.5.6
 
 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
 8#include <linux/mm.h>
 9#include <linux/nmi.h>
10#include <linux/quicklist.h>
11
12void show_mem(unsigned int filter)
13{
14	pg_data_t *pgdat;
15	unsigned long total = 0, reserved = 0, shared = 0,
16		nonshared = 0, highmem = 0;
17
18	printk("Mem-Info:\n");
19	show_free_areas(filter);
20
21	for_each_online_pgdat(pgdat) {
22		unsigned long i, flags;
23
24		pgdat_resize_lock(pgdat, &flags);
25		for (i = 0; i < pgdat->node_spanned_pages; i++) {
26			struct page *page;
27			unsigned long pfn = pgdat->node_start_pfn + i;
28
29			if (unlikely(!(i % MAX_ORDER_NR_PAGES)))
30				touch_nmi_watchdog();
31
32			if (!pfn_valid(pfn))
33				continue;
34
35			page = pfn_to_page(pfn);
36
37			if (PageHighMem(page))
38				highmem++;
39
40			if (PageReserved(page))
41				reserved++;
42			else if (page_count(page) == 1)
43				nonshared++;
44			else if (page_count(page) > 1)
45				shared += page_count(page) - 1;
46
47			total++;
48		}
49		pgdat_resize_unlock(pgdat, &flags);
50	}
51
52	printk("%lu pages RAM\n", total);
53#ifdef CONFIG_HIGHMEM
54	printk("%lu pages HighMem\n", highmem);
55#endif
56	printk("%lu pages reserved\n", reserved);
57	printk("%lu pages shared\n", shared);
58	printk("%lu pages non-shared\n", nonshared);
59#ifdef CONFIG_QUICKLIST
60	printk("%lu pages in pagetable cache\n",
61		quicklist_total_size());
62#endif
63}
v5.4
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 * Generic show_mem() implementation
 4 *
 5 * Copyright (C) 2008 Johannes Weiner <hannes@saeurebad.de>
 
 6 */
 7
 8#include <linux/mm.h>
 9#include <linux/cma.h>
 
10
11void show_mem(unsigned int filter, nodemask_t *nodemask)
12{
13	pg_data_t *pgdat;
14	unsigned long total = 0, reserved = 0, highmem = 0;
 
15
16	printk("Mem-Info:\n");
17	show_free_areas(filter, nodemask);
18
19	for_each_online_pgdat(pgdat) {
20		int zoneid;
21
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
27			total += zone->present_pages;
28			reserved += zone->present_pages - zone_managed_pages(zone);
 
 
29
30			if (is_highmem_idx(zoneid))
31				highmem += zone->present_pages;
 
 
 
 
 
 
32		}
 
33	}
34
35	printk("%lu pages RAM\n", total);
36	printk("%lu pages HighMem/MovableOnly\n", highmem);
 
 
37	printk("%lu pages reserved\n", reserved);
38#ifdef CONFIG_CMA
39	printk("%lu pages cma reserved\n", totalcma_pages);
40#endif
41#ifdef CONFIG_MEMORY_FAILURE
42	printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
43#endif
44}