linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/memory_hotplug: fix default_zone_for_pfn() to include highmem zone range
@ 2020-06-04 13:39 Vamshi K Sthambamkadi
  2020-06-04 14:49 ` David Hildenbrand
  0 siblings, 1 reply; 2+ messages in thread
From: Vamshi K Sthambamkadi @ 2020-06-04 13:39 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel

On x86_32, while onlining highmem sections, the func default_zone_for_pfn()
defaults target zone to ZONE_NORMAL (movable_node_enabled = 0). Onlining of
pages is successful, and these highmem pages are moved into zone_normal.

As a consequence, these pages are treated as low mem, and page addresses
are calculated using lowmem_page_address() which effectively overflows the
32 bit virtual addresses, leading to kernel panics and system becomes
unusable.

Change default_kernel_zone_for_pfn() to intersect highmem pfn range, and
calculate the default zone accordingly.

Signed-off-by: Vamshi K Sthambamkadi <vamshi.k.sthambamkadi@gmail.com>
---
 mm/memory_hotplug.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index c4d5c45..30f101a 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -725,8 +725,13 @@ static struct zone *default_kernel_zone_for_pfn(int nid, unsigned long start_pfn
 {
 	struct pglist_data *pgdat = NODE_DATA(nid);
 	int zid;
+	int nr_zones = ZONE_NORMAL;
 
-	for (zid = 0; zid <= ZONE_NORMAL; zid++) {
+#ifdef CONFIG_HIGHMEM
+	nr_zones = ZONE_HIGHMEM;
+#endif
+
+	for (zid = 0; zid <= nr_zones; zid++) {
 		struct zone *zone = &pgdat->node_zones[zid];
 
 		if (zone_intersects(zone, start_pfn, nr_pages))
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm/memory_hotplug: fix default_zone_for_pfn() to include highmem zone range
  2020-06-04 13:39 [PATCH] mm/memory_hotplug: fix default_zone_for_pfn() to include highmem zone range Vamshi K Sthambamkadi
@ 2020-06-04 14:49 ` David Hildenbrand
  0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2020-06-04 14:49 UTC (permalink / raw)
  To: Vamshi K Sthambamkadi, akpm
  Cc: linux-mm, linux-kernel, Michal Hocko, Baoquan He

On 04.06.20 15:39, Vamshi K Sthambamkadi wrote:
> On x86_32, while onlining highmem sections, the func default_zone_for_pfn()
> defaults target zone to ZONE_NORMAL (movable_node_enabled = 0). Onlining of
> pages is successful, and these highmem pages are moved into zone_normal.
> 
> As a consequence, these pages are treated as low mem, and page addresses
> are calculated using lowmem_page_address() which effectively overflows the
> 32 bit virtual addresses, leading to kernel panics and system becomes
> unusable.
> 
> Change default_kernel_zone_for_pfn() to intersect highmem pfn range, and
> calculate the default zone accordingly.

We discussed this recently [1], and decided that we don't really care
about memory hotplug on 32-bit anymore (especially, user space could
still configure a different zone and make things crash). There was a
patch from Michal in [1], looks like it has not been picked up yet.

@Andrew, can we queue Michals patch?

[1] https://lkml.kernel.org/r/20200218100532.GA4151@dhcp22.suse.cz

> 
> Signed-off-by: Vamshi K Sthambamkadi <vamshi.k.sthambamkadi@gmail.com>
> ---
>  mm/memory_hotplug.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index c4d5c45..30f101a 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -725,8 +725,13 @@ static struct zone *default_kernel_zone_for_pfn(int nid, unsigned long start_pfn
>  {
>  	struct pglist_data *pgdat = NODE_DATA(nid);
>  	int zid;
> +	int nr_zones = ZONE_NORMAL;
>  
> -	for (zid = 0; zid <= ZONE_NORMAL; zid++) {
> +#ifdef CONFIG_HIGHMEM
> +	nr_zones = ZONE_HIGHMEM;
> +#endif
> +
> +	for (zid = 0; zid <= nr_zones; zid++) {
>  		struct zone *zone = &pgdat->node_zones[zid];
>  
>  		if (zone_intersects(zone, start_pfn, nr_pages))
> 


-- 
Thanks,

David / dhildenb


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-04 14:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-04 13:39 [PATCH] mm/memory_hotplug: fix default_zone_for_pfn() to include highmem zone range Vamshi K Sthambamkadi
2020-06-04 14:49 ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).