Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp206291lqg; Wed, 10 Apr 2024 23:15:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsncQ0LojIfxDIhhYoURJc8aMRQOG++X1ub9TJLV0Ed/LLsnVKo8rMxqZj37z+8puT36wHJz29WUNpwn8o5HaBszMMb7ngEPGG4uwwjw== X-Google-Smtp-Source: AGHT+IE1SCk8pAHFe40I+OhSsVbQWQyUFNLzlrgh1fwoQZS7PMKSy7GjuWlSF6CZ5fOerlieRwmt X-Received: by 2002:a05:6512:31d0:b0:516:a1eb:e6a8 with SMTP id j16-20020a05651231d000b00516a1ebe6a8mr3939411lfe.39.1712816124901; Wed, 10 Apr 2024 23:15:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712816124; cv=pass; d=google.com; s=arc-20160816; b=atpmhvYc8hWELCd8nq6skd/7/IDunYXaEMsR1+BV7N88kQFOE8XTU4IMBDH0ybXkrc LRWoKfSW4FwvLUM51qhk2ZsfEZoii7hWRRjxvUSlszEhtnZRfadWnqqDcS8jzDKqJUVF OCBnOKWuTNGJ0mjyS7f1GyFSvZ9k54S+JqIHvoSGJWPnbpHRRABJgeTthZNvZPZsoBLi uSY7+41XW8imECKJYJY1kFMtD7J7zOo5YZ/F/UKvjRaA+/V51BxQP+/HtLR/bTlItdvp dz8yWHmXoemBuzTe1FhoclhM30VJvQ6LnFde8Mvz8cjDojhFZRFn15od/EDg04oO4djP s5vA== 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=NV2OESMwGKMflyoTHmbwFP2rE14w1PWpBAxrQJN3/8E=; fh=WEMOZDYzhROtJ53Nx6fHy9wYEqwkxnRo6fKhqlB4aEM=; b=h3LTaCt1cbHnYEwRnoHV261JNd126HhCChzepa2xqYF1LBo8iE5P9FmqNLquDyVtoa nOCi8bm/vCNogKznA/5qaATFijjETt1ic22tFwTqUJN9jKHtialCLCBjdYXag26VjRVo qyFJJAdyLMuFVqfzRlTTMkRTW6PhVZQaXIaQjdBngg7eFDsR/hfF5qBuaC3Jg8OFB9hp E1bqPELf5gXJfMAzcBDXLnKI4sGVYCN0ZGs0LmThyk82j0eVB/p+fRqDorfHanp5ClCh eDw5+jFdqSzmKrOjF8FdbRbd9ElVzixoaeI8H80T9+oHYyZYRAdPJls+gQM28iYobnJ1 e8Cw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AtcW68Rk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-139827-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139827-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id nc33-20020a1709071c2100b00a522485223esi180991ejc.782.2024.04.10.23.15.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 23:15:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139827-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AtcW68Rk; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-139827-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139827-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9CA751F25940 for ; Thu, 11 Apr 2024 06:15:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F0B4313D602; Thu, 11 Apr 2024 06:14:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AtcW68Rk" 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 0FB6F13D528 for ; Thu, 11 Apr 2024 06:14:25 +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=1712816066; cv=none; b=nLd12UheKWr8VPoUczTwBMcUKRJ96u9osEJLaKG2l1OKXCX6TekflVsOEl7vxNoxwgutyhX099wHXTxOwhztrbVgydip6/J+5TMjnCf2zyV1Wza/M0PUC5N1MsVyavXuxZsd4Wo3i+5NgLm0QEHZU4GdIUOs5is9yP+jkNUPzRA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712816066; c=relaxed/simple; bh=Psjp2Yi0v76d8BNfvxYBx/0pfRjAkX6bKnyisDETHPQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TW10POnAIT6CUDlZaWq0MU6OAwrTr+vey0oS9SXsMZARX/Avkf3JBxtPcNki+zUEAKQuERGACdcWu6FnXbHNrB6kuGmv8g3x70pYIEvuAVXbn3ouMf1VjUr4CLRMBpmcoixbdzXtazKvBmf4OvMhR6DhZOcdlms0OweawtxikhM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AtcW68Rk; arc=none smtp.client-ip=10.30.226.201 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> 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(). 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; } -- 2.43.0