Skip to content

Commit cdd91a7

Browse files
jiangliutorvalds
authored andcommitted
mm: report available pages as "MemTotal" for each NUMA node
As reported by https://bugzilla.kernel.org/show_bug.cgi?id=53501, "MemTotal" from /proc/meminfo means memory pages managed by the buddy system (managed_pages), but "MemTotal" from /sys/.../node/nodex/meminfo means physical pages present (present_pages) within the NUMA node. There's a difference between managed_pages and present_pages due to bootmem allocator and reserved pages. And Documentation/filesystems/proc.txt says MemTotal: Total usable ram (i.e. physical ram minus a few reserved bits and the kernel binary code) So change /sys/.../node/nodex/meminfo to report available pages within the node as "MemTotal". Signed-off-by: Jiang Liu <[email protected]> Reported-by: <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Minchan Kim <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: "Michael S. Tsirkin" <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Chris Metcalf <[email protected]> Cc: David Howells <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jeremy Fitzhardinge <[email protected]> Cc: Jianguo Wu <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Kamezawa Hiroyuki <[email protected]> Cc: Konrad Rzeszutek Wilk <[email protected]> Cc: Marek Szyprowski <[email protected]> Cc: Michel Lespinasse <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Rusty Russell <[email protected]> Cc: Tang Chen <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Wen Congyang <[email protected]> Cc: Will Deacon <[email protected]> Cc: Yasuaki Ishimatsu <[email protected]> Cc: Yinghai Lu <[email protected]> Cc: Russell King <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 0c98853 commit cdd91a7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mm/page_alloc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2904,9 +2904,13 @@ EXPORT_SYMBOL(si_meminfo);
29042904
#ifdef CONFIG_NUMA
29052905
void si_meminfo_node(struct sysinfo *val, int nid)
29062906
{
2907+
int zone_type; /* needs to be signed */
2908+
unsigned long managed_pages = 0;
29072909
pg_data_t *pgdat = NODE_DATA(nid);
29082910

2909-
val->totalram = pgdat->node_present_pages;
2911+
for (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++)
2912+
managed_pages += pgdat->node_zones[zone_type].managed_pages;
2913+
val->totalram = managed_pages;
29102914
val->freeram = node_page_state(nid, NR_FREE_PAGES);
29112915
#ifdef CONFIG_HIGHMEM
29122916
val->totalhigh = pgdat->node_zones[ZONE_HIGHMEM].managed_pages;

0 commit comments

Comments
 (0)