From patchwork Wed Mar 20 07:40:39 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: 13597417 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 9A0D1C54E58 for ; Wed, 20 Mar 2024 07:37:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D6CC6B0098; Wed, 20 Mar 2024 03:37:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 284DA6B0099; Wed, 20 Mar 2024 03:37:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 174E16B009A; Wed, 20 Mar 2024 03:37:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 07B0E6B0098 for ; Wed, 20 Mar 2024 03:37:53 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9BDC980937 for ; Wed, 20 Mar 2024 07:37:52 +0000 (UTC) X-FDA: 81916613184.20.E360D5E Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf19.hostedemail.com (Postfix) with ESMTP id 83AB91A0008 for ; Wed, 20 Mar 2024 07:37:50 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=L37WiUcZ; spf=pass (imf19.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1710920271; 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=7Mms33VJ54sgRp8FnyAenQsmXNJ7i0i74OLC8Z8JYlk=; b=4TU2LPoQtvgUBEWyWIy5f6SbkK+WaSR9UhnuGtKXR7gAebbUxJYgj96bRUSrZM61ploYj9 ENsdl/xK99YLvWxOV9yIqzlZbHP1rfApo4HyHrHtnCHtz3XQlkq1+T9bPJC0vwafaNjJL+ XnNeUfZJ2zax4lrxWgAk8CgD2PfrIjg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710920271; a=rsa-sha256; cv=none; b=cw+TKTCXYt5BNxcqMJoau/eg+PsLD/2+xZMmiqPF4jA5NiQrg8al8yBi+IPUNFSvVGag9l Z3OM9fDTdbD3ZSENDrJKnLg2jWxRst2IfIIFQsth9IMv0ri49jZRaWeB3VcztcULxUqWFx qJ4rZu1jroSuuAQ2P2f7wCpyfq50ocQ= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=L37WiUcZ; spf=pass (imf19.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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 sin.source.kernel.org (Postfix) with ESMTP id 09FD0CE10A3; Wed, 20 Mar 2024 07:37:47 +0000 (UTC) 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> MIME-Version: 1.0 X-Stat-Signature: stuibykojabebcyi9doqrsi84w7tso6k X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 83AB91A0008 X-Rspam-User: X-HE-Tag: 1710920270-168445 X-HE-Meta: U2FsdGVkX19THJ/8VF29ZAI60E7eUcdwsQFPsGUioS/ntSYtckIXRAfxmW2yKgpeGN9WIa93+0u7l7CGHJwyPadAK2+3QQLY/+HqyJrXKZxbL19IuBU+m0MwBNfCfqR4LcNclL6bNyP+IQDQfOUJpMHOGAQ2nVz3L6kT5w5Qty+ZNa8qWyqPhrQVTYSy59yXdA04G1MrFFGJFBHiW16N2VHsVFTE0QpKAfXuiY1eFR82gAsZzvGyoz+D5tXOb053A6rAQCAPBDJi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UkGPfj7uHpEDJGyqMZg6gD9ueX3A8bppvdMK3Kk6nB6EJbmJ12rpNWkHwn50nqt2Z3TJfUD5DhlBFe2ZUiVkIV5nlcYCfRvxb/0c4cB8XvQqRn56zFq4uWCJsK3+ZgpRJQuxu3KA00iUSkxg7u5kJ9GpMcmexCEKQGjU8C1YsOyUPpxBtEQn 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, 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; }