Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1856544lqe; Tue, 9 Apr 2024 02:26:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZzk4e+8sK+RKU5unSR9WMIVoUJSAjxis+LFItnbzP2IhYqUL+X21eutg/js+Z2dRQ6yOMsgVKnxvcKi7Ph7Cfe5Zir9s9dlXsDQRptg== X-Google-Smtp-Source: AGHT+IHH7M8z33S8ONsfqIbHuO6y74eeXaxO5rbAnvyRZK1OVXZxoBeEXF+XbYvTRa3/i5NCQM+m X-Received: by 2002:a17:90a:d490:b0:2a2:fec9:1bbd with SMTP id s16-20020a17090ad49000b002a2fec91bbdmr3026868pju.17.1712654793463; Tue, 09 Apr 2024 02:26:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712654793; cv=pass; d=google.com; s=arc-20160816; b=fDhPMT5wPAvwwwOVuyFdSwAOMCAv0Tx9ykxTtiEsoMjF2wYnGwP93I0eCLVB/AKC0T 2OlwrORykPlkAqQ0bud5tXrUpwKWW8WmCL/oidQuJs/8GoUL6rw55Ndr5aEokYwCh40o naLqhLkvOalm3vs/LcKiwpeJji2T95Okh3Ol9kvB556WvuvRanG6+Q/qOEfhyGiDHzJd 0GHd3l9LIYwDLoZLirJXsMF/suwoGbVNVSw5Nl3oUiXTWcCaB7lhtnFFAxjSQ4S1l2fv fNkK3u6sSsl/Y6F7sOmrmM5TyQP//invEQIKzV6dpjb4Q5YVym7b13ZpR8EXyBiqiFLD 7GcQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6QulrtiHM3qMf89NRSaECQx6TgoGBwLTjWk8wB72ft8=; fh=L4VNAxQbQYrcrdeHT1sPO3RlS0TogNvaAEf/71clfA0=; b=shLNVKvDz2G/zd30DSCytvs8VWGf3cyen8t2tTRNakXu1oKG/zKTrf6RzibjUTAIQF 4LhyyNiK/vYh34C2/8vo5b3kozipiYnbTtAviuWBqRHifRvZ2VV5s+Aa1+934QA19SR8 0gBoyt2swcaJuCVs5kmTCh1n+g6mY/tS9l4qy+lPpOPWQpiRfBxCPXowSvs8TAvB57Tb O7uSNhrIcMr4171juA4ykwOrFQXzL9Ek8Z+uVLDlfnzuJxenL7czBahtkcdZnXQZzxvh ck7RUo72jhre60V0sfVZXoEDgn76KrVRt8SkJs2vvfwMY+6XzAzmV7L7YXsYv09QfFBi lKqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p5Bnq1HO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-136557-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136557-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 4-20020a631244000000b005cfbd190e58si7885518pgs.115.2024.04.09.02.26.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 02:26:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136557-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p5Bnq1HO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-136557-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136557-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BBC87284CB0 for ; Tue, 9 Apr 2024 09:26:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A61B84D1C; Tue, 9 Apr 2024 09:25:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p5Bnq1HO" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 586D083CBB for ; Tue, 9 Apr 2024 09:25:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712654725; cv=none; b=iWrVOEdiMbd9MfC1jpxJGTM8mCprsiPyauLT/wSjMLQoNWyXbnqhgL/OGaljgVLiUNa4XvDzyjcqLnOafpeLh9KQkxqsZGzOl5Jl1bTM5+Mi0zEqq5qkve643t7g/P8qGbkyLwwHCMu1Ik6brG3ZrrobjHIwq012zTuNCngBG4E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712654725; c=relaxed/simple; bh=75r9vBcHOLP/QZTkSWPs35KE2gnggcdp1NXQWqEu+94=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kHpXvuBONGIeAAFhHscKf+1UwO5Dollie82mzYnZ7IOIsgb6Uc2tSoUbequREOglSGovOWUHCnTVIi3y13n7EQXFqEnlK6qXCah0nJ1RasMZPrpG25ehmDfoMQ59lTRpJDjvNn4aP8acKYHYOpcZLummpu7yhMtHsWbjwYGAGtI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p5Bnq1HO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 215C9C433F1; Tue, 9 Apr 2024 09:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712654725; bh=75r9vBcHOLP/QZTkSWPs35KE2gnggcdp1NXQWqEu+94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p5Bnq1HOAUtLmDUOgf30B1us3yYOvoqfbsqdgljPW7tCMagB+HFvKmmnfPuHCqaAA WPbEjJPAWmlTdry8oDNy9VfvJlw3qvFvbmUGQul6e8oP+RnraHBE2TakqzFIhvQuIq gphN4ixndTfyy2XxZ/Ih4+dcjLFX157nljTFeGMVlsqBhy/vxZP0XlmVcr8GIPuJKa g7j8plpLvXti8Y8cI7oq9RyAyMvD0AqSfkFNlBH7UdUQtfuiXx2IH96mDn4IDRkCZo dWGzI82T70q/SMpExS+ufP8Za7G3Te0vL34DVbmTxufVb5E77tIJ5+arJk5Z4eqxrd Gymd/Ri0z08AA== From: alexs@kernel.org To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: "Alex Shi (tencent)" , Izik Eidus , Matthew Wilcox , Andrea Arcangeli , Hugh Dickins , Chris Wright , David Hildenbrand Subject: [PATCH v4 4/9] mm/ksm: use folio in remove_stable_node Date: Tue, 9 Apr 2024 17:28:19 +0800 Message-ID: <20240409092826.1733637-5-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240409092826.1733637-1-alexs@kernel.org> References: <20240409092826.1733637-1-alexs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Alex Shi (tencent)" pages in stable tree are all single normal page, so uses ksm_get_folio() and folio_set_stable_node(), also saves 3 calls to compound_head(). Signed-off-by: Alex Shi (tencent) Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright Reviewed-by: David Hildenbrand --- mm/ksm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index c9b7c5701f22..b6ee2bc7646f 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1121,11 +1121,11 @@ static inline void folio_set_stable_node(struct folio *folio, */ static int remove_stable_node(struct ksm_stable_node *stable_node) { - struct page *page; + struct folio *folio; int err; - page = get_ksm_page(stable_node, GET_KSM_PAGE_LOCK); - if (!page) { + folio = ksm_get_folio(stable_node, GET_KSM_PAGE_LOCK); + if (!folio) { /* * get_ksm_page did remove_node_from_stable_tree itself. */ @@ -1138,22 +1138,22 @@ static int remove_stable_node(struct ksm_stable_node *stable_node) * merge_across_nodes/max_page_sharing be switched. */ err = -EBUSY; - if (!page_mapped(page)) { + if (!folio_mapped(folio)) { /* * The stable node did not yet appear stale to get_ksm_page(), - * since that allows for an unmapped ksm page to be recognized + * since that allows for an unmapped ksm folio to be recognized * right up until it is freed; but the node is safe to remove. - * This page might be in an LRU cache waiting to be freed, - * or it might be PageSwapCache (perhaps under writeback), + * This folio might be in an LRU cache waiting to be freed, + * or it might be in the swapcache (perhaps under writeback), * or it might have been removed from swapcache a moment ago. */ - set_page_stable_node(page, NULL); + folio_set_stable_node(folio, NULL); remove_node_from_stable_tree(stable_node); err = 0; } - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); return err; } -- 2.43.0