From patchwork Fri Mar 22 08:36:51 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: 13599730 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 8F466C54E71 for ; Fri, 22 Mar 2024 08:34:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1FB6B6B0095; Fri, 22 Mar 2024 04:34:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 182226B0096; Fri, 22 Mar 2024 04:34:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3C516B0098; Fri, 22 Mar 2024 04:34:45 -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 DBFCB6B0095 for ; Fri, 22 Mar 2024 04:34:45 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 842AC1211A7 for ; Fri, 22 Mar 2024 08:34:45 +0000 (UTC) X-FDA: 81924014130.07.14E6E2F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id ECA9840010 for ; Fri, 22 Mar 2024 08:34:43 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=imVmTgVq; spf=pass (imf01.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 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=1711096484; 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=hPqMQs/fY15AC2cVcg4j/r+MhUxad7KHQi26/px9qXs=; b=fdERHi+EaMJft7mQ/Y9P/3kgU0mrYpma0/0RASjig/pU4f3Ipb26WSe679rOf2a3NsyhJh iiTC0If2gSjxh//b0F8jeEOm8QvRtjNvENCbB1mCXpaTENNSx/OAgh58Lc45PPNWJFOZyu 56zUabaaG0A9hQj912NV1pO40xMArkc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711096484; a=rsa-sha256; cv=none; b=qzuF/GHA6zkzx/jQEg/xhu8VjWbxm49DP8iREJduol/hM5oMVxL7jzfuSYMfi6vriPKcpb mQOL+i3QDWtIyx4cgVUFx8mJKrJ4yQWd7rAytB1Uw+2wAbmTrPhIK/0kF96NUjxJKhqKoF FIXewxwmLSmDsolamUY0cLAihvhOLc4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=imVmTgVq; spf=pass (imf01.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 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 dfw.source.kernel.org (Postfix) with ESMTP id 38D276128D; Fri, 22 Mar 2024 08:34:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5AF0C433F1; Fri, 22 Mar 2024 08:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096482; bh=k8zytA2A5T1rgDUiIACZ6hBdX8Fv5Jcn+9QWsQNKn6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=imVmTgVqlm+AmLk8Z+ZTMWUVNgNEq2BRlwccjhVyXLCB5qbeGmW6fnWIQVCdNlzid 06QraqFqwlS6y3vmnpi4Ap+WlLV/fStE6rPaOVtdHzI8NrNZ42fTJC9XPUrPp6ir+c GV4rj/JQSVNeSlk0ugfN6JCQ1XDjD1pSqTglUpse/EvLUm2T2jWrtq9YXKNEu9fuzn t69uwVBV97Ya9HH95qLpXX8br7iG5co6wHQvXztAm3v6yEEo3yOuQ4k31/8fwPTdEs MBLkSjMg134iZq1KJzMzfVW8NG/QHXg85sUGpSMLwN1pLXyxCrtZ7TX+M/Nl8s3kO0 7Uingur0uvApA== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 04/14] mm/ksm: use folio in remove_stable_node Date: Fri, 22 Mar 2024 16:36:51 +0800 Message-ID: <20240322083703.232364-5-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: hebchrgro66wumwjwjosyhky3fmpzyw4 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: ECA9840010 X-Rspam-User: X-HE-Tag: 1711096483-371528 X-HE-Meta: U2FsdGVkX188T6gAjLRnEQE3x7OpmsYjDy10M8jUbWXi8q2cN4spwnWsd1EeH+2AFKM/bmtkYskr/w8tXMSzFQ3TA0v+2D2jPzXAnCtbs2LIjNth+NiC2TqLqtHF++UVhB2iEyz4bWqSrQKRKmuNetDeYUVAX4sHxm9uVLmbcNlVCbxIqmeFiRbj/45b/WuO4VXK/2f0/mWPdGZ9t79n76udPBtS3ll5XZT8CUgedi8Tz6y80L0YQiqSB5SFIcY5HpAORSt55NpzAoOmwfHmIi52g/bex3LAcg0L8DZKpvazW+q+Rl2oboQKZfnDYgM1a0m0BgQ3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xLM40GoFZzXQ9grqPOAaKaao5mV/FNYsT9ZqDfHf5aapZUf6f8ibIEnx1HnGcsURuljYxK+skAx2wiUEtggPsPzrmBdBfQIDHiXBE4 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(). Signed-off-by: Alex Shi (tencent) Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright --- mm/ksm.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index c9b7c5701f22..b6ee2bc7646f 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1121,11 +1121,11 @@ 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. */ @@ -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 + * 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; }