Commit bbe832b9 authored by Rei Yamamoto's avatar Rei Yamamoto Committed by Andrew Morton

mm, compaction: fast_find_migrateblock() should return pfn in the target zone

At present, pages not in the target zone are added to cc->migratepages
list in isolate_migratepages_block().  As a result, pages may migrate
between nodes unintentionally.

This would be a serious problem for older kernels without commit
a984226f ("mm: memcontrol: remove the pgdata parameter of
mem_cgroup_page_lruvec"), because it can corrupt the lru list by
handling pages in list without holding proper lru_lock.

Avoid returning a pfn outside the target zone in the case that it is
not aligned with a pageblock boundary.  Otherwise
isolate_migratepages_block() will handle pages not in the target zone.

Link: https://lkml.kernel.org/r/20220511044300.4069-1-yamamoto.rei@jp.fujitsu.com
Fixes: 70b44595 ("mm, compaction: use free lists to quickly locate a migration source")
Signed-off-by: default avatarRei Yamamoto <yamamoto.rei@jp.fujitsu.com>
Reviewed-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Acked-by: default avatarMel Gorman <mgorman@techsingularity.net>
Reviewed-by: default avatarOscar Salvador <osalvador@suse.de>
Cc: Don Dutile <ddutile@redhat.com>
Cc: Wonhyuk Yang <vvghjk1234@gmail.com>
Cc: Rei Yamamoto <yamamoto.rei@jp.fujitsu.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent d4a157f5
...@@ -1848,6 +1848,8 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) ...@@ -1848,6 +1848,8 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)
update_fast_start_pfn(cc, free_pfn); update_fast_start_pfn(cc, free_pfn);
pfn = pageblock_start_pfn(free_pfn); pfn = pageblock_start_pfn(free_pfn);
if (pfn < cc->zone->zone_start_pfn)
pfn = cc->zone->zone_start_pfn;
cc->fast_search_fail = 0; cc->fast_search_fail = 0;
found_block = true; found_block = true;
set_pageblock_skip(freepage); set_pageblock_skip(freepage);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment