Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1350936lqt; Wed, 20 Mar 2024 00:38:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5e1GF08wnKWWWZd+G8+LWQ8qxUJug7FqpuCjxtNqIdoWkfZSrZ/Jv7BYSTKu5Gb7f6SapBw9CZ64eYK45FxGSq9MJFlO0/pCe4QWxrg== X-Google-Smtp-Source: AGHT+IHosXMy8Kr6nZy7z/wau99J/MvpLL5VHGj6Tev8rJKFA554cEed8vXayxS8g6CYB+bCg8bY X-Received: by 2002:a17:902:7807:b0:1e0:2344:e914 with SMTP id p7-20020a170902780700b001e02344e914mr1170152pll.57.1710920309663; Wed, 20 Mar 2024 00:38:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710920309; cv=pass; d=google.com; s=arc-20160816; b=oS2FKFxjsKC2YPq3XRG74QOH3sir+P6DKKMnc6SUN1JRooI+SOurOdIPUPAgWby7dJ aiUw5MMcXD/LwnNm39MVglxNsGy97hQrQ7PGxWM2kxvNB2mrqCiY/KjMhiPszpW3lWEe I6DTKgEbf3DANB76XcqtYCL6TO/qmYO19IiOT0yOuuSkmf8pHI3tXFxN8KcRjrSde2TO phG2pFX7IhvgsR0qknemWqkPgSWJP/BFkIdXFipSYa+Hgjb3/BDwaP2JKrr1ItJBNgh7 m4YcqKqS3NHZI8YdUJnb61Ejag2EEoTv+chK3qcyorGU/V8/g3d6wzjYjYb66CAPNodT 7aBA== 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=7Mms33VJ54sgRp8FnyAenQsmXNJ7i0i74OLC8Z8JYlk=; fh=HTsbfkBy5TsRnyWiG7NOinEtk+/LWD8E51EQEMbLwTM=; b=bGGgV66YCBdBQwO2K/xjFcvHS2hxTVtK9Lvgtqr3DpAZICYYpEbQCr3JNOwCPDSaLb spTtjs0BbcGSvwo7ldStZwaXmGDLOQtFY6XUab7LmjhwUlEg0oa3BUdlXJMLpiITXx8v m00QqrzRjDVio2M5FxJDcnVkh0KS3hhtm54+vVlVnDoNxdrtbp6ujs+mq4cn50N4/gbg hrdt0OVZGaHwpqCckeRH3WzbnJ1xTsQX1y1XpKQUi5YzErQLRN8F9c+YLnLNTrt9gmp+ 60x8nAccRhH/AfbgsHIm5M4b2EyiQzKSBC3fHYEyjFF7hqvksS0URz8oo34A0PhjyKK6 se1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L37WiUcZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-108552-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108552-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. [139.178.88.99]) by mx.google.com with ESMTPS id v5-20020a170903238500b001e0575877e1si1416311plh.347.2024.03.20.00.38.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 00:38:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108552-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L37WiUcZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-108552-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108552-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 1B198283619 for ; Wed, 20 Mar 2024 07:38:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE7282C697; Wed, 20 Mar 2024 07:37:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L37WiUcZ" 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 054EF224D1 for ; Wed, 20 Mar 2024 07:37:46 +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=1710920267; cv=none; b=AdvsuNoXXK9Ggb3GuNUhaAEKScp70B65mTfqbbP/jbRJ8Bm79OrgRi/VzG7wSLWu8rr9NFzlrvHw9vBhVMSN0N+lDO2oIEzYK68OT6lPvrX6napLXHWVLy3M7/SacU6+rW6pTz+DeRjjqZFJZBqXe+nh5PB9Vk8y55AC6/MoZzA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710920267; c=relaxed/simple; bh=QBm6pSuc3VKXpcso3yJosqmwb8/BJ2OoR9I3H0hBrRE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YNeby5+HYcRNTvXJmc2OVLrxjCWQzkFVNMuM6z+TJ/9VUgUXRwTzL6SfmjBGfc0/h8Op2kGOD+Q/PAjlpB0Vw5tPrKlgcf3FtB/R55D7LlZSEHeId5VO52v+51TIuBYLFc6CcuS5NCgR3qIPiDk1jqULe/2miQ0UFjTdeCrfNq8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L37WiUcZ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52E33C433C7; Wed, 20 Mar 2024 07:37:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710920266; bh=QBm6pSuc3VKXpcso3yJosqmwb8/BJ2OoR9I3H0hBrRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L37WiUcZJsGDbOCHOPrSNTjyO0gSDx/iv+H7FACJLgcKsiZeTGrjxxkD+tePXxwzO WU/+a1n3c+tMsi/tk2O8Gzlwg/FAiUawPXh7x/4BAkeKr8YTmc9fE6ielqPWONuj93 Ww0aiZc8FfLVgEa2KjV3ORGARjUO3JItK016YlNbAU6e2v0Dc/fFd8+ab5keQ7xi8S aS9uwYzTy+ZEcrELKJecDguNV5953wDpPrZ+/U6DcP4heEe6vamrHAOEzr8kP02UQt uwZ1NaS2JnE/kpLYI1IEnYWxb+eaRQHQN5SL64g94xDcd63nVvXdoLNlqfqL8bJDhg mrQj1OmnP2LNQ== From: alexs@kernel.org To: Izik Eidus , Matthew Wilcox , Andrea Arcangeli , Hugh Dickins , Chris Wright , kasong@tencent.com, Andrew Morton , linux-mm@kvack.org (open list:MEMORY MANAGEMENT), linux-kernel@vger.kernel.org (open list) Cc: linux-kernel@vger.kernel.org, "Alex Shi (tencent)" Subject: [PATCH 03/11] mm/ksm: use a folio in remove_stable_node Date: Wed, 20 Mar 2024 15:40:39 +0800 Message-ID: <20240320074049.4130552-4-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240320074049.4130552-1-alexs@kernel.org> References: <20240320074049.4130552-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, use folios could save 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 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index 922e33500875..9ea9b5ac44b4 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1107,11 +1107,11 @@ static inline void set_page_stable_node(struct page *page, */ 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 = get_ksm_page(stable_node, GET_KSM_PAGE_LOCK); + if (!folio) { /* * get_ksm_page did remove_node_from_stable_tree itself. */ @@ -1124,22 +1124,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, + * This folio might be in an LRU cache waiting to be freed, * or it might be PageSwapCache (perhaps under writeback), * or it might have been removed from swapcache a moment ago. */ - set_page_stable_node(page, NULL); + set_page_stable_node(&folio->page, 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