From ff56a97530f78b482b65a531e6c6f7337a84a0bf Mon Sep 17 00:00:00 2001 From: Charan Teja Reddy Date: Wed, 23 Dec 2020 13:32:07 +0530 Subject: [PATCH] mem-offline: disallow page migration to isolated page blocks The isolated page blocks shouldn't be used as migration destination. Consider the below scenario: Pa Pb __offline_pages() isolate the page blocks migrate the page to the isolated page block offline the memory block online the same memory block which clears the page refcount and try to put the page to buddy In the above scenario, Pa is migrating the page to the page block on what Pb is trying to offline after the page block is isolated. This can cause the issues like wrong page contents, memory offline failures. Change-Id: Ibceaa17ed34e4c7f38d555bc82189d7eb212cfcc Signed-off-by: Charan Teja Reddy --- drivers/soc/qcom/mem-offline.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/soc/qcom/mem-offline.c b/drivers/soc/qcom/mem-offline.c index 2964948a8a1a..9ce89e6fa54a 100644 --- a/drivers/soc/qcom/mem-offline.c +++ b/drivers/soc/qcom/mem-offline.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -460,6 +461,12 @@ static void isolate_free_pages(struct movable_zone_fill_control *fc) continue; } + if (!(start_pfn % pageblock_nr_pages) && + is_migrate_isolate_page(page)) { + start_pfn += pageblock_nr_pages - 1; + continue; + } + if (!PageBuddy(page)) continue;