From patchwork Tue Mar 5 16:13:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13582650 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 A6801C54798 for ; Tue, 5 Mar 2024 16:13:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 372CE6B0080; Tue, 5 Mar 2024 11:13:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 32C8A6B0082; Tue, 5 Mar 2024 11:13:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C3226B0085; Tue, 5 Mar 2024 11:13:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0CCCF6B0080 for ; Tue, 5 Mar 2024 11:13:21 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BD7C4A146A for ; Tue, 5 Mar 2024 16:13:20 +0000 (UTC) X-FDA: 81863480160.15.ED057C6 Received: from fout5-smtp.messagingengine.com (fout5-smtp.messagingengine.com [103.168.172.148]) by imf29.hostedemail.com (Postfix) with ESMTP id 75E5912001B for ; Tue, 5 Mar 2024 16:13:17 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="X u6QgjH"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=SsXzf1m9; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf29.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=1709655197; 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=MQAE8rdyXk8pt4o4BGwUXXML/VVJgez4A8nNBD4O3ko=; b=h+LEgGtmmmi9j8bIBiNUTkLGnwDIV6GtFg0duJyzdVRIhUOAn97Fry1XIjgZji8hhFtWKq jAWTe+9YvL8Ivnqqe58ulPuzdbv2At8ZdnZWbWVN9kEhJgsBtK4JjRngHjV7FNlHfq0bjQ MZg1GZUqM7hR3DAtyfiGpLW7SxYlmZ0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="X u6QgjH"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=SsXzf1m9; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf29.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=1709655197; a=rsa-sha256; cv=none; b=fDxhLBjoxDBZuyi/5+3tzFT11F8WHQm5ohAOAiAZOR1ApSwvi9taX7duvswiBaFhXwRSFO vtCf63fwsU5akDwTTVa9L9+tFd5WCYzWri09iA6S7ZjYLI4jrnTilvM7F6jvOO5iPpy6af JaZ7+/cFmQ7dYMeJo/8yekQTu70kLIE= Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.nyi.internal (Postfix) with ESMTP id C17AE1380090; Tue, 5 Mar 2024 11:13:16 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 05 Mar 2024 11:13:16 -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=1709655196; x= 1709741596; bh=MQAE8rdyXk8pt4o4BGwUXXML/VVJgez4A8nNBD4O3ko=; b=X u6QgjH+5jDGIMtcjeBRFliBnb6LrSlR0ueQg79UXqwcL36H8IEGor8B+WeLGlToe uWCu5wQJRkp8Up/7yvivt4HxGedY6fFPI77nWGwEGyB4DzCWl8JmlWcBtOHhXn92 ulX8/bCf2D+T/vQvTQrfFjPusWdOI8s+R8/Ntk8LRJpomEwRsLL+VTw/G4rVy+PC gG/oUNph2lv5lxx0qVOekGwB+ba37p09lVcnUtatUmf2iB5AeTOpgiquIVyW0SQU dxz5Z/29NxFuWIyUbjpMh+eS/jZftb5MpZtovwR3c0m8zW4XstHK27+d76/qEgtn MVedtOizH+XkUrzwMbTHQ== 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=1709655196; x=1709741596; bh=M QAE8rdyXk8pt4o4BGwUXXML/VVJgez4A8nNBD4O3ko=; b=SsXzf1m9in2NrK/ar sVIOBIj+uvIzmq3uRSdbepmc8IIM7+Ahf/XoSSbfb51DYXkoZ1Buv9INR6AYMFtK yixwOZ/T/Rmrgpqd1WajfAChKRP/CRouYbyE3TWIg1xbAlAPaa9sALWd0VHzlYVp msJYt+ZzWGBzgEbwYb+EXUAXLj00M8wIJKGBooeSJTWR5Avd3+T9U+tN3vq1Qo3m 2coZ/0MjB6I9Oo4aBt8e02Vy/J5zQMrQq8gT1J9DQ6VzSFnzcHRgBV+dYmFwdes1 CeehtksYDHkrpuEJOvm6g4AI+kvAJ/c67U65JacLPuooSS6pA86OFcnYI3OQpPIr fatjQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrheelgdekvdcutefuodetggdotefrodftvf 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:13:16 -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 v6.1.y] mm/migrate: set swap entry values of THP tail pages properly. Date: Tue, 5 Mar 2024 11:13:13 -0500 Message-ID: <20240305161313.90954-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: 75E5912001B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: qc9pjgc4cgh36i9f4gkfx613xfeogcd1 X-HE-Tag: 1709655197-196899 X-HE-Meta: U2FsdGVkX19MthaBN9QGWsilUMJoJkeUXB550+9tdA6LTXSmLKd/9xXS7JdgYZ6Ox/P9NgME/tjTD++fSxlUpm8BZUQL1twgVoWt5pJLvXLJJl4lQzGtxzvC7NC5MYMyBzlVTqdMlSn6hlT8vIjYA7aTna8tJ4PnUjUyNC7FIksGQJiU640aEolhf4GZQybJQvHG/+3h6Bkh9Cphjzu4fR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LGl0m8fi+z3KDU0YgaszDDNuszmUEKNKtvCOnnLul0PPscJDrLMdkz8fJjepoHOYNYXFKi9l4TLO/9YXsR6BglDuntTxofIWemwGG5X/cFQgxMrSK7Iif2DhKoP6NGzp404gHfATh6E1XzYqvFQ9NLXEZ 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. 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 c93dd6a31c31..c5968021fde0 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -423,8 +423,12 @@ int folio_migrate_mapping(struct address_space *mapping, if (folio_test_swapbacked(folio)) { __folio_set_swapbacked(newfolio); if (folio_test_swapcache(folio)) { + int i; + folio_set_swapcache(newfolio); - newfolio->private = folio_get_private(folio); + for (i = 0; i < nr; i++) + set_page_private(folio_page(newfolio, i), + page_private(folio_page(folio, i))); } entries = nr; } else {