From patchwork Tue Mar 5 16:27:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13582704 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 E0751C54798 for ; Tue, 5 Mar 2024 16:27:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 729B96B0095; Tue, 5 Mar 2024 11:27:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6DA056B0096; Tue, 5 Mar 2024 11:27:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 506546B0098; Tue, 5 Mar 2024 11:27:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3E3A16B0095 for ; Tue, 5 Mar 2024 11:27:51 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0F97D1A0306 for ; Tue, 5 Mar 2024 16:27:51 +0000 (UTC) X-FDA: 81863516742.29.5241B66 Received: from fhigh8-smtp.messagingengine.com (fhigh8-smtp.messagingengine.com [103.168.172.159]) by imf09.hostedemail.com (Postfix) with ESMTP id 05338140002 for ; Tue, 5 Mar 2024 16:27:48 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="I XJBrMF"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=T9NjM0uB; spf=pass (imf09.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=1709656069; 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=rv9CWGPrXcYc3Xg91xHt2tGn5vOuXTAu4AiypxdwtfI=; b=jA5xDB4tJjNB4CHK+B73N4ZJx5Ls1PLyd+Fy+zykzrq4DR7JA32JgKKez/8AXWnuVQV4Dq 91xJi4XaqN180Kc2izvbHjustl7bJNGhXe2vyyaLRyBEWkOauEcJmjr+eeqVk/1Ew+ZA2C 05fq1qgT2Pvf/pO3gdbg1qbrqFoJ8OQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709656069; a=rsa-sha256; cv=none; b=NdWmETUGIDFtCmjVNrXEeiCLQCDYjICob11rF0XQ/sWnQZkPLacVeoPVLaj9eVrp+45CjU MfjmjKZHrDHXdvk1f9xS41ffHhwDcn0tcTy63LaubzBiSwvuCKTUzhUImihQCzKl0wOMb6 TUXi9s+oLRIT9AqbK0NS8ILn7amwi2Y= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="I XJBrMF"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=T9NjM0uB; spf=pass (imf09.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 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 3ECC21140102; Tue, 5 Mar 2024 11:27:48 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 05 Mar 2024 11:27: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=1709656068; x= 1709742468; bh=rv9CWGPrXcYc3Xg91xHt2tGn5vOuXTAu4AiypxdwtfI=; b=I XJBrMF6GoMrvn8+2qQGNQfmtPI48iFvUdOMd6UMFm0M/R6y72wKrBkOCzZPLEhJn F10PoPYhf28TG+LMEJ3VvAJgfDiMxdaAPNUvl8cvHwGomtDOvvbuOLfLzns6bkWw TzxpAHeZtrr3MB/DE/gQg0Ixj0brKQVL/qDo+mgEo1X+vXPlqJR/reosqegOBX+h +iWWh5rWqdP2DFAeJMrX5eZMXi+qjVVWCtjVikKjSmBQB+Zz29Wfd4tfAgYTd5Jb lkwNY5XYbG5H2KRSXitZxxDzneYCwvPSULojxHqB0Jx59Uvv3KRoEfbzn4qCbirg 612HWqQYsf8GIZxmWn9mQ== 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=1709656068; x=1709742468; bh=r v9CWGPrXcYc3Xg91xHt2tGn5vOuXTAu4AiypxdwtfI=; b=T9NjM0uBULIOagiAZ 4H3YfMTXy9Giplp5/jyZVKAOMXFL0v14dvzCr/k4n/cAE/wrDFt40DXNvUIxZ6J0 upSDkvR6GVfcIe9QfTr46boPX2rJEpp/fMGJ8uAJ99E3adEa9xOGpLVrPNBfJDkP TkDDPhYnN64VyX8Y2L2X3VtkGi7TzlRH4WJsFITZ1UdFV8573qCnTnpIhLRioPLn UvyEYbJAGFtQhUEsZz72ZnBCggfbj84R9bYhzE2Kiz0rM9fbgHWjTXZdajE5iQ/s 6xHkKWoRhlKYCVZH4pW/GrpFBNgO65pUCrKGRqVIT4dedf7XmZaNREoqK1rqyGBJ ubrPA== 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:27:46 -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.10.y] mm/migrate: set swap entry values of THP tail pages properly. Date: Tue, 5 Mar 2024 11:27:44 -0500 Message-ID: <20240305162744.93431-1-zi.yan@sent.com> X-Mailer: git-send-email 2.43.0 Reply-To: Zi Yan MIME-Version: 1.0 X-Stat-Signature: u89t4yu7rgr6ma7bogb5th4sossbah4j X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 05338140002 X-Rspam-User: X-HE-Tag: 1709656068-740528 X-HE-Meta: U2FsdGVkX199WO6iuKF82rD1zLyT5nuzvOZ3tB+TuiIyjjYyjTvco9OIRKa1wNW2V1xFi+lCt0CHV/h/HnYkliKa0GPwIbjzxeuA6gl8sZdGfcESs+jghmWMasJzop9pGGEmO+L04miGFFr4rvEUFDcm8jNIgNkqyuKJX36w59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wuDRRYRl9u1ypmRx+ZCf3KtWE20j8Yur/rwPJrhtxzQgSKFVgIyEvjjzXuEKYQayIgowRdbfNDlZ1PbfM5avhLMsJj2RfdvnNti+q7mVoht6Fh77G3pHdvRBnkVqPm/lx/bVnzgHExHxYPnHRm4bYY5+s0mNsNd5d9RQVE1PKPuLm8vQUJjVkW4eM/2ISnxt8KJ3U3eWoCsmKOuvKlrVHq6YOLHbPv73jZCZdkxPnAZtpuCh6KBSGVvL2hNkZYfevkwU09a6NYgOkkLw== 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 fcb7eb6a6eca..c0a8f3c9e256 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -447,8 +447,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);