From patchwork Tue Apr 9 09:28:20 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: 13622063 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 C2EDCCD1284 for ; Tue, 9 Apr 2024 09:25:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41C866B009B; Tue, 9 Apr 2024 05:25:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 377F76B009D; Tue, 9 Apr 2024 05:25:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 155676B009C; Tue, 9 Apr 2024 05:25:31 -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 DE2FE6B0099 for ; Tue, 9 Apr 2024 05:25:30 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A9577402D2 for ; Tue, 9 Apr 2024 09:25:30 +0000 (UTC) X-FDA: 81989460420.09.F4FFA07 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 1037616000D for ; Tue, 9 Apr 2024 09:25:28 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="K/9py+Ni"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712654729; 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=IbRO76iTSzroHX7fl9UkQl3yuoVMKDt79AtbotqUFNU=; b=QavtyyLCckZYO/TbN/Dm1KFeBgEH2iYJIiu8EZrR740HBIzPaxtYQbuagkQK2q2SA98oX0 geaVkAXkW+CxjvtxdQWAsHGnuIK6NQq5CSMYOFdVWntUFyjGkFr0kOE79ecR5Dfp0PJ4kG logNuOTAw5JnG1lH1EmQUYo6xxoNUUQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="K/9py+Ni"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712654729; a=rsa-sha256; cv=none; b=rghqukqehBUsi0OtdheNGV4zPbQP7JoMSZ52x2rZDAZZU8zKyeth9qHD/aHsLK3+NurY5o DMUBAz8MyI9W9bA3mCHoQe2+ixffsAzHyae68InzzhhUB3J6qfGTEelAsAGLxu3NBXM2E9 eQ1a1dq9o50WArk1WWJ0cZEc4zVvG7Y= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 29F0261684; Tue, 9 Apr 2024 09:25:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD7A1C433B1; Tue, 9 Apr 2024 09:25:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712654727; bh=ZY9sin7F1FOM2/QeBR1n457pb/jjou4lTyaBx1XPflg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K/9py+NidPXCVPUMGd0kufG/y63MT2AfemIKhalAx4FloWPEwHbZK2/NodbgYlfam zo+IBb/3dmx60VAHPosB7YEpJzjE4f6byWsF3cqBNDQTCYzHNlz1HVqKnDT2HCh1lK cUy1Qp/Nk+bw0qgcno/YuSUreXEUWW5SOgssY+aVr+ovZlF1o6DrO62VsIqPaDSqIL ttYkVNFKBA5orHBOuPQ5xlqvdb3bamLKbDz+es7APokW2gfKAb7pAAom0ncqZU5hyo ppGJR9OmDqADNk7NeIrzMkHFXmhTBU3CmUQdRp16HYybhutxFGJOQXHy2+KNamaACi QX7pHZuJY4FPg== 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 5/9] mm/ksm: use folio in stable_node_dup Date: Tue, 9 Apr 2024 17:28:20 +0800 Message-ID: <20240409092826.1733637-6-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> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: yc8p19c8opumjoxfc3ugr4me15ech73s X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1037616000D X-HE-Tag: 1712654728-516354 X-HE-Meta: U2FsdGVkX1+NyPDgA2RMiUjn5VOYayZQX5H5zUfTdlwhahC0Fd8xmql4sIW8wqjDirpdRHfYsL64L4zhqj4lzIu6cipDzr28gZfQaKFMuT4oqcvr9DElg35Zp/gqgzLQQYykgYDTEdInU/LxxaHVEte6aOaOXUtTuZrqP7X66BtJENSvucLnm5tz7ce2BE4zMdW5ygBgtz/F9wiLfzMzdngmWEIXrT2GUSJ+fOdTKRdxrRw70Rac+0Et1TRckEQYwiFJ8MXj4CLViF56rSRSblZiyPEU4jiguzmBq2+DL4hcF1QtBjgh6qsSDeXMAFCwwi6nYfHJ+d4KOBliziimz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xQcKjZdLoKO3NruQXA1IMidioaQ/KR5/PJfBNtr5imT643HjW1ACX/0l1G1er1q4BKhXwXp+m 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 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 = 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,