Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

memory hotplug: fix updating of num_physpages for hot plugged memory

Sizing of memory allocations shouldn't depend on the number of physical
pages found in a system, as that generally includes (perhaps a huge amount
of) non-RAM pages. The amount of what actually is usable as storage
should instead be used as a basis here.

In line with that, the memory hotplug code should update num_physpages in
a way that it retains its original (post-boot) meaning; in particular,
decreasing the value should at best be done with great care - this patch
doesn't try to ever decrease this value at all as it doesn't really seem
meaningful to do so.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: Badari Pulavarty <pbadari@us.ibm.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Dave Hansen <haveblue@us.ibm.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jan Beulich and committed by
Linus Torvalds
4738e1b9 78986a67

+4 -2
+4 -2
mm/memory_hotplug.c
··· 339 339 340 340 void online_page(struct page *page) 341 341 { 342 + unsigned long pfn = page_to_pfn(page); 343 + 342 344 totalram_pages++; 343 - num_physpages++; 345 + if (pfn >= num_physpages) 346 + num_physpages = pfn + 1; 344 347 345 348 #ifdef CONFIG_HIGHMEM 346 349 if (PageHighMem(page)) ··· 835 832 zone->present_pages -= offlined_pages; 836 833 zone->zone_pgdat->node_present_pages -= offlined_pages; 837 834 totalram_pages -= offlined_pages; 838 - num_physpages -= offlined_pages; 839 835 840 836 setup_per_zone_wmarks(); 841 837 calculate_zone_inactive_ratio(zone);