From patchwork Tue Mar 5 16:19:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13582667 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE1F7C54798 for ; Tue, 5 Mar 2024 16:19:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 412EE6B0085; Tue, 5 Mar 2024 11:19:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C37A6B0087; Tue, 5 Mar 2024 11:19:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 263DC6B0088; Tue, 5 Mar 2024 11:19:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 10F5F6B0085 for ; Tue, 5 Mar 2024 11:19:47 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DDFBA40291 for ; Tue, 5 Mar 2024 16:19:46 +0000 (UTC) X-FDA: 81863496372.27.6A0661B Received: from fout5-smtp.messagingengine.com (fout5-smtp.messagingengine.com [103.168.172.148]) by imf14.hostedemail.com (Postfix) with ESMTP id E40BA10000E for ; Tue, 5 Mar 2024 16:19:44 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="I EjOGKw"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=AIE7XwLq; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf14.hostedemail.com: domain of zi.yan@sent.com designates 103.168.172.148 as permitted sender) smtp.mailfrom=zi.yan@sent.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709655585; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=cebIwQz4NE6KUjZeHKpCkqPfLkmI0BXvci7kY9MsUcE=; b=p94aHS+w8EQXw64x9S0gB++OOAKMqv6NWOP5ymt4SpChCKkuUxvGao5SwspS7MCS8bwxAd qKxXo85uE9iOBHP5yhHh81Dc6a/uUdKJRkPXdhVc4z0GPmc5tlzsPZWEA6pfMBgYCeAf8N nxzuUyrhXMr2Fhf70fMnP4SLkAfN9Bo= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="I EjOGKw"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=AIE7XwLq; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf14.hostedemail.com: domain of zi.yan@sent.com designates 103.168.172.148 as permitted sender) smtp.mailfrom=zi.yan@sent.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709655585; a=rsa-sha256; cv=none; b=NJR/+SxFp06yDr5I9zJDOguAApkgch7Z4LUSqUVBLIaYr2w5KqWQEMoT4WqPUrn9Z1a/LP WCWp5PIr2z5/bgTWu5tincw469gUk07Z4RG1T7sQpJTjOCWYPYjvycJXKkney1o3tQ57ES y0v+rOYUq05kIRjMG3PWcDpTIFPbKBk= Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfout.nyi.internal (Postfix) with ESMTP id 2622713800B1; Tue, 5 Mar 2024 11:19:44 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Tue, 05 Mar 2024 11:19:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:message-id:mime-version:reply-to :reply-to:subject:subject:to:to; s=fm1; t=1709655584; x= 1709741984; bh=cebIwQz4NE6KUjZeHKpCkqPfLkmI0BXvci7kY9MsUcE=; b=I EjOGKw+d1D5ItrmlyPGojuFO9uDQlLbVEi7LuqSXVk0HPAD88/dwDHLjL3MmhO/Q AoyurWi+C+wgEt8315i3L3a5eINHI1oYCyv38FbJtnwwxS1HNznpbFy99KmIv72U 7RP9mShGBf7pEDdZTruFhVfOOk/tS5NtKdo9Vqr8b4jk26xLOUq7Ph1L5+CbXQcs J+14tl802knRJKPOvIVvaD9SuTNRCWc7eOSj1O8jPhgNga66OGxmaGBzgxpj42kG Dx0VsEQJ6EyBahrr/6O2/uZWqzYdM7ARty3CTqT3lpHF8Dec+jgfW3g7GutvUjNp OOnD8yXOqWG42wsnfLNSA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:message-id:mime-version:reply-to:reply-to :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1709655584; x=1709741984; bh=c ebIwQz4NE6KUjZeHKpCkqPfLkmI0BXvci7kY9MsUcE=; b=AIE7XwLqaGXhbulex VKKMwfx9YLj5KULgFZdcRGhADOxNcg6mJyCWmygmHXmaFi1P3Wk04jHNQ6YPHkr5 mLe62m1h0EpSR1ql0c+JabwcFp504X1cb+xeb9tdRia1eh4WDlULsL1lGDId7utd k8XcMR6utJNbj5gpJkLaWWKIw6AoGaifpe+EFumMZJ4GLzlCnZ9GcJflNshz3krA o0xavWB0+vqB8HdKQjmmosrRvPuu+Qc4XsrXfo3ym+1fPbVRg7NuLjicjCUiehy2 om/evbkXMzSJv+7HqqkWZs8jbgKeCowi+WS4auJ3WGOzcucAHiznicv38kxf2/kv aaeGA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrheelgdekgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkfforhggtgfgsehtkeertdertdejnecuhfhrohhmpegkihcujggr nhcuoeiiihdrhigrnhesshgvnhhtrdgtohhmqeenucggtffrrghtthgvrhhnpeeuveethe evudduffevteefheeukeehuedtueehieehieelveegveeuffeileffhfenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpeiiihdrhigrnhesshgvnh htrdgtohhm X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 5 Mar 2024 11:19:43 -0500 (EST) From: Zi Yan To: gregkh@linuxfoundation.org, stable@vger.kernel.org Cc: Zi Yan , linux-mm@kvack.org, Charan Teja Kalla , "Matthew Wilcox (Oracle)" , David Hildenbrand , Andrew Morton , Huang Ying , Naoya Horiguchi Subject: [PATCH STABLE v5.15.y] mm/migrate: set swap entry values of THP tail pages properly. Date: Tue, 5 Mar 2024 11:19:41 -0500 Message-ID: <20240305161941.92021-1-zi.yan@sent.com> X-Mailer: git-send-email 2.43.0 Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Queue-Id: E40BA10000E X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: yo1d3y68uzeojrjx1bhewma6ng6rfs3o X-HE-Tag: 1709655584-88814 X-HE-Meta: U2FsdGVkX1+guwsL1T3spLciG3AmJyLH2fYQI0h2E44q6ZHdW4dr/uUpSZ4BZryIINNMdP+xpCk/dVxlnM9F1Nqx8cEFgZhcMNFfVu+9fbmJGEQ8fR7GyS+rCwec14qAlTYG9f9z1+MHgO3VlNXRJdPMSsCaLE2MVmQvAfDv3fDG4IcZ5o4kaSpm9rCX2qhKftvawxpVvvNPaXs8E5j6s5oaxeTi3j1XBh6I9eqJe0ZxabUyn2Mt9cad8JzHobex5+HMIeiBcW9QzvudZzVug/WxIi/vHY8JyY2cjnYJfmKt8Qpg+C1AxOw6zgSe5IQrJP5f6XljOHzs/DX2B10pi3z22V7W1PV1wBC/K6P0VsZxXSqxTNSzsm7LWKioW3t3T23nyzEZP7hZ1ixu1bu/T3toqVHClgogDwQQT3JX/ByYZy4TlWC2dDqI5YMe6NgiIGuX8nKZs9dI8y+iNIQGwrAMkoXSNHw5d9xghQ9mYOU0XztB/tTa6dXRt4YELIB2BKaja5A8twTtcj93Hq0tgwNmr4/i9gDxOiggrbGs6VshcPJNU/U5HFouA8ffXJAIQvVWiV3gNGEeE3KfgRGOAFAjuupyhQzYZUFmib6TvJ0G/hr19vSEfyQBcEBiLQsrT5BHkzOK0CkdbMLl+4/FJy8uJk68RbX6hbqANcUf6XWZoOCwXRJI5y5K3mQLUuv7tY/gH8c6Kh7XxWK16KyiL+yW6syCcAS0NVaJXgONWk3Em2Fb2ewdq3erGR02BIyampT6MbWCXcvhx/gz/3MChxOmWFsfQ7EI3zZCJPGj+nYle51y0uI9k7uP6v6ebla4u5gR3FMVcF7AUC5RQ+IjWl8aZJzA7d9MYAGYDtIllJaXykxPbYdEoYB4vJk1tkcikKLq6LJBa02+cOqXF+x1xbFJ9D0oBINSXQp9vBUkZE398kYoGgWTx0YJmGv6S8ugI7PZ8zfSN7/Wg2z1eqB Hb2RiE+x HVBqxxZ/UDkPMw1WtIWcClgReMqgDKF90TI98D8U346U7+CrsN6vW1IWoUvODxaqK0HJqKRlCqqaGqQl2MJUbQ4Kwu8nJ+qsB367cLkRAWvvOUIc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Zi Yan The tail pages in a THP can have swap entry information stored in their private field. When migrating to a new page, all tail pages of the new page need to update ->private to avoid future data corruption. Corresponding swapcache entries need to be updated as well. e71769ae5260 ("mm: enable thp migration for shmem thp") fixed it already. Fixes: 616b8371539a ("mm: thp: enable thp migration in generic path") Signed-off-by: Zi Yan Acked-by: David Hildenbrand --- mm/migrate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/migrate.c b/mm/migrate.c index c7d5566623ad..c37af50f312d 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -424,8 +424,12 @@ int migrate_page_move_mapping(struct address_space *mapping, if (PageSwapBacked(page)) { __SetPageSwapBacked(newpage); if (PageSwapCache(page)) { + int i; + SetPageSwapCache(newpage); - set_page_private(newpage, page_private(page)); + for (i = 0; i < (1 << compound_order(page)); i++) + set_page_private(newpage + i, + page_private(page + i)); } } else { VM_BUG_ON_PAGE(PageSwapCache(page), page);