From patchwork Thu Apr 11 06:17:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexs@kernel.org X-Patchwork-Id: 13625448 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 A29F5CD128A for ; Thu, 11 Apr 2024 06:14:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B57C6B00A0; Thu, 11 Apr 2024 02:14:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 165BB6B00A1; Thu, 11 Apr 2024 02:14:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 006216B00A2; Thu, 11 Apr 2024 02:14:47 -0400 (EDT) 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 CA9D46B00A0 for ; Thu, 11 Apr 2024 02:14:47 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8B04F80A64 for ; Thu, 11 Apr 2024 06:14:47 +0000 (UTC) X-FDA: 81996237414.09.6201AD0 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf10.hostedemail.com (Postfix) with ESMTP id 87394C0008 for ; Thu, 11 Apr 2024 06:14:45 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=p8rhinow; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712816086; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MFcG4Yr2Hq5moJirQsn9mRkvbvfjJMIc5VQrDCoHTkM=; b=c04NEixCp5rZvmBjcV4FbEcGHs1EHL0PklKvqS/5UTXAhelAebqf0LKbcmEnbxsB0CNjYT L/7LbzKotyrA+Ao8rZlU4LN5Sz8YVSdcYx6MeMCxefuEwhc2oMNfpSCIY7P86uuDfy+R5Y 4cfaMIPg+Hv20Bu6ch6vPrGb5MT3OR4= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=p8rhinow; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712816086; a=rsa-sha256; cv=none; b=t40fyGa7mIgw48YeiW/dEcGuyVp8aKVBpMu5mf5Dhi1oz/khFQDqGVGkYxBIwefwiMvltv VstzOED47qQzrhivp/Sdc3fQInot/2HbgsSWE4pZrjavGCFzgDKRENhPq3F6LCTRZYIc0i YHWcAT7nHN2eQi4Qtx0sb1e3+UN9lHA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id D4D9DCE2EFB; Thu, 11 Apr 2024 06:14:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3C97C433C7; Thu, 11 Apr 2024 06:14:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712816082; bh=2BbBT91rO5EKEsTUfQ1HnSSvv2jhr/Cd5b48tiAufmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p8rhinowpXykMIv8xrZeYQ4/sM/rBmUtzroByI24TOcabbu/AkuHzwOo+wLvLyBpS ei0r0IEsaUt6MiLYL78P4HxgT4D0qn7aVE0oPYB+vS8d+2JgmWR7RC6mVVCbCYkxJS d96sO+9dyG3l6GtE7RAf2pH1a4qCulOXq6jesyBIpnKlqbyvXaujgi2UkUOtJ9tsME 3vjChWTYULjRrUtk/iQvsOXiOwgV8vZobvEoLodOJdwvRydog0NJLVNYYyq2vcvoi2 U4GARspuxshWeFuJK3WhJGdkBjbfZ05BoReePvWFmPG2XqxozAr9Nz/Z39EAWC3ew+ x5SoVAJSv6oPA== From: alexs@kernel.org To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, zik.eidus@ravellosystems.com, willy@infradead.org, aarcange@redhat.com, hughd@google.com, chrisw@sous-sol.org, david@redhat.com Cc: "Alex Shi (tencent)" , Izik Eidus Subject: [PATCH v5 10/10] mm/ksm: replace set_page_stable_node by folio_set_stable_node Date: Thu, 11 Apr 2024 14:17:11 +0800 Message-ID: <20240411061713.1847574-11-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411061713.1847574-1-alexs@kernel.org> References: <20240411061713.1847574-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: y3ofwwbsh46ioffyhqycu1ugbgkbmfzp X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 87394C0008 X-HE-Tag: 1712816085-276326 X-HE-Meta: U2FsdGVkX19Bo0gKpDfcS95TnulUBanxNTwLnSgROUkWectmRZFF4IhpX1KqKEojnYy2wUBvrEmKEaquqq4YdA6O+nJNK2rhM9M6pN/K7Kl8jYaUj1k8Oaedj1WYbFnciYySgi09MC7PKAOjDxrGVKMq7Wj0gYJdd6X1ZHAlCEAn8kBS7lgHcTIt2Dqabskg6wq3I7s4ldiuivqg0Lb1BIKETQQZPr8W9jCpl/tTyNjgM32lcKyN3A7s8hM+NA3raV0bjKt2Y7sytE+Cc2rc75XqrMSX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cnzmXZuqKrmTc+7zkJvY5WDFj+KIPWERkOWaiQlALVoPgf3ZuExM+k7awXIFAMPIA1n0zpGK+Mzd2d8Z9dyzIAyBB68zV2cXXRXmMtu1ltMbgmNJ7U7MZ19JiTWeBPtXUG6Al6PuTr4m0/SD1fGI 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: "Alex Shi (tencent)" Only single page could be reached where we set stable node after write protect, so use folio converted func to replace page's. And remove the unused func set_page_stable_node(). Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright Signed-off-by: Alex Shi (tencent) Reviewed-by: David Hildenbrand --- mm/ksm.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index 662fdaaf3ea3..486c9974f8e2 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1094,17 +1094,11 @@ static inline struct ksm_stable_node *page_stable_node(struct page *page) return folio_stable_node(page_folio(page)); } -static inline void set_page_stable_node(struct page *page, - struct ksm_stable_node *stable_node) -{ - VM_BUG_ON_PAGE(PageAnon(page) && PageAnonExclusive(page), page); - page->mapping = (void *)((unsigned long)stable_node | PAGE_MAPPING_KSM); -} - static inline void folio_set_stable_node(struct folio *folio, struct ksm_stable_node *stable_node) { - set_page_stable_node(&folio->page, stable_node); + VM_WARN_ON_FOLIO(folio_test_anon(folio) && PageAnonExclusive(&folio->page), folio); + folio->mapping = (void *)((unsigned long)stable_node | PAGE_MAPPING_KSM); } #ifdef CONFIG_SYSFS @@ -1519,7 +1513,7 @@ static int try_to_merge_one_page(struct vm_area_struct *vma, * PageAnon+anon_vma to PageKsm+NULL stable_node: * stable_tree_insert() will update stable_node. */ - set_page_stable_node(page, NULL); + folio_set_stable_node(page_folio(page), NULL); mark_page_accessed(page); /* * Page reclaim just frees a clean page with no dirty