From nobody Sat Feb 7 08:02:28 2026 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 B1AB013CAA0 for ; Thu, 11 Apr 2024 06:14:28 +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=1712816068; cv=none; b=ocHqgeDeQJ9cymuDRgx+wbvyApcsRWZaBW5ngOc8rMcvFR3C22wZhhTii/2CrVMaOWtn5HBYV15M1ab813eUIlgX81zX/nuGoaBD7qY7kPXfZUK/gpCw8CiM0aBM0Sd3IJvdfuMbu26IlvOG2UvAa/6QQx2ano2ut+TL7bp+jZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712816068; c=relaxed/simple; bh=6Rigut9B0xei0o3RlU/2pvsNtNjz8VS58APxTOkaTzQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G/BRm5P/+RiH0zOJdf4rAsnOuucPUC3ViSkupaWNL1NovQpe5OsPv3fLFVP8uxojXFTQ8Ug9FV3aAuyfYxgkmyKgBZ6iQqEdFol8KNnjlApubA7b+zKOTFzSJsWc6RwQge3UhpQaSTFMFnq+P2R6gwCaJavbJaaGP2xU2eGiFiw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ohkAORx1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ohkAORx1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37F82C433B2; Thu, 11 Apr 2024 06:14:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712816068; bh=6Rigut9B0xei0o3RlU/2pvsNtNjz8VS58APxTOkaTzQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ohkAORx1XDD/r3zGvplob2RLchLHYpJtenMlCbrLa21NNHXYHsSFleenl2QJvPwDO BmJobQMM8/tiaJ2dc6Xqc1+pTXwNBj4/zO06Eeu4LRUemG65+A9n/DP1SoCXG6914z vmmFfjvM6AxZfKRbJh6c/IeVBz7S8/GXndViQaqA1DdKxNizoD+AfChC+db9N5Bnp9 7vRT2PZBknD6b550bTqQ9oSG/8iTN94euob/LzgnwW4VPDEHbwNrSjRjnWDXIqu14t sx0a9yK+5/uUZG1uXV0Si3q76gnQPcXFHtNdkX+DnqoIGAZzLazQIpwpJpOYxe4ryU EYYNzK4nJSBNA== 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 05/10] mm/ksm: use folio in stable_node_dup Date: Thu, 11 Apr 2024 14:17:06 +0800 Message-ID: <20240411061713.1847574-6-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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Alex Shi (tencent)" Use ksm_get_folio() and save 2 compound_head calls. 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 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index 1a7b13004589..654400f993fc 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1638,7 +1638,7 @@ static struct page *stable_node_dup(struct ksm_stable= _node **_stable_node_dup, { struct ksm_stable_node *dup, *found =3D NULL, *stable_node =3D *_stable_n= ode; struct hlist_node *hlist_safe; - struct page *_tree_page, *tree_page =3D NULL; + struct folio *folio, *tree_folio =3D NULL; int nr =3D 0; int found_rmap_hlist_len; =20 @@ -1657,24 +1657,24 @@ static struct page *stable_node_dup(struct ksm_stab= le_node **_stable_node_dup, * We must walk all stable_node_dup to prune the stale * stable nodes during lookup. * - * get_ksm_page can drop the nodes from the + * ksm_get_folio can drop the nodes from the * stable_node->hlist if they point to freed pages * (that's why we do a _safe walk). The "dup" * stable_node parameter itself will be freed from * under us if it returns NULL. */ - _tree_page =3D get_ksm_page(dup, GET_KSM_PAGE_NOLOCK); - if (!_tree_page) + folio =3D ksm_get_folio(dup, GET_KSM_PAGE_NOLOCK); + if (!folio) continue; nr +=3D 1; if (is_page_sharing_candidate(dup)) { if (!found || dup->rmap_hlist_len > found_rmap_hlist_len) { if (found) - put_page(tree_page); + folio_put(tree_folio); found =3D dup; found_rmap_hlist_len =3D found->rmap_hlist_len; - tree_page =3D _tree_page; + tree_folio =3D folio; =20 /* skip put_page for found dup */ if (!prune_stale_stable_nodes) @@ -1682,7 +1682,7 @@ static struct page *stable_node_dup(struct ksm_stable= _node **_stable_node_dup, continue; } } - put_page(_tree_page); + folio_put(folio); } =20 if (found) { @@ -1747,7 +1747,7 @@ static struct page *stable_node_dup(struct ksm_stable= _node **_stable_node_dup, } =20 *_stable_node_dup =3D found; - return tree_page; + return &tree_folio->page; } =20 static struct ksm_stable_node *stable_node_dup_any(struct ksm_stable_node = *stable_node, --=20 2.43.0