Greg Kroah-Hartman
2021-Sep-16 16:02 UTC
[PATCH 5.14 404/432] mm/memory_hotplug: use "unsigned long" for PFN in zone_for_pfn_range()
From: David Hildenbrand <david at redhat.com> 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/20210607195430.48228-1-david at redhat.com 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. Link: https://lkml.kernel.org/r/20210712124052.26491-2-david at redhat.com Fixes: e5e689302633 ("mm, memory_hotplug: display allowed zones in the preferred ordering") Signed-off-by: David Hildenbrand <david at redhat.com> Reviewed-by: Pankaj Gupta <pankaj.gupta at ionos.com> Reviewed-by: Muchun Song <songmuchun at bytedance.com> Reviewed-by: Oscar Salvador <osalvador at suse.de> Cc: David Hildenbrand <david at redhat.com> Cc: Vitaly Kuznetsov <vkuznets at redhat.com> Cc: "Michael S. Tsirkin" <mst at redhat.com> Cc: Jason Wang <jasowang at redhat.com> Cc: Pankaj Gupta <pankaj.gupta.linux at gmail.com> Cc: Wei Yang <richard.weiyang at linux.alibaba.com> Cc: Michal Hocko <mhocko at kernel.org> Cc: Dan Williams <dan.j.williams at intel.com> Cc: Anshuman Khandual <anshuman.khandual at arm.com> Cc: Dave Hansen <dave.hansen at linux.intel.com> Cc: Vlastimil Babka <vbabka at suse.cz> Cc: Mike Rapoport <rppt at kernel.org> Cc: "Rafael J. Wysocki" <rjw at rjwysocki.net> Cc: Len Brown <lenb at kernel.org> Cc: Pavel Tatashin <pasha.tatashin at soleen.com> Cc: Heiko Carstens <hca at linux.ibm.com> Cc: Michael Ellerman <mpe at ellerman.id.au> Cc: Catalin Marinas <catalin.marinas at arm.com> Cc: virtualization at lists.linux-foundation.org Cc: Andy Lutomirski <luto at kernel.org> Cc: "Aneesh Kumar K.V" <aneesh.kumar at linux.ibm.com> Cc: Anton Blanchard <anton at ozlabs.org> Cc: Ard Biesheuvel <ardb at kernel.org> Cc: Baoquan He <bhe at redhat.com> Cc: Benjamin Herrenschmidt <benh at kernel.crashing.org> Cc: Borislav Petkov <bp at alien8.de> Cc: Christian Borntraeger <borntraeger at de.ibm.com> Cc: Christophe Leroy <christophe.leroy at c-s.fr> Cc: Dave Jiang <dave.jiang at intel.com> Cc: "H. Peter Anvin" <hpa at zytor.com> Cc: Ingo Molnar <mingo at redhat.com> Cc: Jia He <justin.he at arm.com> Cc: Joe Perches <joe at perches.com> Cc: Kefeng Wang <wangkefeng.wang at huawei.com> Cc: Laurent Dufour <ldufour at linux.ibm.com> Cc: Michel Lespinasse <michel at lespinasse.org> Cc: Nathan Lynch <nathanl at linux.ibm.com> Cc: Nicholas Piggin <npiggin at gmail.com> Cc: Paul Mackerras <paulus at samba.org> Cc: Peter Zijlstra <peterz at infradead.org> Cc: Pierre Morel <pmorel at linux.ibm.com> Cc: "Rafael J. Wysocki" <rafael.j.wysocki at intel.com> Cc: Rich Felker <dalias at libc.org> Cc: Scott Cheloha <cheloha at linux.ibm.com> Cc: Sergei Trofimovich <slyfox at gentoo.org> Cc: Thiago Jung Bauermann <bauerman at linux.ibm.com> Cc: Thomas Gleixner <tglx at linutronix.de> Cc: Vasily Gorbik <gor at linux.ibm.com> Cc: Vishal Verma <vishal.l.verma at intel.com> Cc: Will Deacon <will at kernel.org> Cc: Yoshinori Sato <ysato at users.sourceforge.jp> Cc: <stable at vger.kernel.org> Signed-off-by: Andrew Morton <akpm at linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org> --- include/linux/memory_hotplug.h | 4 ++-- mm/memory_hotplug.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -339,8 +339,8 @@ extern void sparse_remove_section(struct unsigned long map_offset, struct vmem_altmap *altmap); extern struct page *sparse_decode_mem_map(unsigned long coded_mem_map, unsigned long pnum); -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); extern int arch_create_linear_mapping(int nid, u64 start, u64 size, struct mhp_params *params); void arch_remove_linear_mapping(u64 start, u64 size); --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -708,8 +708,8 @@ static inline struct zone *default_zone_ 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);