Skip to content

Commit dd8e2f2

Browse files
osalvadorvilardagatorvalds
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>
1 parent 8736cc2 commit dd8e2f2

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
@@ -838,9 +838,16 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,
838838
int ret;
839839
struct memory_notify arg;
840840

841-
/* We can only online full sections (e.g., SECTION_IS_ONLINE) */
841+
/*
842+
* {on,off}lining is constrained to full memory sections (or more
843+
* precisly to memory blocks from the user space POV).
844+
* memmap_on_memory is an exception because it reserves initial part
845+
* of the physical memory space for vmemmaps. That space is pageblock
846+
* aligned.
847+
*/
842848
if (WARN_ON_ONCE(!nr_pages ||
843-
!IS_ALIGNED(pfn | nr_pages, PAGES_PER_SECTION)))
849+
!IS_ALIGNED(pfn, pageblock_nr_pages) ||
850+
!IS_ALIGNED(pfn + nr_pages, PAGES_PER_SECTION)))
844851
return -EINVAL;
845852

846853
mem_hotplug_begin();
@@ -1573,9 +1580,16 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages)
15731580
int ret, node;
15741581
char *reason;
15751582

1576-
/* We can only offline full sections (e.g., SECTION_IS_ONLINE) */
1583+
/*
1584+
* {on,off}lining is constrained to full memory sections (or more
1585+
* precisly to memory blocks from the user space POV).
1586+
* memmap_on_memory is an exception because it reserves initial part
1587+
* of the physical memory space for vmemmaps. That space is pageblock
1588+
* aligned.
1589+
*/
15771590
if (WARN_ON_ONCE(!nr_pages ||
1578-
!IS_ALIGNED(start_pfn | nr_pages, PAGES_PER_SECTION)))
1591+
!IS_ALIGNED(start_pfn, pageblock_nr_pages) ||
1592+
!IS_ALIGNED(start_pfn + nr_pages, PAGES_PER_SECTION)))
15791593
return -EINVAL;
15801594

15811595
mem_hotplug_begin();

0 commit comments

Comments
 (0)