From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AAF5C433EF for ; Wed, 8 Jun 2022 01:53:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390672AbiFHBvG (ORCPT ); Tue, 7 Jun 2022 21:51:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383129AbiFGWTU (ORCPT ); Tue, 7 Jun 2022 18:19:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC9FD19762D; Tue, 7 Jun 2022 12:20:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2204F60906; Tue, 7 Jun 2022 19:20:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B1B6C341C0; Tue, 7 Jun 2022 19:20:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629635; bh=EO8JBHw8FJVtlQsdM5QRvdHxzQHvifwHotLYtOSjkqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fGm1j5HzJUfR/BJAjzpGSwR4UaOFxfCrR0hgcR7F18XKmk4q7sfMaikdh3LyNZR47 wgyCpCEpItQSyqYBrRzvzvdQV28mZo374VYiIsqH4MxT9vHHG0hGxvC/3ZJDESa7mF HYPqwyVmgFROOvliTJOD8ja8X3ElCeRZihjL7cSk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rei Yamamoto , Miaohe Lin , Mel Gorman , Oscar Salvador , Don Dutile , Wonhyuk Yang , Andrew Morton Subject: [PATCH 5.18 760/879] mm, compaction: fast_find_migrateblock() should return pfn in the target zone Date: Tue, 7 Jun 2022 19:04:38 +0200 Message-Id: <20220607165024.924465598@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rei Yamamoto commit bbe832b9db2e1ad21522f8f0bf02775fff8a0e0e upstream. 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 a984226f457f849e ("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: 70b44595eafe ("mm, compaction: use free lists to quickly locate a migration source") Signed-off-by: Rei Yamamoto Reviewed-by: Miaohe Lin Acked-by: Mel Gorman Reviewed-by: Oscar Salvador Cc: Don Dutile Cc: Wonhyuk Yang Cc: Rei Yamamoto Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/compaction.c | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1858,6 +1858,8 @@ static unsigned long fast_find_migratebl update_fast_start_pfn(cc, 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; found_block = true; set_pageblock_skip(freepage);