From nobody Mon Feb 9 12:01:25 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 6E20015E5BC for ; Mon, 25 Mar 2024 12:45:59 +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=1711370759; cv=none; b=BOt3BA06w5wqOFxJSR5J1Z19YgN3EajP67mHKMvfR7rcfZxviv+WdjBohtpsVhgPDV6GMooRNGJ+k0u+JAb9gDSVP7YuLzh1p//EKJZxUD5lJzGMwzknxdJ6ja5a6Y3iLXmE+y0Uy9YZKwXyOrwzG5f5YtkzUgneCrwFp5StVUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370759; c=relaxed/simple; bh=use98PRBO/PGh8RpGpv26dYXjrLSdpRJYI2DZcqj2jQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S8Fp7JtUUTfH7xB6/yuqP2KT8sX5qXcBt7STCO3qpVRc2OxDQWl/68HlNxIoRwoSWRAm4GkVviTxdsg9W8xqr7A4Gg2Q5OjHNMh8lBfcwlv7UnK0TkjvtAh3d6i7/UQdV4dqyZF5VUHeQmzQB/I+er04ShtUCYv/bW3K4ovPTFQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LRtPf4r8; 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="LRtPf4r8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB56AC433F1; Mon, 25 Mar 2024 12:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370759; bh=use98PRBO/PGh8RpGpv26dYXjrLSdpRJYI2DZcqj2jQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LRtPf4r8PWZiL5CnScSGqihoUvl5yGGa4RN9z0L/EYdAJg3+6MqePjyIvUpkMx1rw 3Fsdp9liTUlZSC+8d9zCkq4Ngw7NrIclL994hgNJbmp/L+puZisbyUSfZXfOtw+KIR gQFjeo1NO9/gGmslX7z9ky+Yd9OjWbR9pLsVS2suqmxtBS2Kd4tFIgl52/eU999qlH 9MKIs+9iKWxWm2B22UK37n5x5CT9GlBfIPmlycWt+5Lg0h/GXkA33I0DE3DZPOu1+j SXAcDHdBp3ph/rHE5tK/WavJAR82+8zTaPgB+Rr6yrDkvWUuv20zQVqKkuL81nrhpH 0zWOkcXhZePAw== 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 05/14] mm/ksm: use folio in stable_node_dup Date: Mon, 25 Mar 2024 20:48:52 +0800 Message-ID: <20240325124904.398913-6-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> 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. 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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index b6ee2bc7646f..aa80fbf3a8e0 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 @@ -1663,18 +1663,18 @@ static struct page *stable_node_dup(struct ksm_stab= le_node **_stable_node_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