From patchwork Tue Mar 5 16:29:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13582705 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 13498C54798 for ; Tue, 5 Mar 2024 16:29:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B1CB6B0098; Tue, 5 Mar 2024 11:29:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8623F6B0099; Tue, 5 Mar 2024 11:29:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72ACF6B009A; Tue, 5 Mar 2024 11:29:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 643D86B0098 for ; Tue, 5 Mar 2024 11:29:51 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 17833A0EA8 for ; Tue, 5 Mar 2024 16:29:51 +0000 (UTC) X-FDA: 81863521782.05.4CC1154 Received: from fhigh8-smtp.messagingengine.com (fhigh8-smtp.messagingengine.com [103.168.172.159]) by imf10.hostedemail.com (Postfix) with ESMTP id 10A72C0011 for ; Tue, 5 Mar 2024 16:29:48 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="a uvd2yZ"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=pNqemNbZ; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf10.hostedemail.com: domain of zi.yan@sent.com designates 103.168.172.159 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=1709656189; 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=n7c5roTq8gGe7Zdj/lBmtvHsdOPMMzS9iluivszAxX0=; b=thcDV2KKHRPkGp8QMWtQ5/uXldpnGb4CAo85TSJpOouMcoVH0P1ei/F/e5dqLc/EFwL7sE S5bVCwTuzJ0NfxgtlRKDOhpyQF1whAcP4/eWBehJxPmtIu2/0y/o75dIfvVJ0qtRwk7X0K YJKTWKUK+RBvAn/1fwNo1VQl0DxwC3s= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="a uvd2yZ"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=pNqemNbZ; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf10.hostedemail.com: domain of zi.yan@sent.com designates 103.168.172.159 as permitted sender) smtp.mailfrom=zi.yan@sent.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709656189; a=rsa-sha256; cv=none; b=KUmouX+BMoJbB6uGmIx47D7TnSCnxTiMcL7unNz6af9kXX+UdDOZnpwxQ6cDcILxPgRhED 0E4vK6deRp3VYrQA0pgtAEIZjDaraRQEogoAxXszvlwX7tvom+e6L0Tm7bWNyiHlRqb87U wHwNNBVUvUjUAnfErMjwFtCJo83pDNA= Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 5A3901140163; Tue, 5 Mar 2024 11:29:48 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 05 Mar 2024 11:29:48 -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=1709656188; x= 1709742588; bh=n7c5roTq8gGe7Zdj/lBmtvHsdOPMMzS9iluivszAxX0=; b=a uvd2yZbwTCn09cqthFeDHdWNQofu24WCl6Myw1hvdOB7QPD3+n1dOBILUoXl4607 /yBuKVIUtwsBDOVeCcTyojfjktADopfAF2J8H9IVoBET+yr3kHDeVwHVWB5gHgQu DWeo99lMFOCAufCwXMQCRFkp39Pgp3gT+zzY0DXMuf8gczX0jeM1Tg6ZImdLGxS7 0jjNXFZG1lvDoCedI9yM5ngSfMpmPPIyG9I+jiytVUf3EOQN+gPA114WuLP9PP9d YAJfyZ/egJHJfiQ0RKuVaaikPgPwge+y4Uu7wOwHeSk+430OA2FIGCnBocWiAEdT rDZat6T78FAn1LXbsTxgQ== 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=1709656188; x=1709742588; bh=n 7c5roTq8gGe7Zdj/lBmtvHsdOPMMzS9iluivszAxX0=; b=pNqemNbZD+RLldtXf lR2UgKd40nsB2C8xwecE6bwaNBpVJxZuPXfoZjE0yATgVJO5gUg+l39vf0dBo84c mwVm6hJ/C3XfGvh/WC+TmQJ9rw6ENr5NPu9TSCZs5CO/6H1Q2mYKaExAxnvt8XUN F3AcnkRO2m4ssoR2M8bINmZ4qG6PxzBIWLasn04oC/OC+cTx6fjZITkv+DUEQOPA 6WTUWwgr5rd8zXWFC+kNAXMJUKZn3HV7yJiBk3++uJGChCY7FzVHTZioxiPSzzJ/ ScNpCO+Pu8lTkOh95McT0OMUHwu7ry3q/FOsG3cJq0YnPKKlwXKQ/YFmhGVLjfOb VSHdQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrheelgdekhecutefuodetggdotefrodftvf 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:29:47 -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.4.y] mm/migrate: set swap entry values of THP tail pages properly. Date: Tue, 5 Mar 2024 11:29:46 -0500 Message-ID: <20240305162946.94199-1-zi.yan@sent.com> X-Mailer: git-send-email 2.43.0 Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 10A72C0011 X-Stat-Signature: dgh1ushjetj14zh98ywpbzjdqxaact4j X-Rspam-User: X-HE-Tag: 1709656188-818918 X-HE-Meta: U2FsdGVkX1/SKU5ULM3muVpfY1XvpexoaZt0syRNCyIJzUqmgN4YKQxrT0uAYnDU4beglj9tH+rtKqGCUi8GJ6Rdp15SI6Y3C0idtwfhYm44DAUbS8XgEn1rlfACb6YuXupMG07EKfkKfSSHIt6RtQZzijiW8QfQ7Uou988/xh1r9n63b6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KtWHdtEP/L82H9t9wO+A0bpK3nwQCOU0mGwMMbj/Md9iJWGzIpbB6fZsyN0wCBFCL6ud1zjfwuWIqoyU8JVzJu2UbrRFZZOwI5W0usHJ+1pq9A0J9yza8aYwSfzq22WYfQGd/wT40TYhT17GUQ05I0NKuYSKHIHCHZqCiH5P4jfLyOIOW3uDlvWPMhJEU2Uy2P+Yfnr9tIc8Rmq53KKwvsKIVBJss5TEi7nc0Yiw5MaIfUYSguuc/mARwTYHFVUkSBm65ZxeIJxb+XUP0TUHsIyWQ== 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 034b0662fd3b..9cfd53eaeb4e 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -441,8 +441,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);