From patchwork Tue Mar 5 16:32: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: 13582708 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 04258C54E41 for ; Tue, 5 Mar 2024 16:32:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7306D940008; Tue, 5 Mar 2024 11:32:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B70E940007; Tue, 5 Mar 2024 11:32:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 557E9940008; Tue, 5 Mar 2024 11:32:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 40E1D940007 for ; Tue, 5 Mar 2024 11:32:19 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id EEF961A0BF6 for ; Tue, 5 Mar 2024 16:32:18 +0000 (UTC) X-FDA: 81863527956.16.C21D8E3 Received: from fhigh8-smtp.messagingengine.com (fhigh8-smtp.messagingengine.com [103.168.172.159]) by imf30.hostedemail.com (Postfix) with ESMTP id D8DD080027 for ; Tue, 5 Mar 2024 16:32:16 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="A 8Sdnuz"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=pgGINRdA; spf=pass (imf30.hostedemail.com: domain of zi.yan@sent.com designates 103.168.172.159 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709656337; 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=6l285yO6SumF56rDdMfLu5SKNuqZg2rVZIvbyL2k2BA=; b=aMNNl3Wzi1Z//S7DjhirPOlZhwWU14vdl+Uc+hd3jt8sEswjylB08DxzhnFPpCpSg0dOjq CSH8CXAIPAyXF0+q2cJiNKDUKh/bS1CpXtmZ3xXohi8aL0xrAH2iVaJ/eGIp5dRvrqwGkz 4p0TtekgvG6IlBtD0ZmDfNiSFDXqL0E= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="A 8Sdnuz"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=pgGINRdA; spf=pass (imf30.hostedemail.com: domain of zi.yan@sent.com designates 103.168.172.159 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709656337; a=rsa-sha256; cv=none; b=0v9qsnxZLR/6Dln4BmH2UY2Gwju0CebmBN4ULTMQU0WpU82fMlF5sNB57LwOT4rSTvWzz6 uLeqC0tThNIYC1H19iLPEp1uHRZt1b2cg7UDqomivJNdYw9OPLl14sNM42aLRu6HRUKUOe fOakb7kwX9qwsdKJaS7DY1D1t+C6hVY= Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 2E17211400FA; Tue, 5 Mar 2024 11:32:16 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 05 Mar 2024 11:32: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=1709656336; x= 1709742736; bh=6l285yO6SumF56rDdMfLu5SKNuqZg2rVZIvbyL2k2BA=; b=A 8SdnuzYJGaXbdWUdJ+PSgE2BryZ9iNej8TjYTDd3Ymh2Mc4phWdDj5CAOaz4AKaZ Pyivn+LxudPB2jyo6rhKEIIEA+UFvpQWYvQPr7Y8V8zlrOAeyU6gve6NNVwMWPkv jqnAjwMDcUTsIYlf+bks0XnuXsJ7uUMZwwhc3aEXBAkldeZKBYjGSSz3xxhHlYax Zug0Hvx5uKx51mBtFsqq057nQKKKoUnDtBQooyOpNIJkztFLFs8fEw6SnP11xp9B dAPXrsZZl4S3KJoyX2GIRG8cyigcUnjXM1EXLCftRzvb3FzBZXLAeKUJ4OwnItGV 3Zcjkbhn4pwFPEQLO1oBA== 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=1709656336; x=1709742736; bh=6 l285yO6SumF56rDdMfLu5SKNuqZg2rVZIvbyL2k2BA=; b=pgGINRdA7K+YCaJwT neOMX3paB4tUiUZGiRKSDl8zAfH61KMyvp4C/75dHDmDwjwfAz/6HCATObc7ltoQ 2t7jZeluRdT3MVsYqqvp6dHFKTJTfjT6ZmSVC7DhaHFwsSKqg4C/4jdBtvr5Hjy9 +pVMPLxm/PcXjEqgPiYpt5n7bZBSbA3ZEe8bRXd1v1Z2vNtWPvGr/YA+QPKteoyF jB5Q2JIM176OV8E3UWPH98OgZLuuzYZsW9kFnXNNHLxC3a0ll6guxRzkYWHlkJv8 XJoAit3ZiqPP+HaE7o+DlWEwtq6OMnnL8dbZD1SJ0BE5gALMFQ3yRzA0bjsT0AdT d4iqA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrheelgdekiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkfforhggtgfgsehtkeertdertdejnecuhfhrohhmpegkihcujggr nhcuoeiiihdrhigrnhesshgvnhhtrdgtohhmqeenucggtffrrghtthgvrhhnpeetudevhe etheehieetiefhjeevjeeltdfgvdeiueeiudetffdtvedthfetvedtffenucffohhmrghi nhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepiihirdihrghnsehsvghnthdrtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 5 Mar 2024 11:32:14 -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 v4.19.y] mm/migrate: set swap entry values of THP tail pages properly. Date: Tue, 5 Mar 2024 11:32:13 -0500 Message-ID: <20240305163213.95119-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: D8DD080027 X-Rspam-User: X-Stat-Signature: kkzdzwmmi5t67dmyz5jxtjo3npastpcy X-Rspamd-Server: rspam01 X-HE-Tag: 1709656336-328556 X-HE-Meta: U2FsdGVkX1/UJVrNjAc4GAFw9CFz1lJkU7yIIJJ57EYhhONuoyqU0CF0V5bXgHwoF9eeqqP6QM+PYdGfOr7i91z8yqGZI1T7XSHnW0F+KHAd0wLSpY0S3HyGyqZDmSGdpWocEsBMPlUvr5b74nzXGtwEeX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EbppQJQWzhN8x6pMBHQuCNPvZHpXvpx5C/w8bnNsW5A6P2+Vh8WxvkXkwtDAA94gu+u1WaVDI2kOU6zLfyBbbn3dLn671OxihyLniCVcukGB3oO0XYcVd/T2NM9Om29pRQqyJmQ7L71p58u65i8NRJ0joj6qMXARt/7x8P7SuSg2xpCeMaB1wf+vjxj0bG0bW/p3XlaMC2azKa167ssiEz8s6GyUYcY1IxqnKghLvrTHNCmcGBgg1WOSsU6atoa4Ym9tP++/9aeb2A+20G/hLuEoVthpF/d5Bohd4HjLDQ== 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. Closes: https://lore.kernel.org/linux-mm/1707814102-22682-1-git-send-email-quic_charante@quicinc.com/ 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 171573613c39..893ea04498f7 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -514,8 +514,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);