Skip to content

Commit 80a6563

Browse files
osalvadorvilardagashaoyingxu
authored andcommitted
mm,memory_hotplug: relax fully spanned sections check
We want {online,offline}_pages to operate on whole memblocks, but memmap_on_memory will poke pageblock_nr_pages aligned holes in the beginning, which is a special case we want to allow. Relax the check to account for that case. Link: https://lkml.kernel.org/r/20210421102701.25051-3-osalvador@suse.de Signed-off-by: Oscar Salvador <osalvador@suse.de> Reviewed-by: David Hildenbrand <david@redhat.com> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Anshuman Khandual <anshuman.khandual@arm.com> Cc: Pavel Tatashin <pasha.tatashin@soleen.com> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> (cherry -picked from commit dd8e2f2)
1 parent 13486a0 commit 80a6563

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

mm/memory_hotplug.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,16 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,
786786
int ret;
787787
struct memory_notify arg;
788788

789-
/* We can only online full sections (e.g., SECTION_IS_ONLINE) */
789+
/*
790+
* {on,off}lining is constrained to full memory sections (or more
791+
* precisly to memory blocks from the user space POV).
792+
* memmap_on_memory is an exception because it reserves initial part
793+
* of the physical memory space for vmemmaps. That space is pageblock
794+
* aligned.
795+
*/
790796
if (WARN_ON_ONCE(!nr_pages ||
791-
!IS_ALIGNED(pfn | nr_pages, PAGES_PER_SECTION)))
797+
!IS_ALIGNED(pfn, pageblock_nr_pages) ||
798+
!IS_ALIGNED(pfn + nr_pages, PAGES_PER_SECTION)))
792799
return -EINVAL;
793800

794801
mem_hotplug_begin();
@@ -1465,9 +1472,16 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages)
14651472
int ret, node;
14661473
char *reason;
14671474

1468-
/* We can only offline full sections (e.g., SECTION_IS_ONLINE) */
1475+
/*
1476+
* {on,off}lining is constrained to full memory sections (or more
1477+
* precisly to memory blocks from the user space POV).
1478+
* memmap_on_memory is an exception because it reserves initial part
1479+
* of the physical memory space for vmemmaps. That space is pageblock
1480+
* aligned.
1481+
*/
14691482
if (WARN_ON_ONCE(!nr_pages ||
1470-
!IS_ALIGNED(start_pfn | nr_pages, PAGES_PER_SECTION)))
1483+
!IS_ALIGNED(start_pfn, pageblock_nr_pages) ||
1484+
!IS_ALIGNED(start_pfn + nr_pages, PAGES_PER_SECTION)))
14711485
return -EINVAL;
14721486

14731487
mem_hotplug_begin();

0 commit comments

Comments
 (0)