From patchwork Wed Mar 20 07:40:40 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: 13597418 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 70E2BC54E67 for ; Wed, 20 Mar 2024 07:37:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E21516B009A; Wed, 20 Mar 2024 03:37:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DAB276B009B; Wed, 20 Mar 2024 03:37:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAEEF6B009C; Wed, 20 Mar 2024 03:37:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9C65C6B009A for ; Wed, 20 Mar 2024 03:37:55 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6A00D40AB8 for ; Wed, 20 Mar 2024 07:37:55 +0000 (UTC) X-FDA: 81916613310.05.4ED9068 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf26.hostedemail.com (Postfix) with ESMTP id 27E1E14000D for ; Wed, 20 Mar 2024 07:37:52 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YI8Hv6Xm; spf=pass (imf26.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=1710920273; 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=0FazGL3FuTt1mcjMwnjMXTdVvVz5+26grHrof5VpqTc=; b=n+qOMP0u6Ou+ibDIWHBrVxOp52A+P1+o3dfE7aSR84ZPB89oiM6Td7pPzdPqxdlYY11L9t ya6Kkl0nO+8+B228SpSSh6GEdHd2p+11oC0Y9mTic0JmMP32ketILEHOc4adT/1Bw1s7TC 2biJEu9Z7RUhEJWseUiGp8iuHppGwyM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710920273; a=rsa-sha256; cv=none; b=Rlu5ojarNk7+YQjnWJEiTiYkEr1VC5VMYM8ePkZSESRNMeHRZlVCjTVa2SPwWL5SJgY3VV jZHeYvNPHFiQFz2kDbTOTGI/zM2Dw3nuSMC4gAKI+WaujRTdG5F/drfLB/X8Zy0BidW3eF vbHcvd5KGx7J3gpRccyR+Mkf3jQYrQ0= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YI8Hv6Xm; spf=pass (imf26.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 31611CE1098; Wed, 20 Mar 2024 07:37:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5001CC43394; Wed, 20 Mar 2024 07:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710920269; bh=o9GRn+UUdxaobJAptmjj5VgVz5sUBp61iu84lZ36vgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YI8Hv6Xm0jtVWQtKp1cEyat0wmWHkY/j8Kn9DULx7rBhfbctCAntP1sNzBbd/Bgxf GKK43+qd3J6n4vPv1LSUBWx7F0jGccn4GAjoLM7vsPEws0j8wqHcpLDkSqObqPUuVx S00afiEWDkzZAspltpRvm6n9CzWLkZZD+sF6Yv437TNRj14g+lzb+lT9VmbZKVVdi0 S0FJt5H5PXEH4w1WFjdRasWZANKxZgTMKd0TGJwcL18EO4qG0Z+afEB0r2hCI/K5mL QKchWwWwSDnOFXDVHupER88Io9H7AnuzjlMcmemfsbxURM5CC2DJV+0FmKEL2WDgAX 1i5wfHTNMdfWA== From: alexs@kernel.org To: Izik Eidus , Matthew Wilcox , Andrea Arcangeli , Hugh Dickins , Chris Wright , kasong@tencent.com, Andrew Morton , linux-mm@kvack.org (open list:MEMORY MANAGEMENT), linux-kernel@vger.kernel.org (open list) Cc: linux-kernel@vger.kernel.org, "Alex Shi (tencent)" Subject: [PATCH 04/11] mm/ksm: use folio in stable_node_dup Date: Wed, 20 Mar 2024 15:40:40 +0800 Message-ID: <20240320074049.4130552-5-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240320074049.4130552-1-alexs@kernel.org> References: <20240320074049.4130552-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 27E1E14000D X-Rspam-User: X-Stat-Signature: itgxsi3ybwii71jux79i1xbcqsrdwgja X-Rspamd-Server: rspam03 X-HE-Tag: 1710920272-307861 X-HE-Meta: U2FsdGVkX1+ldZdpgUuXufreCUFaQPRPayOVneqcbthtVl7DoMUswgxyF3gxFXilGvT81GD0w9JmoGgfiz0C3g1lFPw6sLUSXUesZp4K3whZWzQ4JHfIJmbkA1QJoC+py7sv0i3kAwDND4esDWwGn5bvAKrnyufvwQK6gRg782weH4gEkrBFVK7ODFZR2nYTJ40B7lQlWeQaKvLVZolUbKNyh6mYbFFLEF8vsy9YmMah7tsVBBRgx/w4apCrrVoYuDytd4iPOSZVC5lJh4TkSlA7tYxZP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rRZisSOMzhj1FlJh9gYIVxf7muR3LEbLFQjTejE1jPXWV13MThejklrzYeZgfZauvZTKZ+XfdTYBBfA+QbGm7ebo2OPvvEgf2jfHkjBjRqZkg2cMjvEMRWDZgQd1ue9lgMbsbJ4e 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)" 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 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index 9ea9b5ac44b4..f57817ef75bf 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1617,14 +1617,14 @@ bool is_page_sharing_candidate(struct ksm_stable_node *stable_node) return __is_page_sharing_candidate(stable_node, 0); } -static struct page *stable_node_dup(struct ksm_stable_node **_stable_node_dup, - struct ksm_stable_node **_stable_node, - struct rb_root *root, - bool prune_stale_stable_nodes) +static void *stable_node_dup(struct ksm_stable_node **_stable_node_dup, + struct ksm_stable_node **_stable_node, + struct rb_root *root, + bool prune_stale_stable_nodes) { 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; @@ -1649,18 +1649,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 = get_ksm_page(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) @@ -1668,7 +1668,7 @@ static struct page *stable_node_dup(struct ksm_stable_node **_stable_node_dup, continue; } } - put_page(_tree_page); + folio_put(folio); } if (found) { @@ -1733,7 +1733,7 @@ static struct page *stable_node_dup(struct ksm_stable_node **_stable_node_dup, } *_stable_node_dup = found; - return tree_page; + return tree_folio; } static struct ksm_stable_node *stable_node_dup_any(struct ksm_stable_node *stable_node,