From patchwork Thu Apr 11 06:17:05 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: 13625442 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 55E87CD1292 for ; Thu, 11 Apr 2024 06:14:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9B596B0092; Thu, 11 Apr 2024 02:14:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CFBE96B0095; Thu, 11 Apr 2024 02:14:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B756B6B0096; Thu, 11 Apr 2024 02:14:31 -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 993E66B0092 for ; Thu, 11 Apr 2024 02:14:31 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2225CA0A93 for ; Thu, 11 Apr 2024 06:14:31 +0000 (UTC) X-FDA: 81996236742.25.5D88066 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf09.hostedemail.com (Postfix) with ESMTP id 13E6114001A for ; Thu, 11 Apr 2024 06:14:28 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=AtcW68Rk; spf=pass (imf09.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=1712816069; 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=NV2OESMwGKMflyoTHmbwFP2rE14w1PWpBAxrQJN3/8E=; b=g5Y097DRHM0Yj5XPpq6vh+bt0BnoBavuDJwkIi4l9FanlxWTObqTcBnLinvHZCqRO/950t anBsQWROpiizvRtHD8VMXaYKiabeeYwrF2HDmNtXp+vtWGehaAUFC97nJPgJw6zv6GXpMy kPn51yYJnipncYHDXvfQoy27xNyurn0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712816069; a=rsa-sha256; cv=none; b=ZjpdvYZEcDudzcmmYPDg5uWBhBLJoTqeii95jyCudbD9R9pCzsenH5/aSQh0NF8/q5tKYL z30ZCxfC/GNUh45HnEWFmfJJ94Ri5UCcm/c4usLfiZNtvo9wGrgnPsxExUI+HBkmxqBAQ8 vGEj2rp9Dv5GKcyKqYOlpEbOz7n0lYI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=AtcW68Rk; spf=pass (imf09.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 04938CE2F14; Thu, 11 Apr 2024 06:14:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 740FCC43394; Thu, 11 Apr 2024 06:14:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712816065; bh=Psjp2Yi0v76d8BNfvxYBx/0pfRjAkX6bKnyisDETHPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AtcW68Rk2WAP6ax3CbHdN4r9JSIXDouQiaVp9hG8moEE+5MKD9ffWBUO5Tn/KJyGa NfMqOSI1Kg9SLWaCAt4mINhEpg8uA7V7AKNHrWSJYnO/ytFtlTDCyhvBN+CTNRELWd 0W7pOuXj7+4Qz1Yrt9MI3dBZ++m5FTGRNZwXgaBy7O6ENdkgvPdaLIokjOEX0Y1vEg sbXCZW8tv+k9RUzc3/1RDiZxV2ZLzjVu1im7P69RmdYadEdObhiNkPKUKPxbdSRiXH GTO+PjJ/hF0piGutbC7coJxsH5pq0KB1O1RE/qRF9ayCTCpxB/q5W/pf8Klp/KRFgE rF3mDjkj6WvAg== 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 04/10] mm/ksm: use folio in remove_stable_node Date: Thu, 11 Apr 2024 14:17:05 +0800 Message-ID: <20240411061713.1847574-5-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> MIME-Version: 1.0 X-Rspamd-Queue-Id: 13E6114001A X-Rspam-User: X-Stat-Signature: u3ipbbu56o568n9jcgfut8qbwoggfdzw X-Rspamd-Server: rspam03 X-HE-Tag: 1712816068-704950 X-HE-Meta: U2FsdGVkX1+RbdH0Pn3ZHgDuaKyd+nz/So9VUkIdS2TGQxDXeKXl8m7Sm+GMYa59vJEM0aEyOh4nBSUJGrx8lC+p02oQYCM+MCrZyeWIIFQFXolrG73uRSAllNe16NHpEqElATxh26+VI/5o5ChkMLbdVJRMJ+DHnzenuH+rBUOwI56LJWbaJ2DocxMdBi8PEieq+P9DdZ3Vwb8aG47s/m5Nb+uvZn9MiNe96C7dnRv289LLNlwXoytOpfEAZJ6EmetZU0VSvpj7ArTKbdxkp6iPQxO8WPOTTM8KvtN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fGrjOaJNWaYcvSSsIMM5lKahn0D0aqx9cfRMrYbZyQCCHDJowAbKmoE+Bfxi/NXUAibONfGvdcrzI30+GKhfNzCKWPD1svPhg15Sps9AR1G5THAwEcI8YoBM/9Q3G/J4C8WuG7sssm6 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)" pages in stable tree are all single normal page, so uses ksm_get_folio() and folio_set_stable_node(), also saves 3 calls to compound_head(). 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 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index 3c52bf9df84c..1a7b13004589 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1121,13 +1121,13 @@ static inline void folio_set_stable_node(struct folio *folio, */ static int remove_stable_node(struct ksm_stable_node *stable_node) { - struct page *page; + struct folio *folio; int err; - page = get_ksm_page(stable_node, GET_KSM_PAGE_LOCK); - if (!page) { + folio = ksm_get_folio(stable_node, GET_KSM_PAGE_LOCK); + if (!folio) { /* - * get_ksm_page did remove_node_from_stable_tree itself. + * ksm_get_folio did remove_node_from_stable_tree itself. */ return 0; } @@ -1138,22 +1138,22 @@ static int remove_stable_node(struct ksm_stable_node *stable_node) * merge_across_nodes/max_page_sharing be switched. */ err = -EBUSY; - if (!page_mapped(page)) { + if (!folio_mapped(folio)) { /* - * The stable node did not yet appear stale to get_ksm_page(), - * since that allows for an unmapped ksm page to be recognized + * The stable node did not yet appear stale to ksm_get_folio(), + * since that allows for an unmapped ksm folio to be recognized * right up until it is freed; but the node is safe to remove. - * This page might be in an LRU cache waiting to be freed, - * or it might be PageSwapCache (perhaps under writeback), + * This folio might be in an LRU cache waiting to be freed, + * or it might be in the swapcache (perhaps under writeback), * or it might have been removed from swapcache a moment ago. */ - set_page_stable_node(page, NULL); + folio_set_stable_node(folio, NULL); remove_node_from_stable_tree(stable_node); err = 0; } - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); return err; }