Skip to content

Commit a69578a

Browse files
Michal Hockotorvalds
authored andcommitted
mm, memory_hotplug: fix MMOP_ONLINE_KEEP behavior
Heiko Carstens has noticed that the MMOP_ONLINE_KEEP is broken currently $ grep . memory3?/valid_zones memory34/valid_zones:Normal Movable memory35/valid_zones:Normal Movable memory36/valid_zones:Normal Movable memory37/valid_zones:Normal Movable $ echo online_movable > memory34/state $ grep . memory3?/valid_zones memory34/valid_zones:Movable memory35/valid_zones:Movable memory36/valid_zones:Movable memory37/valid_zones:Movable $ echo online > memory36/state $ grep . memory3?/valid_zones memory34/valid_zones:Movable memory36/valid_zones:Normal memory37/valid_zones:Movable so we have effectively punched a hole into the movable zone. The problem is that move_pfn_range() check for MMOP_ONLINE_KEEP is wrong. It only checks whether the given range is already part of the movable zone which is not the case here as only memory34 is in the zone. Fix this by using allow_online_pfn_range(..., MMOP_ONLINE_KERNEL) if that is false then we can be sure that movable onlining is the right thing to do. Fixes: "mm, memory_hotplug: do not associate hotadded memory to zones until online" Link: http://lkml.kernel.org/r/20170601083746.4924-2-mhocko@kernel.org Signed-off-by: Michal Hocko <mhocko@suse.com> Reported-by: Heiko Carstens <heiko.carstens@de.ibm.com> Tested-by: Heiko Carstens <heiko.carstens@de.ibm.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Reza Arbab <arbab@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f1dd2cd commit a69578a

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎mm/memory_hotplug.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,11 +1115,12 @@ static struct zone * __meminit move_pfn_range(int online_type, int nid,
11151115
if (online_type == MMOP_ONLINE_KEEP) {
11161116
struct zone *movable_zone = &pgdat->node_zones[ZONE_MOVABLE];
11171117
/*
1118-
* MMOP_ONLINE_KEEP inherits the current zone which is
1119-
* ZONE_NORMAL by default but we might be within ZONE_MOVABLE
1120-
* already.
1118+
* MMOP_ONLINE_KEEP defaults to MMOP_ONLINE_KERNEL but use
1119+
* movable zone if that is not possible (e.g. we are within
1120+
* or past the existing movable zone)
11211121
*/
1122-
if (zone_intersects(movable_zone, start_pfn, nr_pages))
1122+
if (!allow_online_pfn_range(nid, start_pfn, nr_pages,
1123+
MMOP_ONLINE_KERNEL))
11231124
zone = movable_zone;
11241125
} else if (online_type == MMOP_ONLINE_MOVABLE) {
11251126
zone = &pgdat->node_zones[ZONE_MOVABLE];

0 commit comments

Comments
 (0)