Skip to contentSkip to conversation

mm/memory_hotplug: use "unsigned long" for PFN in zone_for_pfn_range()

PATCH In review David Hildenbrand 2 participants 4 messages Sep 20, 2021 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 1/1 mm/memory_hotplug: use "unsigned long" for PFN in zone_for_pfn_range()

In reply to a message not in the archive

commit 7cf209ba8a86410939a24cb1aeb279479a7e0ca6 upstream.

Patch series "mm/memory_hotplug: preparatory patches for new online policy and memory"

These are all cleanups and one fix previously sent as part of [1]:
[PATCH v1 00/12] mm/memory_hotplug: "auto-movable" online policy and memory groups.

These patches make sense even without the other series, therefore I pulled them out to make the other series easier to digest.

[1] https://lkml.kernel.org/r/[email protected]

This patch (of 4):

Checkpatch complained on a follow-up patch that we are using "unsigned" here, which defaults to "unsigned int" and checkpatch is correct.

As we will search for a fitting zone using the wrong pfn, we might end up onlining memory to one of the special kernel zones, such as ZONE_DMA, which can end badly as the onlined memory does not satisfy properties of these zones.

Use "unsigned long" instead, just as we do in other places when handling PFNs. This can bite us once we have physical addresses in the range of multiple TB.

Fixes e5e689302633 ("mm, memory_hotplug: display allowed zones in the preferred ordering")
Cc David Hildenbrand <[email protected]>
Cc Vitaly Kuznetsov <[email protected]>
Cc "Michael S. Tsirkin" <[email protected]>
Cc Jason Wang <[email protected]>
Cc Pankaj Gupta <[email protected]>
Cc Wei Yang <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Dan Williams <[email protected]>
Cc Anshuman Khandual <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Len Brown <[email protected]>
Cc Pavel Tatashin <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc "Aneesh Kumar K.V" <[email protected]>
Cc Anton Blanchard <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Baoquan He <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Dave Jiang <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jia He <[email protected]>
Cc Joe Perches <[email protected]>
Cc Kefeng Wang <[email protected]>
Cc Laurent Dufour <[email protected]>
Cc Michel Lespinasse <[email protected]>
Cc Nathan Lynch <[email protected]>
Cc Nicholas Piggin <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Pierre Morel <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Rich Felker <[email protected]>
Cc Scott Cheloha <[email protected]>
Cc Sergei Trofimovich <[email protected]>
Cc Thiago Jung Bauermann <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Vishal Verma <[email protected]>
Cc Will Deacon <[email protected]>
Cc Yoshinori Sato <[email protected]>
---
 include/linux/memory_hotplug.h | 4 ++--
 mm/memory_hotplug.c            | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
include/linux/memory_hotplug.h +2 -2
index d17d45c41a0b..565317876822 100644
@@ -344,6 +344,6 @@ extern struct page *sparse_decode_mem_map(unsigned long coded_mem_map,
 					  unsigned long pnum);
 extern bool allow_online_pfn_range(int nid, unsigned long pfn, unsigned long nr_pages,
 		int online_type);
-extern struct zone *zone_for_pfn_range(int online_type, int nid, unsigned start_pfn,
-		unsigned long nr_pages);
+extern struct zone *zone_for_pfn_range(int online_type, int nid,
+		unsigned long start_pfn, unsigned long nr_pages);
 #endif /* __LINUX_MEMORY_HOTPLUG_H */
mm/memory_hotplug.c +2 -2
index e60e28131f67..20f079c81b33 100644
@@ -783,8 +783,8 @@ static inline struct zone *default_zone_for_pfn(int nid, unsigned long start_pfn
 	return movable_node_enabled ? movable_zone : kernel_zone;
 }
 
-struct zone * zone_for_pfn_range(int online_type, int nid, unsigned start_pfn,
-		unsigned long nr_pages)
+struct zone *zone_for_pfn_range(int online_type, int nid,
+		unsigned long start_pfn, unsigned long nr_pages)
 {
 	if (online_type == MMOP_ONLINE_KERNEL)
 		return default_kernel_zone_for_pfn(nid, start_pfn, nr_pages);
Signature · 1 line
2.31.1
maintainer
#2 lore raw
Quoted 2 lines · David Hildenbrand

commit 7cf209ba8a86410939a24cb1aeb279479a7e0ca6 upstream.

We also need a 5.4.y version if we are going to be able to apply the 4.19.y and 4.14.y versions.

thanks,

greg k-h

#3 lore raw
Quoted 6 lines · Greg KH
Quoted 2 lines · David Hildenbrand

commit 7cf209ba8a86410939a24cb1aeb279479a7e0ca6 upstream.

We also need a 5.4.y version if we are going to be able to apply the 4.19.y and 4.14.y versions.

On it, still compiling :)

Signature · 3 lines
Thanks,

David / dhildenb
maintainer
#4 lore raw
Quoted 9 lines · David Hildenbrand
Quoted 6 lines · Greg KH
Quoted 2 lines · David Hildenbrand

commit 7cf209ba8a86410939a24cb1aeb279479a7e0ca6 upstream.

We also need a 5.4.y version if we are going to be able to apply the 4.19.y and 4.14.y versions.

On it, still compiling :)

Ah, thanks, all now queued up.

greg k-h