From patchwork Mon Mar 25 12:48:51 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: 13602018 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 6C999C54E58 for ; Mon, 25 Mar 2024 12:46:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F19386B009A; Mon, 25 Mar 2024 08:46:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC8B36B009B; Mon, 25 Mar 2024 08:46:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6AF26B009C; Mon, 25 Mar 2024 08:46:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C342F6B009A for ; Mon, 25 Mar 2024 08:46:01 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 98157C066D for ; Mon, 25 Mar 2024 12:46:01 +0000 (UTC) X-FDA: 81935533722.14.29D8DDC Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf01.hostedemail.com (Postfix) with ESMTP id 7EE6A40015 for ; Mon, 25 Mar 2024 12:45:59 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eCXCMsav; spf=pass (imf01.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711370760; 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=hPqMQs/fY15AC2cVcg4j/r+MhUxad7KHQi26/px9qXs=; b=arID4MHzfkt54hN52Hn7weYsNa1qmLCaZPCJCZ7QBcdKKraPaG4p4DQNYYn+cyPfDDyBcd 25I4oEL6LF3HHTISImLL7M1s2riCbG+ct5x3CxtB2/x/hk+bvJs70bzPJwxCo8xkG/ED+K OSX9ut33xSSQlqGkezkfp4RbklGahvg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370760; a=rsa-sha256; cv=none; b=4RzquXhSoj8g+NRTffSVtbiHxT4MFj3mjEXrRVl0to7ceAKezPYuGEVbpYE3Sxu6Oz7IWB guE7lwkXy5+81LN84j6QAFkGTvIRXlcashjHh1fpZXUZLf+XqEdMQyyFdBbuG9LOQy5U2L D84w+RZB1ALIYaesPmxmpcc5bDfB2Uo= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eCXCMsav; spf=pass (imf01.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id DE28BCE1777; Mon, 25 Mar 2024 12:45:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9649C433A6; Mon, 25 Mar 2024 12:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370756; bh=k8zytA2A5T1rgDUiIACZ6hBdX8Fv5Jcn+9QWsQNKn6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eCXCMsavhNOpAhZ7kJ53WdZwQKpuR2F7J0ZTZC1rzgutAlE5WiOGa7PrxTMOnMARa JfPhPX9LQJiY8vbNiLiDBSY6pLZYbUANi5Je+jK5qa/nFXX8ERQS33vHjuNT83yyfT 2KMDNRZMHC5XZLJy4fUp8FjLNBwJsWRLvM+MebUe2K1BC+RHZCpaZiKwO6xFuGXiqW JZeggEJVwxFI1pFShlUUjpQTX4BZNY7UDVuzH6arWZhTGgCsUftr2vbwZUvooZ2RvS unmUy6JT9yoDSORyeY3EJoi02k2S0QsMfzHfpptaoaMcaebfat8W39e3t33np53eYi qMyO3pObODdMw== From: alexs@kernel.org To: Matthew Wilcox , Andrea Arcangeli , Izik Eidus , david@redhat.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, ryncsn@gmail.com Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v3 04/14] mm/ksm: use folio in remove_stable_node Date: Mon, 25 Mar 2024 20:48:51 +0800 Message-ID: <20240325124904.398913-5-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240325124904.398913-1-alexs@kernel.org> References: <20240325124904.398913-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 64mwxezwn3uh3s5ixa8iui5ma38hmnbr X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 7EE6A40015 X-Rspam-User: X-HE-Tag: 1711370759-519720 X-HE-Meta: U2FsdGVkX18SqqMBWFf/oA18sVGP1jD/eDvdjUyqDUE9R39qpEMZEG5iFbj26C7D3gV4jemMmWsMVopu+gNNbY1MNghoFmFdKkVf2Ehcwv6MuKxUrujfBzOfWxO152qwuPQG6wbAYtm9dAX3BKtJGTrYq7l/cRxtz0kNBHefvRjgyNstvdyhdlCUpXgFKyRxX8mRW1DjQjfARNdaAhKS+sK7KNBZsy5GOc5D0MrJGYWd2ASFz9IfTuJkFgSzRyNtix7C80v6LlnA1vn/mrEZeicwrBSxXDFRKePo3t2y05VIcZCRKmEGorLiyxkwAtWuGJuTLzgh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d1SBRJU7ym77hLfIjGLaD2JFbaQh/lGX8DAktvWeRvnRTNy5PolprLwuy+WwUJbP5vjOoy5fGI/1GZ4PVTchPmbX7GR 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)" 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 --- 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; }