Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2757234lqp; Mon, 25 Mar 2024 08:24:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVtjd/qDuPpUu8c4oGlo87k/lZtEGL2DrE7SnnfOYra3cC7QXmMBq81G6M3up2rIaxyUnAIOftEVtEa1B79olAUWvPNlg8AAU+W9nGJUg== X-Google-Smtp-Source: AGHT+IGroQh6hPh6JxcqGqGACUIRmko7yOLd6VkWu4JYDVmLO+V9YNLcch6bJT94MDQlM0jX5u+j X-Received: by 2002:a17:907:9484:b0:a47:475c:74fa with SMTP id dm4-20020a170907948400b00a47475c74famr4799780ejc.77.1711380294189; Mon, 25 Mar 2024 08:24:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711380294; cv=pass; d=google.com; s=arc-20160816; b=R3cn68ugA6TqMgt3A0VvSlRT2dEjZeXYpcQ7GlRvQpKV2FcS0l54q+3M9AX0Wvs1Ec ufWUegr587EfXo8L7Sfw86d2fD/A/yDClzVMchrxe/VkuQ1xiL5HaGhN3NHwKKYQaZ8E ik01Prjw76zJ2yfRIKVz2DHm2yIovlSdbS61i+enWQmzFiaC9QfkzfbGp1xxs6L/uVzs nWM1ij6Nmei/nE/TqBjeZ1sdbeKfLE4bMfs4Rk5sEnsz2wL3byHLxwByqBy3SS4S/r4z Y16WqrMvTbYTL657o/IE6UZvmGcIRckKqAvhH5gQDeMSkEUhaOKaE1FvanrlSEYZsywh 44Vg== 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=oM/I0IW4sNN1M+mWX3Gj5u2yvEIbpRfkYSEBOg5dRw4=; fh=82Tkto9wLAThGWFPjMOHQAMNM/SHGFFIudThbRSmfJc=; b=xdVAAfE54GQwx8h9ImJbbY5ywFJxkeZ+bV04JBbPsH6JDYtTm4xeBcYDQ0sWP6YIJf V0jo7j+/nKJwGLeeY+QOppDdg9zQ8u7wb3Cr4fMRAeBDo1kbYQwZqei/7CnH2zw710va 1Gbl9kxXUOUmr6D0aAg+YKTknKlGrcQZHV+AizUTfovnUbJZhMaDfAIROqMHO5qoimBM 4S124UJtyTNeKasrJAZcn5LamUpG6L4GNlhBgwS/udhZGKxWrxJaU90niaCAduDc18ym 9ws/80uvZboFwbHNEnnMaIB5SKECPBFV8X04PM7PSeEDfVU38/Xq0zZ+jdG+/5vV1KWO Oz6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LRtPf4r8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117038-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117038-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 bv16-20020a170906b1d000b00a46a9c38af8si2625848ejb.176.2024.03.25.08.24.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 08:24:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117038-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=LRtPf4r8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117038-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117038-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 AEAA51F39F80 for ; Mon, 25 Mar 2024 15:24:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42C4615E7EA; Mon, 25 Mar 2024 12:46:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LRtPf4r8" 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 6E20015E5BC for ; Mon, 25 Mar 2024 12:45:59 +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=1711370759; cv=none; b=BOt3BA06w5wqOFxJSR5J1Z19YgN3EajP67mHKMvfR7rcfZxviv+WdjBohtpsVhgPDV6GMooRNGJ+k0u+JAb9gDSVP7YuLzh1p//EKJZxUD5lJzGMwzknxdJ6ja5a6Y3iLXmE+y0Uy9YZKwXyOrwzG5f5YtkzUgneCrwFp5StVUI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711370759; c=relaxed/simple; bh=use98PRBO/PGh8RpGpv26dYXjrLSdpRJYI2DZcqj2jQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S8Fp7JtUUTfH7xB6/yuqP2KT8sX5qXcBt7STCO3qpVRc2OxDQWl/68HlNxIoRwoSWRAm4GkVviTxdsg9W8xqr7A4Gg2Q5OjHNMh8lBfcwlv7UnK0TkjvtAh3d6i7/UQdV4dqyZF5VUHeQmzQB/I+er04ShtUCYv/bW3K4ovPTFQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LRtPf4r8; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB56AC433F1; Mon, 25 Mar 2024 12:45:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370759; bh=use98PRBO/PGh8RpGpv26dYXjrLSdpRJYI2DZcqj2jQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LRtPf4r8PWZiL5CnScSGqihoUvl5yGGa4RN9z0L/EYdAJg3+6MqePjyIvUpkMx1rw 3Fsdp9liTUlZSC+8d9zCkq4Ngw7NrIclL994hgNJbmp/L+puZisbyUSfZXfOtw+KIR gQFjeo1NO9/gGmslX7z9ky+Yd9OjWbR9pLsVS2suqmxtBS2Kd4tFIgl52/eU999qlH 9MKIs+9iKWxWm2B22UK37n5x5CT9GlBfIPmlycWt+5Lg0h/GXkA33I0DE3DZPOu1+j SXAcDHdBp3ph/rHE5tK/WavJAR82+8zTaPgB+Rr6yrDkvWUuv20zQVqKkuL81nrhpH 0zWOkcXhZePAw== 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, ryncsn@gmail.com Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v3 05/14] mm/ksm: use folio in stable_node_dup Date: Mon, 25 Mar 2024 20:48:52 +0800 Message-ID: <20240325124904.398913-6-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240325124904.398913-1-alexs@kernel.org> References: <20240325124904.398913-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)" Use ksm_get_folio() and 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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index b6ee2bc7646f..aa80fbf3a8e0 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1638,7 +1638,7 @@ static struct page *stable_node_dup(struct ksm_stable_node **_stable_node_dup, { 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; @@ -1663,18 +1663,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 = ksm_get_folio(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) @@ -1682,7 +1682,7 @@ static struct page *stable_node_dup(struct ksm_stable_node **_stable_node_dup, continue; } } - put_page(_tree_page); + folio_put(folio); } if (found) { @@ -1747,7 +1747,7 @@ static struct page *stable_node_dup(struct ksm_stable_node **_stable_node_dup, } *_stable_node_dup = found; - return tree_page; + return &tree_folio->page; } static struct ksm_stable_node *stable_node_dup_any(struct ksm_stable_node *stable_node, -- 2.43.0