mm/memory_hotplug.c: use PFN_UP / PFN_DOWN in walk_system_ram_range()
authorDavid Hildenbrand <david@redhat.com>
Mon, 23 Sep 2019 22:35:55 +0000 (15:35 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 24 Sep 2019 22:54:09 +0000 (15:54 -0700)
Patch series "mm/memory_hotplug: online_pages() cleanups", v2.

Some cleanups (+ one fix for a special case) in the context of
online_pages().

This patch (of 5):

This makes it clearer that we will never call func() with duplicate PFNs
in case we have multiple sub-page memory resources.  All unaligned parts
of PFNs are completely discarded.

Link: http://lkml.kernel.org/r/20190814154109.3448-2-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Nadav Amit <namit@vmware.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Arun KS <arunks@codeaurora.org>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/resource.c

index 74877e9d90ca6402e937515b291661f5ea0c9377..76036a41143b9b136a51e0c56332e191669ac8bb 100644 (file)
@@ -487,8 +487,8 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
        while (start < end &&
               !find_next_iomem_res(start, end, flags, IORES_DESC_NONE,
                                    false, &res)) {
-               pfn = (res.start + PAGE_SIZE - 1) >> PAGE_SHIFT;
-               end_pfn = (res.end + 1) >> PAGE_SHIFT;
+               pfn = PFN_UP(res.start);
+               end_pfn = PFN_DOWN(res.end + 1);
                if (end_pfn > pfn)
                        ret = (*func)(pfn, end_pfn - pfn, arg);
                if (ret)