Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp978805lqp; Fri, 22 Mar 2024 01:35:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUOCO+8LZRRLKT8gbwW5H84N7XDRh9rTrhZqN3pm9Dwp5KX2HsvzOq4d37ZeMbFvC2LJ6cprbq5PLWXOLHU18q1OWEKkSdhetZPgNelsg== X-Google-Smtp-Source: AGHT+IETs6fyoJWVLhuwFGtK0TrHaJ+NNHxdcaep3j3Qg1yLpc/sNPx0KDuTVpkwpIcN7UEETZkl X-Received: by 2002:a05:6a20:9596:b0:1a1:44fe:345b with SMTP id iu22-20020a056a20959600b001a144fe345bmr2258628pzb.22.1711096531837; Fri, 22 Mar 2024 01:35:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711096531; cv=pass; d=google.com; s=arc-20160816; b=m3E4gbnuVpwIdDR5lDpICY4/I8Zwx9HdSBV/3pSvlkTINGgmoFw/7JqyaKnr0Lkdd7 7dv9Vb8b2L/p+3ZHxcKD6Qi7NFqBrwINEzuh4CMrh6TgsWaoSmeDeMLM9vvWCp0L6H/8 KaUG7o7+iDpY04Tx94u05D5G6o0lOMNf3/ib7LWNZ5+jyF0AoJo1v/4xiiqS0neUVVKE x6pMexW8vRTgVm0sxfgz5TNM2ll8ZST3xLwFGdrYniyHipw9mhwPJOWV69Cn88kP6zPl TypB0T4PpkRnYwv+6Yzc8V8PqpbwAzqk52HllaRdAH4+8xEankS4l+c5bgbjA8t9OdA1 DeHA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hPqMQs/fY15AC2cVcg4j/r+MhUxad7KHQi26/px9qXs=; fh=CTFdFrbtP7Z7TCdMbqsgkrQi425Yz+qx6YS+cHHF8Sc=; b=YXWmyhMBkeFvslgca3sUGiqBqLKfNuyl/0zQ9xtWgJ6k+HIIjaeOlaO/8LGNgH/Mr4 35unb0oPfo/1D2TALvzNe/Jy0vgvxk4jtDAX4AuQdn15ABn9IqWA+xqd/mSWCv/E9q5a nqleQTpgLKAUOKF5nM/gCrdyrBkQSDHJ9INTBWxYeL21LCwge4XKcl3L4o9l5R5/GgBu JFMMN/LWb0LfputYhC5WPbVLyGiNgm/IefusTsLmnYgMxmJiJTDE8H5NLIPEo/p/VI91 PlVGDu9rYbbCymoXcqp5/YcQh/IC1k2diK+HXA8xUf+t95oZltDwOmu264weja/OtESI qVZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=imVmTgVq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-111133-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111133-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id mc4-20020a1709032b0400b001dd46c442e4si1568493plb.270.2024.03.22.01.35.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 01:35:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111133-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=imVmTgVq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-111133-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111133-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 84082282E59 for ; Fri, 22 Mar 2024 08:35:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34FEE2869A; Fri, 22 Mar 2024 08:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="imVmTgVq" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F75E249FE for ; Fri, 22 Mar 2024 08:34:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711096483; cv=none; b=Wip+CpcuPqV8s0uqH9Dwy4OymN5o29I8/LLD2RhhZAbOSM8NJl+Lfo1vOTjYK15fQ9yU9OrDRxUPWHv+MwBNqVQmEBjAHNfF95il0cKDCuTZA2ICq09fDTC+J4O6i9aI2PuD3LMQj+UE4wMTszaMDCuoJo+aMMxJeH9xLrinPZg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711096483; c=relaxed/simple; bh=k8zytA2A5T1rgDUiIACZ6hBdX8Fv5Jcn+9QWsQNKn6E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uWJgjO0M6FncJ+jqgzi0jMNTyjNPqJyc0xPV4BN2BTcrIzN9nA6zfMTlNVxCJYY7S7Eptl7af1HPolLzR0DCzv1AUsKs8wAnS1iReU+2ppUgf0OB/HkeRDM8iZJjRWOkTs0aY8V6IGlcajC2GBEl2f4oucbta2UTfzkdHthON3Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=imVmTgVq; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; } -- 2.43.0