Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm, memory_hotplug: __offline_pages fix wrong locking

Jan has noticed that we do double unlock on some failure paths when
offlining a page range. This is indeed the case when
test_pages_in_a_zone respp. start_isolate_page_range fail. This was an
omission when forward porting the debugging patch from an older kernel.

Fix the issue by dropping mem_hotplug_done from the failure condition
and keeping the single unlock in the catch all failure path.

Link: http://lkml.kernel.org/r/20190115120307.22768-1-mhocko@kernel.org
Fixes: 7960509329c2 ("mm, memory_hotplug: print reason for the offlining failure")
Signed-off-by: Michal Hocko <mhocko@suse.com>
Reported-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jan Kara <jack@suse.cz>
Tested-by: Jan Kara <jack@suse.cz>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Michal Hocko and committed by
Linus Torvalds
e3df4c6e 6376360e

-2
-2
mm/memory_hotplug.c
··· 1570 1570 we assume this for now. .*/ 1571 1571 if (!test_pages_in_a_zone(start_pfn, end_pfn, &valid_start, 1572 1572 &valid_end)) { 1573 - mem_hotplug_done(); 1574 1573 ret = -EINVAL; 1575 1574 reason = "multizone range"; 1576 1575 goto failed_removal; ··· 1584 1585 MIGRATE_MOVABLE, 1585 1586 SKIP_HWPOISON | REPORT_FAILURE); 1586 1587 if (ret) { 1587 - mem_hotplug_done(); 1588 1588 reason = "failure to isolate range"; 1589 1589 goto failed_removal; 1590 1590 }