From patchwork Mon Mar 25 12:48:52 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: 13602021 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 0121ACD11DB for ; Mon, 25 Mar 2024 12:46:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA5BC6B009F; Mon, 25 Mar 2024 08:46:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E07EE6B00A0; Mon, 25 Mar 2024 08:46:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA7316B00A1; Mon, 25 Mar 2024 08:46:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B4A566B009F for ; Mon, 25 Mar 2024 08:46:07 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8BB5C1A0588 for ; Mon, 25 Mar 2024 12:46:07 +0000 (UTC) X-FDA: 81935533974.21.1F93E4A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf10.hostedemail.com (Postfix) with ESMTP id 82613C0003 for ; Mon, 25 Mar 2024 12:46:05 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LRtPf4r8; spf=pass (imf10.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370766; a=rsa-sha256; cv=none; b=rBTrpbWuZFQjxwWB8c0MIkq4kX3sxY/b8KsmQQqZw2qTknfT5fbPvFsOVm8xiAB/Q9+sqG Vwkuwu2oDdGWpWOjCiRiAFIDcdE34FXqtCMNnextCF/WsM41OqLEZWEDO/RaKr5QQZzAGR OkkSxfrg3zEhTaWJL52iL64cgzJf1xA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LRtPf4r8; spf=pass (imf10.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=1711370766; 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=oM/I0IW4sNN1M+mWX3Gj5u2yvEIbpRfkYSEBOg5dRw4=; b=CdOZEIef1doSqlIeVqjAmrpq4eWX6w1RrI2Y/0HfdxyiBudJbhNJgtVeBzBCirDGi2SiB1 8GnxEal20kENcDQyYAo17fPttWUX0dEvdL3H2g5yrgoS01n+mn/NVgUm5iJYYrHyKAdLHx GRTI2GVxL94Mi+a3er6nCaVYC0hGjy0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id CC192CE178F; Mon, 25 Mar 2024 12:45:59 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 82613C0003 X-Stat-Signature: ym4go1fidt1xhycfaky8d6n676e35f11 X-Rspam-User: X-HE-Tag: 1711370765-341683 X-HE-Meta: U2FsdGVkX18rYiyNE7sOnQT3S0RB7SyvpfekOO4TaEC4brp/C0sxkQoGZg5hW4E41mfbUHaeP+x1QWKFGpew+KqAx5900iNbgvnBS1L3hd5kjOdQ4WUmMZUZY6/EqCcbW9ZQLJqJRImWCb+C0hJGHsZmxqg6LdXYpxgEisDU6LM61te9mqK9Hud3aUXQj9N502Qm0G2jHM4jOFypcRfQ82k+whjOP7JiFhgDdk88UzbG1JDR2dMdUBFp6hgtEzmimbwJTw5EgOwbXo08ZAwtNLdTwaCFyYhOdLwEkCxd0ExXAj0WwTZ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/r/ob7D2vDDO7sKqT7mWG0e1FGg0SEsjJyDLgXFanA2JJAIUjYoLIgGGY/aR5SCKzlNNM7bIFbwi2saZbnpv8W7cHBHRKx1OZFTcI168zWQv9hS2/ef1AVIQDghLibykIUGc0GI 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)" 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 --- 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 = NULL, *stable_node = *_stable_node; struct hlist_node *hlist_safe; - struct page *_tree_page, *tree_page = NULL; + struct folio *folio, *tree_folio = NULL; int nr = 0; int found_rmap_hlist_len; @@ -1663,18 +1663,18 @@ static struct page *stable_node_dup(struct ksm_stable_node **_stable_node_dup, * stable_node parameter itself will be freed from * under us if it returns NULL. */ - _tree_page = get_ksm_page(dup, GET_KSM_PAGE_NOLOCK); - if (!_tree_page) + folio = ksm_get_folio(dup, GET_KSM_PAGE_NOLOCK); + if (!folio) continue; nr += 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 = dup; found_rmap_hlist_len = found->rmap_hlist_len; - tree_page = _tree_page; + tree_folio = folio; /* 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); } if (found) { @@ -1747,7 +1747,7 @@ static struct page *stable_node_dup(struct ksm_stable_node **_stable_node_dup, } *_stable_node_dup = found; - return tree_page; + return &tree_folio->page; } static struct ksm_stable_node *stable_node_dup_any(struct ksm_stable_node *stable_node,