From patchwork Mon Mar 25 12:48:48 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: 13602016 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 1ED4FC54E64 for ; Mon, 25 Mar 2024 12:45:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A37706B0095; Mon, 25 Mar 2024 08:45:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E8C86B0096; Mon, 25 Mar 2024 08:45:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 888916B0098; Mon, 25 Mar 2024 08:45:50 -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 763B66B0095 for ; Mon, 25 Mar 2024 08:45:50 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2824C160173 for ; Mon, 25 Mar 2024 12:45:50 +0000 (UTC) X-FDA: 81935533260.25.EBB6692 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id 9DB7040010 for ; Mon, 25 Mar 2024 12:45:48 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nqD8rAwq; spf=pass (imf04.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 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=1711370748; 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=j5O9mkfNcbBoqVBmXr9pW1yRb70AyJM+UXLoLRkPGFM=; b=322wKu9XdyiV3wk/jqkrIxoz/icHhIRP3WNHv4KksOD2uy+r1RVj59qbpNQOyiP4B/6XUi 6LnFlnODR4LQUxTkxTn/pyfRIzlt2OvpaMo0bZrufmSj4RehUhcy+vilBjeZH8WeLJMWI8 /N5QaQE635O+Cz98rPd0UIyF9WSIK0w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370748; a=rsa-sha256; cv=none; b=ifjqSEXqrdPhgDAkFp2lv68560QpDJ/fi6U6wGfPMuHCOPiib/GkmBzK6xlnwr8H74CFDf c16F8WVBz/jBW52gVCeAXDmPJ4VKJTWCXmiezmuYxl/1T2vLg9S1wHKy1B7ryGnmTFAHh8 HVEh5SZU3DBW9o5gQ9c23aUFBILz79c= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nqD8rAwq; spf=pass (imf04.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 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 dfw.source.kernel.org (Postfix) with ESMTP id E24CD60FA2; Mon, 25 Mar 2024 12:45:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4269BC43394; Mon, 25 Mar 2024 12:45:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370747; bh=QDhgdKPLSZ+LCN9CDxfi2X7NfAWh6m7wtgm+INCh864=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nqD8rAwqqd1rZlggHYvDueBQdTe6WYxAdUuXriWjNgenrTHHVxgd7GnHtwUzXPlhH Euyl3J3vJqwRgkj3fMPW6SSRO52ygC73Q37XEga85/ltaHFKcyi6/C2rE8khfLB5PY bxE3SiDge/MfBeeZCQnSRaw+A7+4HaJJVcT/0uxumAh0+nAx5acDnUKKC4zVEo1HSD 9RBSBXjM3odN+trHUYLuYZ2raubRH4AfZKu7VHIhfapDctVyDJdBckiKsEpDWGh90q aPKP7sDOtjUpNAHzVOTGKEQnQnT3FK+ONVRVirrIwynhumCYaAlKkfN748A6RM0AbW pKbYUkce4rmmg== 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 01/14] mm/ksm: add ksm_get_folio Date: Mon, 25 Mar 2024 20:48:48 +0800 Message-ID: <20240325124904.398913-2-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> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9DB7040010 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: gi63ir7wtfk45ufmnf4pf9ens7jn5wtm X-HE-Tag: 1711370748-20133 X-HE-Meta: U2FsdGVkX1/aHASeTRb+r6LwD1xYXaqu7p4TPrr8Mw6YBhxZ2EudFYjm6L+VGSjo5SBQvFETHz8gyEoZ5u69aqqwvW0myZ/ixHfUbZtP7d+hNEqoJntGJGq3rlPB53jH2zf8/gYNL52z1R20ipAcspRDzeyGowzwYDRTf/8926uSUYrp6kIj+bGoyq92f/U+vuK4fdcCkmVtV6AhM8puKVsjzoMsvP5E66PmLv5iwvbzqKC8r1UmPxSClPx+40yXkBxhQSdDMZZq59bNAG9knksDmjW3jDwN4mXj0zL1TraPfRKQs0C3qF+dTx9b0EMBgnEA2Ty8EFVyFgcjEY0lzYLTVecpwDnxqYkpg21GjnOfIK550xDVOammuOe8uYPUdkdB3eq2wC/Lg3Cx/Z3uc+QjbL6ZSbns7SOn2CtcX5W+322jrB8vK5RDmB1mhsb3h34vtKeYxLP3w4GMOIn5xxHxvobFLqK/kpzy63IlkhBT7HvarnxuiMaqIbjiUJPIEmxnEpH0nCRzxSIoUFTljJzU8siLYYQ0Wej3CPml2CIHSjtNHjcmuuKHAKGJCoFK53VH1pKOM0EEE7eT8XmkDYronuoO21G/MqkXASS3XHqr8K2vxtACRc7RiJtkZ0l+5ooAXit1LbibkXMY6FssczhwbiM+n1F0RLxFh64XnvzN2MWuW6C9cDcIjGnpJ6ugeJ3wDptoM2t2Ucm6BU579Pl82LSMWAQrB2KCZ3s1E37yiJBllwWgELtnfaTI//V5+P54N1hA4HJlUsTFLx7RkHGPtTGZUqyQoljYYrzZBudig+xQtq4oa3OFuGHbQs5yd3RvdOgcPOUTmMbCwWZRv9yb8yAee2IUTtPsm9GryZA+illOKsnNDCnyMvAurC+RLYrOOw53Sb8cY5umrMWkwiZWKs8KoXYbt3nwXoK+7Qc8ofWC1sTFYgKk3MdWpaW2fWAVXVJiqsIZPswf588 4JImGGmB ZCIh7 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)" The ksm only contains single pages, so we could add a new func ksm_get_folio for get_ksm_page to use folio instead of pages to save a couple of compound_head calls. After all caller replaced, get_ksm_page will be removed. Signed-off-by: Alex Shi (tencent) Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright Reviewed-by: David Hildenbrand --- mm/ksm.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index 8c001819cf10..ac080235b002 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -915,10 +915,10 @@ enum get_ksm_page_flags { * a page to put something that might look like our key in page->mapping. * is on its way to being freed; but it is an anomaly to bear in mind. */ -static struct page *get_ksm_page(struct ksm_stable_node *stable_node, +static struct folio *ksm_get_folio(struct ksm_stable_node *stable_node, enum get_ksm_page_flags flags) { - struct page *page; + struct folio *folio; void *expected_mapping; unsigned long kpfn; @@ -926,8 +926,8 @@ static struct page *get_ksm_page(struct ksm_stable_node *stable_node, PAGE_MAPPING_KSM); again: kpfn = READ_ONCE(stable_node->kpfn); /* Address dependency. */ - page = pfn_to_page(kpfn); - if (READ_ONCE(page->mapping) != expected_mapping) + folio = pfn_folio(kpfn); + if (READ_ONCE(folio->mapping) != expected_mapping) goto stale; /* @@ -940,41 +940,41 @@ static struct page *get_ksm_page(struct ksm_stable_node *stable_node, * in folio_migrate_mapping(), it might still be our page, * in which case it's essential to keep the node. */ - while (!get_page_unless_zero(page)) { + while (!folio_try_get(folio)) { /* * Another check for page->mapping != expected_mapping would * work here too. We have chosen the !PageSwapCache test to * optimize the common case, when the page is or is about to * be freed: PageSwapCache is cleared (under spin_lock_irq) * in the ref_freeze section of __remove_mapping(); but Anon - * page->mapping reset to NULL later, in free_pages_prepare(). + * folio->mapping reset to NULL later, in free_pages_prepare(). */ - if (!PageSwapCache(page)) + if (!folio_test_swapcache(folio)) goto stale; cpu_relax(); } - if (READ_ONCE(page->mapping) != expected_mapping) { - put_page(page); + if (READ_ONCE(folio->mapping) != expected_mapping) { + folio_put(folio); goto stale; } if (flags == GET_KSM_PAGE_TRYLOCK) { - if (!trylock_page(page)) { - put_page(page); + if (!folio_trylock(folio)) { + folio_put(folio); return ERR_PTR(-EBUSY); } } else if (flags == GET_KSM_PAGE_LOCK) - lock_page(page); + folio_lock(folio); if (flags != GET_KSM_PAGE_NOLOCK) { - if (READ_ONCE(page->mapping) != expected_mapping) { - unlock_page(page); - put_page(page); + if (READ_ONCE(folio->mapping) != expected_mapping) { + folio_unlock(folio); + folio_put(folio); goto stale; } } - return page; + return folio; stale: /* @@ -990,6 +990,14 @@ static struct page *get_ksm_page(struct ksm_stable_node *stable_node, return NULL; } +static struct page *get_ksm_page(struct ksm_stable_node *stable_node, + enum get_ksm_page_flags flags) +{ + struct folio *folio = ksm_get_folio(stable_node, flags); + + return &folio->page; +} + /* * Removing rmap_item from stable or unstable tree. * This function will clean the information from the stable/unstable tree. From patchwork Mon Mar 25 12:48:49 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: 13602017 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 6C965C54E64 for ; Mon, 25 Mar 2024 12:45:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04C6B6B0098; Mon, 25 Mar 2024 08:45:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 005F66B0099; Mon, 25 Mar 2024 08:45:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E065A6B009A; Mon, 25 Mar 2024 08:45:57 -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 CBEF56B0098 for ; Mon, 25 Mar 2024 08:45:57 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AF3751205F8 for ; Mon, 25 Mar 2024 12:45:57 +0000 (UTC) X-FDA: 81935533554.21.2614A72 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf21.hostedemail.com (Postfix) with ESMTP id A04FA1C0009 for ; Mon, 25 Mar 2024 12:45:55 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eVV1IaWV; spf=pass (imf21.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=1711370756; 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=35bf36rVzZCfy8oUlmgzrKLRW5lsRT/GT0/CEZQ4A3g=; b=fi0TIBh9wWxrOICVY/YImMH5NPSVO+uycj7LBjzS0hi87Icu+eTiBaDfuUOGt5LG2erWeG Sf7NhOK38hhhGga/T/xgQTNko5G7EVnU3Af9VFtDo0WhCNWkAd0+9EWjyeACVH27jdg44v NO1BF0taPoBvsSNCIl2CX+NTPw/HEac= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370756; a=rsa-sha256; cv=none; b=Hxk6+JCHkvsIdMVfYuv4w/fmDt40JiPdscM+8e2zFljDt0uMOlQwMU4qjdAPPXZfsEfu2+ q2Liogw4IYUF5tkMXfLS+u512c77/wQzUQ4jUAIf47Uiuk/NLgda3+cgRhcMpJTqXwzPXi VqB9JjvSOiK39BtSipopkksUZ49DLRg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eVV1IaWV; spf=pass (imf21.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 6D29CCE178C; Mon, 25 Mar 2024 12:45:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3302FC43394; Mon, 25 Mar 2024 12:45:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370750; bh=u2CpON+ylVsyq590GuxgPX8aACtNcQ54tsZFdjhyaWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eVV1IaWV9vRcxYwQUums5xqSP5Wq1JaDlgBpGgCe+m6yPpVz9ksbPoP0pmrHEZuu0 v6WWcfakc0/tzBGby00uzvkxjcOBYM6cHLDbWRpFTq94slZHx4TcMPDwKpMzYzzNz0 BMidSuGaNRhfTXfWCVNvqoZqUh4twz18njVGGXwvDUBvTVjq/UvN6fFPsMhX3Vrt7z aY3IAz2QpBy1FzTmFMmrd3Uzk8u+vLRLScq0kqqqEtzy66GpBwBQSuYmEXIScNvKzt 52cbGX7TGYSEhHydw6YfGvD4iY7cColqeIklQDrrLO+owD9mzzFk40BeiXE0DAfH40 jkgADT0ieNvdw== 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 02/14] mm/ksm: use folio in remove_rmap_item_from_tree Date: Mon, 25 Mar 2024 20:48:49 +0800 Message-ID: <20240325124904.398913-3-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> MIME-Version: 1.0 X-Stat-Signature: p4fsjjza1e9wuiue1xydf3som69doe9e X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: A04FA1C0009 X-Rspam-User: X-HE-Tag: 1711370755-85169 X-HE-Meta: U2FsdGVkX1+NYIiaLPi/o6jBy6z8cAdnujJ0WkU0N9GK6+hcObGXvqFpBZFmIeGeRzeYnzuG7v9FLi3HCx40AvRW2j9s/5F3Kw4KZ93oc7VMcac00xj7X+TPbb+kBD8ay283YxXn5IIFK2BlohHW+ymJJhtHIqrxu7glz7jYM+tHO4A1raQrvu3XmE98d9zccyElxg7UMKV76WNPbfX8uf7SFqmjjBwMF9VUZocgrR/kWJJs9/F3wFqdPPiODQNOPAThuAvSG+h9lon7Go4oewK1qZNIHgZyzwekWEUk52b+P4ChEr91dWdDa4WPc5PYAi4Wgcb6rF3SQVSffdkdjLq5vdR78AZXuSaSo7E5e6qiBDD8C2t7khgFDn23gVwliOli+t1vII5Aizs/PA2VQ/ZgtG5FQjmlZ86taFLChqjwFxAxiftdcz59DtY8iuvQSaKKSRaQC0lgxRvZE5MA/ugjdoxCofpCMJmMJYe/dbEbAnhxa3yi2ZGPckTr5brZVbm+oAp6wnfcQAbTtNKirjEQuraDsaPnLMPx4r9liylTkPTc/2qH8wOArzo3bmV95qpohP6u81KNMm4j5KV3y2c87LX0ffn/h7lkyoFtpyjxKgtmluGODEeKJySZhCbTaECTFfBbpurc9U2Sb/I4J3b95cfhIP2arMdqxpG9tKnCINsiE89+nd8npMYWfgYv3N8xGjRvl/vubx8Q5yG8ANAYK0YpO4McvEoBLx5sqyUyFrpeAapcnEK2tK8Qb2kGAp2NfHnlOYkNOvs2TNMe3OebAN3YXg+OdyBaVsZ4MhhyzJDAsdmLioM8TMsHkGCM4QH+fPBrdZN+2Fsbgr6LJMbbwYR8TKpyzr2eQWwRu1fwlzS6u448p1xMO/OSbSxmbu9tskTL2xt//WxKGy5Xo/UAyfeeqpJuW0mR1l+75DozB5aLAS4cgWmuRk7M7o+7mGwz5Cym+OFic8oLEha rhsKKzN+ pegYrcjs4kvGO1r3Oc5JE9pK+nsB7hyOYsUuAHsk/AJB/EAeOKWdTwccB1MshFPsGORUs1qin3PGOTMGFtHSFa8JDdm8evjfZGuBqbshkKkdw2Z9rW5zTsOyR2gnQOznkgGmZZonFMUidOGpsJP23umQTbwDS0tRDicrgsdjxBiTFeMfIJzCcXBWIZQZu79xX39hdtCOAEGC2ys5zsGHLeTAcGJabYICDGJ+ZYRYBAkVq/hKYKHN/1B6p8bH3v/dBagK+zvk7gyvOBTAE9Ah7oGBjcpifwy8Wr6XVKLfzXsI/VhalV9SEvQbrWiuKSyoJ0DSzt3ICcjv2EBc8ozv+40yI7hCZ0dc7j8aImdpKZCnBWeN2GzWSvDSB0zmpMg4FmKoaxsB4ZDGC/g6cXsCWQ0WzdXQEW7xATCob5XxJ80AyFSTMN74GALk9DvXkdErsyMUw+KfIlqmmE6Xq8LP2HpWzGQlPgF6fpN3G24xqaGetNa+YHj9sBwaSHodHcgDLH6HN 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)" To 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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index ac080235b002..ea3dabf71e47 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1006,16 +1006,16 @@ static void remove_rmap_item_from_tree(struct ksm_rmap_item *rmap_item) { if (rmap_item->address & STABLE_FLAG) { struct ksm_stable_node *stable_node; - struct page *page; + struct folio *folio; stable_node = rmap_item->head; - page = get_ksm_page(stable_node, GET_KSM_PAGE_LOCK); - if (!page) + folio = ksm_get_folio(stable_node, GET_KSM_PAGE_LOCK); + if (!folio) goto out; hlist_del(&rmap_item->hlist); - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); if (!hlist_empty(&stable_node->hlist)) ksm_pages_sharing--; From patchwork Mon Mar 25 12:48:50 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: 13602019 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 EDAFBCD11DD for ; Mon, 25 Mar 2024 12:46:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E2536B009B; Mon, 25 Mar 2024 08:46:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 48FFE6B009C; Mon, 25 Mar 2024 08:46:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E43B6B009D; Mon, 25 Mar 2024 08:46:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id F37996B009C for ; Mon, 25 Mar 2024 08:46:01 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8FA22160314 for ; Mon, 25 Mar 2024 12:46:01 +0000 (UTC) X-FDA: 81935533722.18.909FF47 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf15.hostedemail.com (Postfix) with ESMTP id A858BA0019 for ; Mon, 25 Mar 2024 12:45:59 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Whi5pHJZ; spf=pass (imf15.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=1711370760; 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=XGMdmYS1oT7AtfIwzwhYVurhrnfmW9Hkdz0PxTq4TG8=; b=ABgoUDx4kQC8DPP1uIFB29k1u4/nr7MchoGfP3NlrxY4fC4FS/s0fArjjKKvS8MLKfhS35 njHx4oAt+We6+3wj9j/Bffd8cLj2D5Dz2mheDrgJh6S8AH0iM1hHqzsQS68bzZlGR0A6u+ 6vFJGIwto+05qbTp2JvoP8iHC5OgXGs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370760; a=rsa-sha256; cv=none; b=MljczajELPSu2EVXzv6/bucQJqXKTrvXDrzZAoLwmsRXgg2WGw6GiZtFnCYf/uGILY1/fv htPK9KgxreX3GPBlUGP9wC6FZNBC2ZWhvtK7n8h74hF3PvcGxygqRe3dZJJyjVNn9JkicP 4CNN9uP3o49eVORQXJSwwivuBGi+2uM= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Whi5pHJZ; spf=pass (imf15.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 EBC49CE1799; Mon, 25 Mar 2024 12:45:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05091C433C7; Mon, 25 Mar 2024 12:45:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370753; bh=JrD4352jMaYHyAz8IW4Sk3DaQV9z/B+p1XK/ErSE0cs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Whi5pHJZTUlUd6zeuH0lUbmTWwy8sj968vK2RQbExjSv4J927iQXRAax2+zqP3+8Z syH0Miydew3n+dIqfFQbEdodShg6okCztcVT1q/0589fuGXcfUyzduK6ZLpruSDHQG 3ZJJAaqW+jGIx0FmJUNVsuUy8O+V183kQWq9ZI5P+NnBZUHq4iLWx8Si409N3S33xo uUtJvUSWMGqZ0Dn4M3kn9lOThpHWghQ3aPLhvV11Zk1dkPmeiEWNNzvj1Zp9e2UbXj ga9Fu+iazyMERJXJ+ZWG4V/8cwEH/THIP5vbAm67Aj1t2p2C3InwRy3kCtGkNu6HGD i24BIgprJ7qvw== 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 03/14] mm/ksm: add folio_set_stable_node Date: Mon, 25 Mar 2024 20:48:50 +0800 Message-ID: <20240325124904.398913-4-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> MIME-Version: 1.0 X-Rspamd-Queue-Id: A858BA0019 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 9o69xdw57x5w9913kbshdik3nj8tde9w X-HE-Tag: 1711370759-728307 X-HE-Meta: U2FsdGVkX19eK3xHK8xgbq5wXubEsRcaJA6dR+8qRK+QtU0tp8QRK+Rsjb9qWjHvaw1v8RHJruVBGrVM0qh5jDDaFURT7ShHR6J26B5vwYZ8yR/iLeLF3dUkMpBG0e5II8hsVh2MZwejccHyycjHEb+mRRgAPWQCj0aPwOwRha5uQ2MT7IShZ/W1blbD+gx5ZgZxTY5vaZNkOnBiTIda+QZd7RpIsl/oKYiFg65LACaV8vPD+C8ClhK+YN5FdpgJtUrg9cVE5SNKJY3c24V6nLtWYWTFRmHSqJSP5XBoIezAJqZwGUVp0ScO11+H5/jJiMGYjdhDGVPBxIULYy7FqDttyk9HHRcq6glhbvCFm6JLFPNie/gM1FRhOAqNtVZSOfknYAszEJCErfO0oAv7NFXi6c+hHgxaM/zrkTWx9r/Bgyn4Id6vdpgvpGb8wlezCJrKh/nleImTwKmrxlt/KQS8HA3QehL7X3K9MpteM2zv+Dd7A6cWRyUY6qqQFavul+M6rKm24uLQWexvP/IoCoHndqjDtNAqG3DR1lOh3wHCw8+b1wvyf9AMW++Qbjce0602494/vHY944hRAYG8tuuXUgCDPoI6fAeAL8m/IvchP0VrEGeYlkDbcfRUTrEjYl2JslM24MJGPdLnXtlSmaE9oBpML5Gbc72VamM7cm1VEjQA/m2Fe5ak+xVO0ydMCUfh8EZ0g1TtctMQj/x5eAdapaIx1QuHDekOo3VwfMTjluZpAmwjObxcW36AIJVM7JhDTkUXfiU24eGHxooLhh6lSlNdCeDbjeCp6HKQkZZQwzDz7w1JQI2aDIVnXTQmZA5qAdT5L30fodkJwlR1P8JhsGFvLp+GTqxsxTTZv4hFMmkDeKb+3jxu5Zc4Bz4asY6Q96PY/phT1jyssLZC9mt7fEKZHx5I2Bo0slGL8E/u0E8oPvzb0hhhSGgJc7UK5zTyoNTHPuV6ty8dMXJ B1OgcsQW s2ThV 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)" Turn set_page_stable_node() into a wrapper folio_set_stable_node, and then use it to replace the former. we will merge them together after all place converted to folio. Signed-off-by: Alex Shi (tencent) Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright --- mm/ksm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mm/ksm.c b/mm/ksm.c index ea3dabf71e47..c9b7c5701f22 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1109,6 +1109,12 @@ static inline void set_page_stable_node(struct page *page, page->mapping = (void *)((unsigned long)stable_node | PAGE_MAPPING_KSM); } +static inline void folio_set_stable_node(struct folio *folio, + struct ksm_stable_node *stable_node) +{ + set_page_stable_node(&folio->page, stable_node); +} + #ifdef CONFIG_SYSFS /* * Only called through the sysfs control interface: @@ -3241,7 +3247,7 @@ void folio_migrate_ksm(struct folio *newfolio, struct folio *folio) * has gone stale (or that folio_test_swapcache has been cleared). */ smp_wmb(); - set_page_stable_node(&folio->page, NULL); + folio_set_stable_node(folio, NULL); } } #endif /* CONFIG_MIGRATION */ From patchwork Mon Mar 25 12:48:51 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: 13602018 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 6C999C54E58 for ; Mon, 25 Mar 2024 12:46:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F19386B009A; Mon, 25 Mar 2024 08:46:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC8B36B009B; Mon, 25 Mar 2024 08:46:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6AF26B009C; Mon, 25 Mar 2024 08:46:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C342F6B009A for ; Mon, 25 Mar 2024 08:46:01 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 98157C066D for ; Mon, 25 Mar 2024 12:46:01 +0000 (UTC) X-FDA: 81935533722.14.29D8DDC Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf01.hostedemail.com (Postfix) with ESMTP id 7EE6A40015 for ; Mon, 25 Mar 2024 12:45:59 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eCXCMsav; spf=pass (imf01.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=1711370760; 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=hPqMQs/fY15AC2cVcg4j/r+MhUxad7KHQi26/px9qXs=; b=arID4MHzfkt54hN52Hn7weYsNa1qmLCaZPCJCZ7QBcdKKraPaG4p4DQNYYn+cyPfDDyBcd 25I4oEL6LF3HHTISImLL7M1s2riCbG+ct5x3CxtB2/x/hk+bvJs70bzPJwxCo8xkG/ED+K OSX9ut33xSSQlqGkezkfp4RbklGahvg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370760; a=rsa-sha256; cv=none; b=4RzquXhSoj8g+NRTffSVtbiHxT4MFj3mjEXrRVl0to7ceAKezPYuGEVbpYE3Sxu6Oz7IWB guE7lwkXy5+81LN84j6QAFkGTvIRXlcashjHh1fpZXUZLf+XqEdMQyyFdBbuG9LOQy5U2L D84w+RZB1ALIYaesPmxmpcc5bDfB2Uo= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eCXCMsav; spf=pass (imf01.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 DE28BCE1777; Mon, 25 Mar 2024 12:45:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9649C433A6; Mon, 25 Mar 2024 12:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370756; bh=k8zytA2A5T1rgDUiIACZ6hBdX8Fv5Jcn+9QWsQNKn6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eCXCMsavhNOpAhZ7kJ53WdZwQKpuR2F7J0ZTZC1rzgutAlE5WiOGa7PrxTMOnMARa JfPhPX9LQJiY8vbNiLiDBSY6pLZYbUANi5Je+jK5qa/nFXX8ERQS33vHjuNT83yyfT 2KMDNRZMHC5XZLJy4fUp8FjLNBwJsWRLvM+MebUe2K1BC+RHZCpaZiKwO6xFuGXiqW JZeggEJVwxFI1pFShlUUjpQTX4BZNY7UDVuzH6arWZhTGgCsUftr2vbwZUvooZ2RvS unmUy6JT9yoDSORyeY3EJoi02k2S0QsMfzHfpptaoaMcaebfat8W39e3t33np53eYi qMyO3pObODdMw== 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 04/14] mm/ksm: use folio in remove_stable_node Date: Mon, 25 Mar 2024 20:48:51 +0800 Message-ID: <20240325124904.398913-5-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> MIME-Version: 1.0 X-Stat-Signature: 64mwxezwn3uh3s5ixa8iui5ma38hmnbr X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 7EE6A40015 X-Rspam-User: X-HE-Tag: 1711370759-519720 X-HE-Meta: U2FsdGVkX18SqqMBWFf/oA18sVGP1jD/eDvdjUyqDUE9R39qpEMZEG5iFbj26C7D3gV4jemMmWsMVopu+gNNbY1MNghoFmFdKkVf2Ehcwv6MuKxUrujfBzOfWxO152qwuPQG6wbAYtm9dAX3BKtJGTrYq7l/cRxtz0kNBHefvRjgyNstvdyhdlCUpXgFKyRxX8mRW1DjQjfARNdaAhKS+sK7KNBZsy5GOc5D0MrJGYWd2ASFz9IfTuJkFgSzRyNtix7C80v6LlnA1vn/mrEZeicwrBSxXDFRKePo3t2y05VIcZCRKmEGorLiyxkwAtWuGJuTLzghk0G3e2QCCJTVwVRO9CmdOGjeebTi8BeiYeL5BKK2SfcgY3U+u3jr7/ZRZozvdNRXxjczBKAB9qV5Gib9aeUITsgWVomjraaJar0CWVNmmnldkZwy5lm9dbneK8YWfYWZzGQFExGXT7+iLICNQ9QLyb1lq87lYR61+lOdoCFlmv8M9YQvN7QVjSGB0j43xS+PjlfDEPusxT/umUDYzZ5VQyVzdw9A3bbljncUeYoZI9JWUCk1ubchIWzhBCK17OxmeLwhtSgYCfDOqSchVwjs4LTemerdn9qYPzyAEMsMMVc59Wv3Pe8vmDhY16+Z7/SdvtjqDzz/bVrGzpRFJVbPTrNpcXkNBty1PqsZevgPd07RcvDTriBTtx94pXB4gnIYTQiAGQG7v8tG20KvamO4B127dh3k95hc/4jydJ0dgdjqU/Cc2Z+jnAHDOZGcy1CK0Do26Vlv77qGhOrl9Fzw+0k/IgT5b5++GXXEt01GIql5n6Twh47KmjVw6gtVhK61kp6ja7xcAz/UIGLrkPLxqZKolV/v7bo1HzoCEpAyQFuCYBePh6agR6zXUrJ1AmTR70cjkmaM6UBVkopV/Xp/V3IxHOPSSdSF3eqZPhjxjYhQKpkifluMip2XGDik7+fIVGy2g6yw7eL Er04XWv+ xAZQIhcDlgM5I75LxgC3uSUMbr+q24sjZNP9aVIfc6hqlsUM6KHHxj4wCHIWNl1/25XJspHAS4kKdSS4uff1u1foSzuYq+s4HCc7eWuvREatygHCFqCdD4sO2SnsCWMzHnpNjBcaETlcBpqrO0E3VuEbwQ5VrQgRNd6FWg7XVcxYAm+Hcadwc1SUetZH3eWiOx0DwAnApLhLFiYs/1GbNlAY6YyxvGvbumo6N/UzTb9dSTSWme+9LjSVQF5IT/d9UhAyPAx1wivPin3EpJMvdeT5O3uZ50UwMB9kI0VIafmpU3j2CmpGYTix+3AVV///ynRW8fMiH/rdPQFfJH2RqDAlqCzp4twHjb7dt7Fep8hBEIlfw1LHTo3XirurQ3ZxTNxqyIyMTNqoNhXp7fhIRLcXykQuvM25uVCNyP8DtMd1SBRJU7ym77hLfIjGLaD2JFbaQh/lGX8DAktvWeRvnRTNy5PolprLwuy+WwUJbP5vjOoy5fGI/1GZ4PVTchPmbX7GR 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, 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; } From patchwork Mon Mar 25 12:48:52 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: 13602021 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 0121ACD11DB for ; Mon, 25 Mar 2024 12:46:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA5BC6B009F; Mon, 25 Mar 2024 08:46:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E07EE6B00A0; Mon, 25 Mar 2024 08:46:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA7316B00A1; Mon, 25 Mar 2024 08:46:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B4A566B009F for ; Mon, 25 Mar 2024 08:46:07 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8BB5C1A0588 for ; Mon, 25 Mar 2024 12:46:07 +0000 (UTC) X-FDA: 81935533974.21.1F93E4A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf10.hostedemail.com (Postfix) with ESMTP id 82613C0003 for ; Mon, 25 Mar 2024 12:46:05 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LRtPf4r8; spf=pass (imf10.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370766; a=rsa-sha256; cv=none; b=rBTrpbWuZFQjxwWB8c0MIkq4kX3sxY/b8KsmQQqZw2qTknfT5fbPvFsOVm8xiAB/Q9+sqG Vwkuwu2oDdGWpWOjCiRiAFIDcdE34FXqtCMNnextCF/WsM41OqLEZWEDO/RaKr5QQZzAGR OkkSxfrg3zEhTaWJL52iL64cgzJf1xA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LRtPf4r8; spf=pass (imf10.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=1711370766; 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=oM/I0IW4sNN1M+mWX3Gj5u2yvEIbpRfkYSEBOg5dRw4=; b=CdOZEIef1doSqlIeVqjAmrpq4eWX6w1RrI2Y/0HfdxyiBudJbhNJgtVeBzBCirDGi2SiB1 8GnxEal20kENcDQyYAo17fPttWUX0dEvdL3H2g5yrgoS01n+mn/NVgUm5iJYYrHyKAdLHx GRTI2GVxL94Mi+a3er6nCaVYC0hGjy0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id CC192CE178F; Mon, 25 Mar 2024 12:45:59 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 82613C0003 X-Stat-Signature: ym4go1fidt1xhycfaky8d6n676e35f11 X-Rspam-User: X-HE-Tag: 1711370765-341683 X-HE-Meta: U2FsdGVkX18rYiyNE7sOnQT3S0RB7SyvpfekOO4TaEC4brp/C0sxkQoGZg5hW4E41mfbUHaeP+x1QWKFGpew+KqAx5900iNbgvnBS1L3hd5kjOdQ4WUmMZUZY6/EqCcbW9ZQLJqJRImWCb+C0hJGHsZmxqg6LdXYpxgEisDU6LM61te9mqK9Hud3aUXQj9N502Qm0G2jHM4jOFypcRfQ82k+whjOP7JiFhgDdk88UzbG1JDR2dMdUBFp6hgtEzmimbwJTw5EgOwbXo08ZAwtNLdTwaCFyYhOdLwEkCxd0ExXAj0WwTZZeZWAOwJy/ETZ/0Tx8kodBgB2luoPJs28GYWwYHkD8BJgB0Epuasfx4InGbdlTrjLJJovcOBvE/y1MlbuIC+G1v4ZGzTr5g7QbvcR5e60nNGWkz1rOucAet7qdHAozGGfxkCGWmTSmDrVXWdPO7ACSXl7t4plA42srF/NP5GYmaBXh4rh0r1D3rPtTNia4B5wG8YTc6j+0cWorgkEiXH03wlQJFpNrU7txDM3b48WUS/MQW8d2TxHkiJipqrUTBKzr4vMOzvCQpBcTlAfdvxtDklC9rVupmd3LhJv/irGMpDIWIh9ZZpdH9HwtwOUoSgBxxWDt7XWwFxdnuz2r9dZ27OvUAzNZBN1sjAgxm+Z2Sv/2G7l0p/ZPGWumBMqTczKv2WUMnG90hH1fnNiPFKqGcc589VumI8Rx//FUDCqnGqZxOB1sMxBQrmvGOm7qlzKBcBh/X7GQ73Eki1uHZIuCIDst+vWEYOD/QADdZbxzNjDnvBfl1rn+IFPeEzRlv3cijNjR4M+RkL5Tx1mgbHV4a4a8vvZ7eCXtAh2tKkhs0NTLbjBCuFm1VfEgeFYRVVKRQn9NtKxE3OoxdNHYX3Mz1fkwGdzOLHW+AgteTj23NfCMKCAG/D4ePkLmIWdIjp32KOKBW2no4YxFoNtGoCxqb9rPKICTkb B+aGQ6rA oaQsU4y5CwudNwIX5XytUBEDYMgU/niAt2wRNge3vhDHuRSsxfntUUlyCdqT1QH0MO+ODyVWpyMUtTW4mv8PJszu7owS/baqJYZ9Ef2n3mgnDuoxUBlnMxYhlGp4JkUVjNPBT0op2lxWLJ2Ei8pHxwzCCQ2zIE2D16RmFPWosnIEbZ5hpOmiBWAERxamig2yz5ttW9WWN2rJU2G1Ky91/aTqGPX2CqroEuZ/HsPqgQUWoUoDeZ0uLSkxXKULdZ2ewU+MnsfYiZ67EYDDcBQcIo4IfllFSyeT5fn4N576cwwmV+XsC2HZclZbMuA/r/AcjeGxz7fxZGZJVlXEsHIApzV4Ey0/vqrydBi5jBUc9d5gVhyJU9FhXLHboJzgxu/r/ob7D2vDDO7sKqT7mWG0e1FGg0SEsjJyDLgXFanA2JJAIUjYoLIgGGY/aR5SCKzlNNM7bIFbwi2saZbnpv8W7cHBHRKx1OZFTcI168zWQv9hS2/ef1AVIQDghLibykIUGc0GI 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)" 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, From patchwork Mon Mar 25 12:48:53 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: 13602020 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 55C95C54E64 for ; Mon, 25 Mar 2024 12:46:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 427C96B009D; Mon, 25 Mar 2024 08:46:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B0586B009E; Mon, 25 Mar 2024 08:46:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 24A076B009F; Mon, 25 Mar 2024 08:46:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0D3386B009D for ; Mon, 25 Mar 2024 08:46:05 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A374E403A8 for ; Mon, 25 Mar 2024 12:46:04 +0000 (UTC) X-FDA: 81935533848.14.F6CCC4E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 0D70D1C0017 for ; Mon, 25 Mar 2024 12:46:02 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QjoZ6FgV; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711370763; 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=L+qO/XcqcIKAFhCFoyPhJG1UhlvKPeV2i/jpCfuNQwc=; b=4ZoO7BtjFtAgy+wQ+tkdDFsbzmLHEa10QTI0MP0ST3S/JMat/Cq9WmgdCX6NVYgy2AHo6k XQEZ3etEzRjpIBYLWnLEeXUt0JMsw7ig7EEAhWDxrDRVZQLktxQRPnQjl77Gp3i+ktV+6Z JkRgfEh15k0JjxgLA4tzQz0ptZpaWfM= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QjoZ6FgV; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370763; a=rsa-sha256; cv=none; b=psPIhnIzHLn8DUiAVjYKkUQDk/CVT15mhkdwI0IDdvD6j0z1/hrfD/7hWoGE2V14Jig2kW neAAKlk6djjQrrfGKxultQsvyphcbMCyt6nluk0Nduehpsli2nmlyEj7mnMCT/8U9LqL3m ccvDV/rm3ZOwq2p4Oe5qOBQFxBxYIHI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3D6A360FA4; Mon, 25 Mar 2024 12:46:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAFF3C43399; Mon, 25 Mar 2024 12:45:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370761; bh=3EngGDxtSZrFY+NPFGnfYU0Kocquv/KpfYgYZYqOFCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QjoZ6FgVlpIls85bdewPna6oDmn2WQIkdvXxVa0PVuSTOfSnoi2GS67/7T2yzLGTU pqP+ZuzwlR93nUViU+yT+7Bo1vkuR/mInu4r5dalOt34sGCZ9YT8pBFxsswAhrUScn rL5f6uni+PSLCcHF3+sBGjcIr96ZecpdJaqpTwIBsEZo94tASOiWtA52AAQHG9ymA8 LQeACgbCBpU4vPjteVHgegKWJPmSOubP0Wr5v9+rVr00SleMoJB8IZu30VbCEFdf6y pg5XBGAOTY31Ro0NURQi8DmQmS+ykXp+MXa0O55h72zSE68tY9uPF5QTHq+1A4Hbeu 5pXqw9a5deBMw== 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 06/14] mm/ksm: use ksm_get_folio in scan_get_next_rmap_item Date: Mon, 25 Mar 2024 20:48:53 +0800 Message-ID: <20240325124904.398913-7-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> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0D70D1C0017 X-Stat-Signature: oyntp65qsn5mm14ji3grpfmesbreiw7e X-HE-Tag: 1711370762-610081 X-HE-Meta: U2FsdGVkX1+O2FPnQiQer75hd8VviEbnxyodcr2elviXLrlgp7doNSdJyjYaT8vXYQ9wsb348E54W51bSad9iq5UNcYo5O12X3IqU6TgL1JeaicXxcegfiY7RWGLkP6ISzeDm9eMPJHm4jnULj80YKey1vEjCwfPBLZUkSpm20e4Kgz1Uc9+9eMK8WA+dOOo8GoXBGhqM5hEU0Kd1Mnwhe2kHORv5Jqg8lYUPHAM7gV0FdXcEbFK53UkXCF+pGvMNEKusofprJs4mrnrD7ktdcPVmJ01U2dNCtv/Nw6T1NNTFmwFgs95q46qowI6Yfyzgk/8XTd7FxSK+EOUNsY7xtEVtHt7ZtrTfGI0+KuNgza0dQKqgDikK0VschoArcQem2gtcCFOlVOoXIROrrJP0PPlQEg1WRqCEkD5Ow3xEgdiW22BLnPGCF1PladyvajYVZQn4IDcJSxNTWbSvpZYs9GIjxH+IpmXmtmsPYe6qhKKIuH+zBZSg81LPi2JC4zYgGNwSol/CIaiI3y0M5G5TKBZ2RufqQAPCcPTY6+Ol8daEoh8PLSD1QKVaZHWQZwJXKm5mtsrTBbvwyFTbtTeVstUSnl3sVJLqryz/4H4eEZ/Se8umlBBluMEH+2SE7Act8Rmi5LfjIwbbzuBuA9c2+qWwGPqJ6gB+mHLC3YJDn8ZBLSy6XYpMfVkC1z1cfIZOL6Hz0vMCL2yXs22awgYhg5asCJYhaoAepafJhzme3rrQaCF6Cg/Bw8AFzjytPrNs6HEWbSoR3QvVHry2qWctjpiasueeY1z5ruYvFvOd1noA8BBnr2Wu1VM4iPJ3T+akbd92yRM3ZbXRlLgyWk2nCDXLuvavXMw55fA7H51bxxvE3Fq3/z9FuGIdCkc5Ctiugf4djklzFYeCyuEt/jnXMoq5Ic0rFBgfoH/S8uzRK/rKzTlN5nJkcN4lp1GCKx1sirVA3hRkZndGRKkcIg MLK61BmQ pLLNfvB5u8YqjRvW4Zd8cccm2kb2QoWevZ1rxcwMyhn+hH8fBBzpEiN0fWC8ozQjyUscIEsnPInWXvfE1FscYCTFVWEBO5WmX/rPhLBuNhKXLN1kH09AyARKek+T7Tm/+fEu/aoC8GcT0Fj/yonbGzXI78Di9hX22KM58QBbTzS38tYntiy/ENYy53tHbwRGfxEv5lMT4M7RIyN4lya7WIn54HoH/youEvucVKDvLmD7w9QiiAO+qVFi5gVgj+IuMZhH64VUfJEpBfaTVjjObAyvaneUW3vBcfHATkNAnOdCq1H9TXNO1nrOaFaJSxMKsLlHsfkJzMUOp5J03m6Hr1Wezb6FPVNZM0cVRom5at9sXOAyKv081uNDLDRtIe68tUZUvwC5DSgnOsbrlBZSB3TcBAyDFzGXLHjmhuLwAs142Z6Toifyi4T2F47L+tLrXkjyytLIgRg/Sovs7CJIZ75a4tFH8OCNcLamWOclHwSBcWVHME6jYAY4QL7+9QZpJJSCu 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)" Save a compound calls. Signed-off-by: Alex Shi (tencent) Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright Reviewed-by: David Hildenbrand --- mm/ksm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index aa80fbf3a8e0..95a487a21eed 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -2611,14 +2611,14 @@ static struct ksm_rmap_item *scan_get_next_rmap_item(struct page **page) */ if (!ksm_merge_across_nodes) { struct ksm_stable_node *stable_node, *next; - struct page *page; + struct folio *folio; list_for_each_entry_safe(stable_node, next, &migrate_nodes, list) { - page = get_ksm_page(stable_node, - GET_KSM_PAGE_NOLOCK); - if (page) - put_page(page); + folio = ksm_get_folio(stable_node, + GET_KSM_PAGE_NOLOCK); + if (folio) + folio_put(folio); cond_resched(); } } From patchwork Mon Mar 25 12:48:54 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: 13602023 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 47C61C54E58 for ; Mon, 25 Mar 2024 12:46:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5498E6B00A1; Mon, 25 Mar 2024 08:46:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 30DE76B00A0; Mon, 25 Mar 2024 08:46:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0266E6B00A2; Mon, 25 Mar 2024 08:46:10 -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 E01246B00A1 for ; Mon, 25 Mar 2024 08:46:10 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BAAEB120127 for ; Mon, 25 Mar 2024 12:46:10 +0000 (UTC) X-FDA: 81935534100.17.E15540B Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf11.hostedemail.com (Postfix) with ESMTP id 882C340004 for ; Mon, 25 Mar 2024 12:46:08 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=n5flbydc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711370769; 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=GTIvm95tmRMu9y0w9Nk5VdEWqO3RtrTdJLLTXsaOd+U=; b=YEojhgeHnP97Ot6t4P12tC/7Ti80w48xYEuIZT8PlG+pixODh+XUCzkDxHRYSPGcgZ5ASz WdqTsyRkQG6isbcF2D5F0fnTh0sa1mjHInoIgR7BE8Yf68zzQGyA3WU+r4LIM0f+BkbT8e +UQyVfGbTXJeIUWWpu7WmdKtP+y5GF4= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=n5flbydc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370769; a=rsa-sha256; cv=none; b=M9iE13AT4QiRk00WwgzfR+dNAzYeyxmmpR4X1zeq9YAMzg+RDF13bUf2Lz6ORP+kR5Pb/5 uA9k13x5UWV2OV2AwvkjXJog050faYWDOd/2OEWyrW074fiYEzjvCgCsKbMe1yt0ApBn6N mcvdMNTazvYOYs+SlUHXvKxTAFUI0c0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 9452BCE1787; Mon, 25 Mar 2024 12:46:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 803FAC43390; Mon, 25 Mar 2024 12:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370764; bh=lWYPejGlgqLibFq5W+K6QUuTn2MtB1S2BqZV6I+i3CE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n5flbydcPOaY/CsPsj+d8KOVqtPlR7xNta+LNhWtad6FJFqA70qit66HqnLvBbz5W PdFK1AZAtFcn36YWBVeGKp1BGYJqFQrd1S76oa3P3pen/6qEOHCUMZyvtVT0BMdG8D w6CHnT3FBjQiWJgLtz+B/cuSw7+Su7GkwpVK3atIN530jw6OwqlIIPtj3GQviOugv1 XJuV5uGhtUYaSPGpRX8ZhcKDV7IQPfuLmkTsmrpbASbcL83UW9eck85Hv6WiRboR/g IsYR4VfIJHEB7VqvFgPPzG3FKyXwQXR9nujPgfxR5nrtDhNtiW350jdjOHhAZXtbaH PLku2UoUL3Gmw== 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 07/14] mm/ksm: use folio in write_protect_page Date: Mon, 25 Mar 2024 20:48:54 +0800 Message-ID: <20240325124904.398913-8-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> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 882C340004 X-Stat-Signature: asjmcapwtx9r6oynf6dtufx6ixsexh8w X-Rspam-User: X-HE-Tag: 1711370768-185005 X-HE-Meta: U2FsdGVkX1+e7CRkeC1gVgobR9xCAUxo0AzTSiYCA/D/H7hLopZl0p6CTxLqaKxLHLrjywQ8SVaylzcTqFG4EnKVoyxo/3PLK6aD0VQhwNjXac3RZT4zyzne9bWOcUKs9OsYHRs7HUA+6XMZlppq/D9dUCDPh/emQfQEcCk31ROyTw7NZd5YkDlj72ubCp0MEiZOjh0sLyrhfcj7dry6+0QtNRaiMnE0kQZTBwFkeEOqqsKVXawtMuIddZaHMStbx8PRlnkBIVmdv0Z/b8hTXMDZYwxVBjQ50TO19JRXehPl8Z22HhCfEHm4VEdPCSw22VCRkdmOalVZr3ACrjmMmWRqN2BfXSB/92hfwcLeILMC7gQR72933GHUBnLzX0749cVbpAaHvyXY90jXHoGXw5AnVUrRSJ7bEO2Oy159MuOYlG0EtbTOcOc+5TtnFFWS5bBnjj/Ew1TuV7JUsZX7UildjflGHVfOc+PD9LbvlBU4q+EsLRhp0phMMFuSZaNqyZ2cyW6AZhcCBQhCrxBlHbBAfcHY8mpKGuPC2N6wJ9R1OoeIrVNJg0H51CDSyPkxc4TNxJgT6wLaWp3o6Irj8oEq4BGNtns1iaKmjLoVSObFUOhOga0mWJ2Qg2UhKoJr6iBT8DK1PFlMUtb/KqpEjAbTT7chgk0zOtEy2sYodqKWKuqunrg9kmCOiKgf6hJFcyl7WzOvNWx0Nzs3+IAxfhKHPSvHUZa0sc4PuEBjtbQRGpU/qj5+0UOWqVgauIBCqoaBL8Zc90s5mpa2+sRPWTH7W9LwPmC4pqvxuAhTv0eNES63CkMPc50LKb5RHjbtiz4nCnKAMD4RE9yYlZY9JdY5i4p/YrbubWVqg/Rn7xzNyV72ltaLsXoPTwVYi/ctvT8MmeVxqVKxuqDakhGqbFlsk/pKDEGqQHBjEsMr2iggHLgih6cdSrm9kxZMZvFu3I9zQwEffMtdqb/I/u3 /fC+fuj5 PAUxBn2jDAScxrBqsDgdgwkeZPybyP/e/DTyx45gly/dysK5jmamFgtTjwxQqzCb857LZMiXgP6yOvwAy13b2BCzfWK69RePEpPvpG9wIp9dfJ5DO5oKOIsv5oCXc3iwgjU16V74HbhHSYhyDEC2e2uzG2UJEXCSnMzN7xN92n5goJjfWz2+BO35EgMCvK6LZL+jjR32JpznLG42PLooRSQjsOW8z7RAZKrEIoEC124Gk95ZtmgJi66FFYdKBTpgRWPqm2x2zUvhrqTzMEBw2I3AgmfGv/RhsiOy3JeaJKJJ8WKZxwCJHvmGFUjxJ9URaBQll2LvilEGU4OxAcHa2G+5xjrnxAXrv9SQQ31Dmj7On1MSctp45fflyZcXreO+SjKqTfiGnBbUSB0f/sR4lFSFC29QdPQiy5pj7xBNXEWDeBAdHycgh7sbKo/stmjzrfDsOaAzAuKIev9dLELMMKvvFKGxU/eZ2qcgt4U2/dBc4CKn5PSKklDyVhR+Rkm8O3Una 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)" Compound page is checked and skipped before write_protect_page() called, use folio to save a few compound_head checking. Signed-off-by: Alex Shi (tencent) Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright --- mm/ksm.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index 95a487a21eed..5d1f62e7462a 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1289,22 +1289,22 @@ static u32 calc_checksum(struct page *page) return checksum; } -static int write_protect_page(struct vm_area_struct *vma, struct page *page, +static int write_protect_page(struct vm_area_struct *vma, struct folio *folio, pte_t *orig_pte) { struct mm_struct *mm = vma->vm_mm; - DEFINE_PAGE_VMA_WALK(pvmw, page, vma, 0, 0); + DEFINE_FOLIO_VMA_WALK(pvmw, folio, vma, 0, 0); int swapped; int err = -EFAULT; struct mmu_notifier_range range; bool anon_exclusive; pte_t entry; - pvmw.address = page_address_in_vma(page, vma); + pvmw.address = page_address_in_vma(&folio->page, vma); if (pvmw.address == -EFAULT) goto out; - BUG_ON(PageTransCompound(page)); + VM_BUG_ON(folio_test_large(folio)); mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, mm, pvmw.address, pvmw.address + PAGE_SIZE); @@ -1315,12 +1315,12 @@ static int write_protect_page(struct vm_area_struct *vma, struct page *page, if (WARN_ONCE(!pvmw.pte, "Unexpected PMD mapping?")) goto out_unlock; - anon_exclusive = PageAnonExclusive(page); + anon_exclusive = PageAnonExclusive(&folio->page); entry = ptep_get(pvmw.pte); if (pte_write(entry) || pte_dirty(entry) || anon_exclusive || mm_tlb_flush_pending(mm)) { - swapped = PageSwapCache(page); - flush_cache_page(vma, pvmw.address, page_to_pfn(page)); + swapped = folio_test_swapcache(folio); + flush_cache_page(vma, pvmw.address, folio_pfn(folio)); /* * Ok this is tricky, when get_user_pages_fast() run it doesn't * take any lock, therefore the check that we are going to make @@ -1340,20 +1340,20 @@ static int write_protect_page(struct vm_area_struct *vma, struct page *page, * Check that no O_DIRECT or similar I/O is in progress on the * page */ - if (page_mapcount(page) + 1 + swapped != page_count(page)) { + if (folio_mapcount(folio) + 1 + swapped != folio_ref_count(folio)) { set_pte_at(mm, pvmw.address, pvmw.pte, entry); goto out_unlock; } /* See folio_try_share_anon_rmap_pte(): clear PTE first. */ if (anon_exclusive && - folio_try_share_anon_rmap_pte(page_folio(page), page)) { + folio_try_share_anon_rmap_pte(folio, &folio->page)) { set_pte_at(mm, pvmw.address, pvmw.pte, entry); goto out_unlock; } if (pte_dirty(entry)) - set_page_dirty(page); + folio_mark_dirty(folio); entry = pte_mkclean(entry); if (pte_write(entry)) @@ -1519,7 +1519,7 @@ static int try_to_merge_one_page(struct vm_area_struct *vma, * ptes are necessarily already write-protected. But in either * case, we need to lock and check page_count is not raised. */ - if (write_protect_page(vma, page, &orig_pte) == 0) { + if (write_protect_page(vma, page_folio(page), &orig_pte) == 0) { if (!kpage) { /* * While we hold page lock, upgrade page from From patchwork Mon Mar 25 12:48:55 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: 13602022 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 A0FADC54E58 for ; Mon, 25 Mar 2024 12:46:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 31C106B00A4; Mon, 25 Mar 2024 08:46:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 185C66B00A1; Mon, 25 Mar 2024 08:46:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECD5D6B00A3; Mon, 25 Mar 2024 08:46:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D33556B00A0 for ; Mon, 25 Mar 2024 08:46:10 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 75F88C066D for ; Mon, 25 Mar 2024 12:46:10 +0000 (UTC) X-FDA: 81935534100.23.3333279 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id C43C81C0020 for ; Mon, 25 Mar 2024 12:46:08 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q6AU0w0G; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711370768; 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=CgdU2ldzb6Q1lsQxi1OyvuCL84QsEiZRjwXqHJ8gUzE=; b=e70drT0YiW4/kyKKSDzxPLo8/jejaCl0opCgOxnYlDS7siVs7ndtt2/IsxlnYObCE+2zmJ fMuIpps7L3aeYTi3VBFaq2uU6+i9v0v70p4gtGWs035lYpR+Tb1AiXlkEIjAOb82N1qgPb p7KRyRzOj74g3fDiNuumTzCVBQU8IvM= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q6AU0w0G; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370768; a=rsa-sha256; cv=none; b=s2Zs+7uETa2KH+2YG6Q6AqOhn3ohTZTPBsmdM5oI1OWj14+a5fW6+GEbguY/GHgAP1PPPn dIzJBQRP5zFMCzavamBcNHADsXKLywK3Tk265vBiojOfHkvBNblbQlUsJGuFJi8heL01n9 +C2yE8qyLsFA53Lm6gCU5+FKviajJKU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D08B060FAF; Mon, 25 Mar 2024 12:46:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71F09C433C7; Mon, 25 Mar 2024 12:46:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370767; bh=1FMqhrTGzv5mI88ql04GgunChyuiZ5EvE2fgo8IbQMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q6AU0w0G/erVGHeJFCX8w/EJeqQFE15Jq05PpOfDQBhQz0mLQRG3ULcPNL3SLertO hm4n2HJMGH+yHfEe8vGRHIR/elq9l+W/2TbpJZ2GhGaruVJ01wKwR0R7Cmca21hYkV xFOaBsAKY2ZQPFpe4yhgc4Rzny2PfvvMx/gv6TAdu0j3fMV7kgXUoDoZaBVb4GU+2y /aPGy4PlY/7p0uinoDfWfyGGQWsWOd+zgrV+h+f2TvnIx5fTUhmTu7a4xO7oracQtb ZQnNvcIT7N/spzY9RL0DCzzdiFMFj8Q99B+mVOCimWgsSOHsYZEdx6ErXYixa63Cz6 YAE22wFF72Aog== 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 08/14] mm/ksm: Convert chain series funcs to use folio Date: Mon, 25 Mar 2024 20:48:55 +0800 Message-ID: <20240325124904.398913-9-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> MIME-Version: 1.0 X-Rspamd-Queue-Id: C43C81C0020 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: jns57zdmzxx36gsnofco6ztn6ej9i5uj X-HE-Tag: 1711370768-532679 X-HE-Meta: U2FsdGVkX19zIMUBu39Qq/S2j0xWUoSipHpevQvg136Txic88hJAoLM30nne269Ybe518h3FKHAWSfkq212oOb2jyC5XzYwpp/MO/r/3bL98xj9qD7xnvKiVlLZqCITdr4OGi8nRqTcTdTJwVbReGcDivHRilXUckYIaUqtNzO4N3X83hwN3kOlxGM0zPXuoPeH9niaVw828jhanY8/i6O4zfFVIQyempuJ3Uogi4BEABxjOOiha4JBaJ0nYdb7XpwDv9Uf9kxPbhpG66wO0AGrRunSi90dZaJ4lwMyJVvXgdKLYAf0o81HWGG3C5WzbN35Y+mohOX7TZpO2NmvyLE0qE4F5rRyp9cAR0XwUKLdDeWnZhTtaRXKJEqi2B6YGlRCve58++ZQfqTT+91LBHHO5z2l0XCRUHtKHPh1EgzEdtgbjGa81/jT3t+YwlAuTm4Q/2c6vgOY7QKfxUWrR6o32JGoGucgKxwClQRpiI0MHgAN5cdWkDPAwYUSShq+f44EFe018gumYTpR0Rbg/VrzPEdjj3eRmenWQ/duTi+ycVQ5/brN4WBKCA96JF4fpZq1bSo6iQlhNz6ErtF6TLFiVm6TwkHPB8McqCS7cqtI4Sgw7VxA4KbvuaCvFeb21MWedEuyi/5IMsiV3MsJps9ssLoMdyhW2c5U9oEOFdYQr/GDkBuOcvwV0bh5ceHEhQ2d+yWB0u9cgvjgJHsNj0i5PiEsfMCe3kA2cbUcqwUVTLpWnA2ydmmmyXSfTPWvzH+4ZZSZ4QIZ02xbvOvvDchH5WdhpSDDr4Bq46ABnlf92fccvz8A50GY31HirvVMyWJH13/C+49W20ivPCagkwBMYWzDnuIOTEy2Fxd9+I4DEi4XNYlb/DpoqEBPb/G+/drFoQ4USH+7H3FtfDO1X3tq7sKwKZ1iudcJKyuFWXcl9XHCnzVAlkoas88BUABMYvrpRrZbxg+5TY3vl3t4 vkPEhnwj cazYLJ40rK2Eh4PbYJp5seOWtz9Qvo3wjVsuLVyIzOH+sZ1+btrGdR8W2qDqwamTBYh1p3G2Tbg/RymXzBgmolC+3T+qSthtIyGbeN7CrmxfVALld5KyFRi4TDL8QPjxBcKhSnEcWaU89iRMmiZkSIr8ZafQnksXnnwxUMLCS2osRmxm/is9WYhM9X/2wIPV925GIVRzw+btgfsR14yNUpxHkrrDklEZj8KlGip/5K26XSaTBOwgaPrpBrTdWGQYGAz8NgpVRVhzclwECL0ymbrmcovc7ZQ/b7dJYoD0DQFJtbhYDdX6fIIl4K65wHOyevEcGuGUwMZ5YkLUuF35gZRAyNtnWqwEEwXFWOwNnyFYOo3g5CE673AolIM2fjsMEstbgu1Jab/uQ7LYSpzskZvdJ1YqhkYvjyvpT89dipVoJoZ2j2ZQKT4uoc3lI6NT2IhNlHx+b/yYGnaw= 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)" In ksm stable tree all page are single, let's convert them to use folios. Change return type to void is ugly, but for a series funcs, it's still a bit simpler than adding new funcs. And they will be changed to 'struct folio' soon. Signed-off-by: Alex Shi (tencent) Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright --- mm/ksm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index 5d1f62e7462a..7188997437d3 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1777,7 +1777,7 @@ static struct ksm_stable_node *stable_node_dup_any(struct ksm_stable_node *stabl * function and will be overwritten in all cases, the caller doesn't * need to initialize it. */ -static struct page *__stable_node_chain(struct ksm_stable_node **_stable_node_dup, +static void *__stable_node_chain(struct ksm_stable_node **_stable_node_dup, struct ksm_stable_node **_stable_node, struct rb_root *root, bool prune_stale_stable_nodes) @@ -1799,24 +1799,24 @@ static struct page *__stable_node_chain(struct ksm_stable_node **_stable_node_du prune_stale_stable_nodes); } -static __always_inline struct page *chain_prune(struct ksm_stable_node **s_n_d, +static __always_inline void *chain_prune(struct ksm_stable_node **s_n_d, struct ksm_stable_node **s_n, struct rb_root *root) { return __stable_node_chain(s_n_d, s_n, root, true); } -static __always_inline struct page *chain(struct ksm_stable_node **s_n_d, +static __always_inline void *chain(struct ksm_stable_node **s_n_d, struct ksm_stable_node *s_n, struct rb_root *root) { struct ksm_stable_node *old_stable_node = s_n; - struct page *tree_page; + struct folio *tree_folio; - tree_page = __stable_node_chain(s_n_d, &s_n, root, false); + tree_folio = __stable_node_chain(s_n_d, &s_n, root, false); /* not pruning dups so s_n cannot have changed */ VM_BUG_ON(s_n != old_stable_node); - return tree_page; + return tree_folio; } /* From patchwork Mon Mar 25 12:48:56 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: 13602024 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 13165C54E64 for ; Mon, 25 Mar 2024 12:46:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE4756B00A3; Mon, 25 Mar 2024 08:46:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D6AF36B00A5; Mon, 25 Mar 2024 08:46:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0C2F6B00A6; Mon, 25 Mar 2024 08:46:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id AC91C6B00A3 for ; Mon, 25 Mar 2024 08:46:13 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6F1388017D for ; Mon, 25 Mar 2024 12:46:13 +0000 (UTC) X-FDA: 81935534226.18.CD40EA3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id C8957C0010 for ; Mon, 25 Mar 2024 12:46:11 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nBzjRhYA; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370771; a=rsa-sha256; cv=none; b=JOGL0jSU7B5joIfrVZ7jqrlOOO3IzUiRMg6VYofCM8KEjAVcmmQgp0xYUsqJNy5TwqXA40 sd5v8ZLB43CSAuhClkAYJvWVkZpB8E5vA3iM8N7FQ9iVAFXo79RSZqofQxzF2BKd4wFW18 j56iux7H6Gc+f/Pne73l1kUxpPARwu4= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nBzjRhYA; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711370771; 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=drZ8VsaKg2g/ZkhLYU7ItdOSAFvCMG+KJPpQlCmXG2Q=; b=X04zWDHNYQK955EpGHqBiq317kMC136Q/xvk1oU8ULjriv6o5MkGis99bndS9C+liMMNbX Ez5HgiXUd6K0K+IDbo7ea68cyjllnlgGA2pQdwKsHpGW4BmFV4jyE2JUTLiDOdZZR/XkHv N3F+AKzkup+yHiG9FPB9HV1OXZNtL4I= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F147F60FA6; Mon, 25 Mar 2024 12:46:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46A41C433C7; Mon, 25 Mar 2024 12:46:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370770; bh=iGqchiYFmo0ETruqN+yqTmLWs9IEH21XszhOvMHk718=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nBzjRhYA/s+ei3HHXwyi91lkTt42O7ifcVbgqgcEbQ6VgULgAXnG6f+FJB4vm7f7R hzX3NDEtbPSkPPHnwEteD3fCeKNlNNTm5Ak3Zhy8XEPfpjmCRSqPDgF+xVmlE376JH yq07703jv7pjhsHtZCQcCI6yvjhsoqaWJh3dHMTqLxgnIOZ8XPXWB2W93tD1/mCESJ tGgvR3enYDoFwJ3j8gou3N2SlDsfwwf1pgxPFDvC5L+WqHBK4Cdzn/1+dwCpaF+/TS LBssjlDr/u89yJ2CGBNIydvk/6G+d7mfRYX6p7ivRTY8ml7tJnYDaZlJ56a8fYf9Pj Aea9WXhpwo4XQ== 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 09/14] mm/ksm: Convert stable_tree_insert to use folio Date: Mon, 25 Mar 2024 20:48:56 +0800 Message-ID: <20240325124904.398913-10-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> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C8957C0010 X-Stat-Signature: 9ngdddfgu7t4j3izy4crtdsnsn5t4xfy X-HE-Tag: 1711370771-251077 X-HE-Meta: U2FsdGVkX19X+NK1w+x38cAdoDpp8hGfRhuNjilDL4ak7w/y7q0v/00M14vsnll5qFuWhT61ufLD0wpJbHCPJcrzEB7/2AHjSBFBbNQ6jQB3Lz+HMnWqLFHEax+Ix64R/SsxWUiCbJZJJoYG4y7iLfgs/6MBP7IAKs+/jV0a5IiCTBOrjklmjc4PyDp0c51fBJBPBlzOyhNlL62xU+b8OSV3ShL4IB8uz35YVpQ4+UEhAUArn5Jhu235ERN2RDb0vw037BK7MqKTqwQKvbDlEXS15eN6BPsCowY85uLdTj/J0FmTqJjndcD5kQ3KNk7t7B3bsM4Bjy7V9q1+aDdiZQHkdMEO0JfhHc5ePQG9AIPA1jUed6eVeccvVOxrPLc7aK7iiqUxNGNgQhu70pKI63JEf+/3s+bNPjvt5kpYWxYjTymvnIlRq3HG8Fcbz08fXwZ7vP6gLmi5fHiFkhfvPsOcKgMmSXTRMwCyWAvQbMLL2U98h19bryyCJ+ULuLoJufkQhtrnzBoVJLnMLa3l2b5LCxoFpjX0F462hAFRFsafCknHDMQQzCldhO8yJ29Gp1Yjl8ZHepu9Me625O+Q1Tf/gT8qouo8hww7oZ15loP2HaC2AkLB2wUl7msGhqfe7DJ41XZfWGGRQKfV67U2jn8xPH/Uklqg4xvJ37MuVRloAZrz0haVr9JjUuTHLX4MsV5iZP9ZG6VOv/RWpHXoMN/6sO0YKEpetVgDSfQHUmeOlhbD/3QiIsI8926q1LDJGZ6XVKDVZLdxKwOtEUtK4shQkr0Yg590bznonMnncBlfepFf0qVHypgFMXOms3A+VFLFt6f6zqpfehicFzHGXz+VBuXfLcwQGgmoJAC5kuIRaMklXI/xUcYIFQD0dF/WUS5EFJqvjAfZCEEwNvjeJO2VFP+zVrg7bYj9Y+9S7ivQVCvJ3ABq1eBDHrTwoMyrK6wHm3J60dIFHKroFSo 7QusBE5K /CNxUb6jNdRo0QJ3smyNLkAjYmQmYMDLAK+H7Q0FF5TB3AqDSXVBS77UYmsLiKOBZhOWUxr3JjuL8Ec+lULS2NEQGjnGFza/vuZN+W7LxVF6zD/1jtM9mAIUXHW5r5zPyg+Eeku1gw0JVYf2L/i0C8U7mxZEZazjqFTfQ87yAA2IEiEB/RWDqvaxHHSdcrVci25wJQ+30qOnvaMbWS0zC6KstTxrydXdYMDPcC7jWt1WJRDn1JUl7FpBVeAT4bcvU5eA3/QZGBi+JOzdv3eujgi+Au0XbIAo6nWxPTyX6WV+5dqHMdD+KVsV5fSvo6FHdvNr49Ebdy8zR2DXWce92PyJYoJ3d2qNg2DV/4sYz73dkfIwZRWC5xkf1lMzcD49quMsyzHax0Bs0aE4rDqcYsbJOxTBIwZxLSVsre0mxAJJ8TCc7vejGp3l4uQ8rgnH67dL93fievlNgnEbLlmMtiQemRaVg0ZXPizyg43tk29ziyl2JXNInSobbIWgOd6s6Y/ES 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)" KSM stable tree only store single page, so convert the func users to use folio and save few 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 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index 7188997437d3..c2afe2f926db 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -2078,7 +2078,7 @@ static struct page *stable_tree_search(struct page *page) * This function returns the stable tree node just allocated on success, * NULL otherwise. */ -static struct ksm_stable_node *stable_tree_insert(struct page *kpage) +static struct ksm_stable_node *stable_tree_insert(struct folio *kfolio) { int nid; unsigned long kpfn; @@ -2088,7 +2088,7 @@ static struct ksm_stable_node *stable_tree_insert(struct page *kpage) struct ksm_stable_node *stable_node, *stable_node_dup, *stable_node_any; bool need_chain = false; - kpfn = page_to_pfn(kpage); + kpfn = folio_pfn(kfolio); nid = get_kpfn_nid(kpfn); root = root_stable_tree + nid; again: @@ -2096,13 +2096,13 @@ static struct ksm_stable_node *stable_tree_insert(struct page *kpage) new = &root->rb_node; while (*new) { - struct page *tree_page; + struct folio *tree_folio; int ret; cond_resched(); stable_node = rb_entry(*new, struct ksm_stable_node, node); stable_node_any = NULL; - tree_page = chain(&stable_node_dup, stable_node, root); + tree_folio = chain(&stable_node_dup, stable_node, root); if (!stable_node_dup) { /* * Either all stable_node dups were full in @@ -2124,11 +2124,11 @@ static struct ksm_stable_node *stable_tree_insert(struct page *kpage) * write protected at all times. Any will work * fine to continue the walk. */ - tree_page = get_ksm_page(stable_node_any, - GET_KSM_PAGE_NOLOCK); + tree_folio = ksm_get_folio(stable_node_any, + GET_KSM_PAGE_NOLOCK); } VM_BUG_ON(!stable_node_dup ^ !!stable_node_any); - if (!tree_page) { + if (!tree_folio) { /* * If we walked over a stale stable_node, * get_ksm_page() will call rb_erase() and it @@ -2141,8 +2141,8 @@ static struct ksm_stable_node *stable_tree_insert(struct page *kpage) goto again; } - ret = memcmp_pages(kpage, tree_page); - put_page(tree_page); + ret = memcmp_pages(&kfolio->page, &tree_folio->page); + folio_put(tree_folio); parent = *new; if (ret < 0) @@ -2161,7 +2161,7 @@ static struct ksm_stable_node *stable_tree_insert(struct page *kpage) INIT_HLIST_HEAD(&stable_node_dup->hlist); stable_node_dup->kpfn = kpfn; - set_page_stable_node(kpage, stable_node_dup); + folio_set_stable_node(kfolio, stable_node_dup); stable_node_dup->rmap_hlist_len = 0; DO_NUMA(stable_node_dup->nid = nid); if (!need_chain) { @@ -2439,7 +2439,7 @@ static void cmp_and_merge_page(struct page *page, struct ksm_rmap_item *rmap_ite * node in the stable tree and add both rmap_items. */ lock_page(kpage); - stable_node = stable_tree_insert(kpage); + stable_node = stable_tree_insert(page_folio(kpage)); if (stable_node) { stable_tree_append(tree_rmap_item, stable_node, false); From patchwork Mon Mar 25 12:48:57 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: 13602025 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 751AFC54E64 for ; Mon, 25 Mar 2024 12:46:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C367C6B00A5; Mon, 25 Mar 2024 08:46:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BE3866B00A6; Mon, 25 Mar 2024 08:46:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5F5C6B00A7; Mon, 25 Mar 2024 08:46:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 90A8D6B00A5 for ; Mon, 25 Mar 2024 08:46:16 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 64382A06A6 for ; Mon, 25 Mar 2024 12:46:16 +0000 (UTC) X-FDA: 81935534352.21.21D1F6B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id A8D70C001F for ; Mon, 25 Mar 2024 12:46:14 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Dz0MergX; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711370774; 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=G/BHHnxF2+HS53kVpC8L/Km83UHVHT7XhuCqK8Fcp5I=; b=rOV69dfe9YpjkL8g5DW3FoKmblKfsTMiIsnvfBo6ODksIVlLrjOOj6bOgXHhuGYUwSRKpE tjfCZYZI+SceJq/lwn3/4KcquhaQl+nzmfxdR2+GMxpn7mJGIohMnD/kN1WbRL+ZDyZfAu gGll8ZkPRjjzjn9Ja+eDVrWkbX47eTo= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Dz0MergX; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370774; a=rsa-sha256; cv=none; b=x0TOo/4hkANnR41A+ObPfYYb+aZn7y71YnXiiQx0ug52h1eCQippw5zF7gKyXAoKnWc2F6 URCznBYPKh1qKu6zo1Ccn7gwvVBTLXEOy+QLZZGYqboFT7rUZOqIK8KmMZ/NxNyzDzjwUp wIpWZq+pzQaS+7CX8yjIQDle0ah5yqE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DF89660F8B; Mon, 25 Mar 2024 12:46:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40281C43390; Mon, 25 Mar 2024 12:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370773; bh=2lgvFI0wNn9RTCMEzEWib7Gn+j7luBL+Jg2E4ycFUf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dz0MergXwbNpE5qypVG9l++oEAh9GgKrjYVi2WZATBEUMf/h2vvKvfWuuN2rYay9Q mvBr0LRQln4jeWSRsqlLU8WM7vzf95ttjzjXBJIPtHyIR8fB+mcbA6L6yjQILNW13E EGLVB0l5Zlthhdi3jucQwfl7boWT3sAKrIJNV9XNKm1YRkYBe9NGv019lOFQyoxQuA 1IBBuXPnLgXvLTeau3NR1///K8RNQnj6GrTVhWQbmN6pYAV+qwXdZ2HD5AKz62NVjT KcjwNL2irL8wTYaKKGnUMzndCBL9R0lq+wEpVRtUACFl77GcxTnbkuJk6hE9dx6Hwk JDbfAotIewksw== 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 10/14] mm/ksm: Convert stable_tree_search to use folio Date: Mon, 25 Mar 2024 20:48:57 +0800 Message-ID: <20240325124904.398913-11-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> MIME-Version: 1.0 X-Rspamd-Queue-Id: A8D70C001F X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 73yageyx6kar45ewtb6xaw7qkzcscdcq X-HE-Tag: 1711370774-196901 X-HE-Meta: U2FsdGVkX1+46AS+RXz3B/Rnj+cis8uCeg4KrkIydefEgboJnIPIG7k93EFlHFRRgs/crwi8wCjFmzbr7N78q8D4ET1hNPgI+iEk51atNKWWsFEzpb/2DEv7KhQM9G91jloUFBctJpwl2Y734+v3naaXaLkZmRDkB6Kv+2CPXgmqtZadMjhzTzjJwCKBXNfOD3waQDodzkiCWEfzLqxWcJiRzw7cIRlUzGvCGUGRL8No/yZozqSpwObEu/aJ0udlSZuP/QCAt+dQdwA/XHZveEKOxVj1yIRmw9YmrAfEGPPd1YB/5sE/FezixYQ8KnypDgTGtvFPfaAYXuz/LLgjoye9531BrIrySMT2TPy39ifDF7LLUR5ZODVUusLvEuf8nav5B7kRTEwNPNzAs+de1PBytgaqqz8WYapQzQt/BHQ7thfPt51MiwgHOkBpSMzAsYiRzV1OvmK14z9f2Nm6E2/+/qdPUrlW+4qqqlSKey/o8kHIqV9Ld68IJeeb7owYBKs8bkLN2PJ/7QyQR9xLhcs5YxicVuCNS0UMAdc61B2pgELPw0u1NgOZgqtrc5bbdEUe/XnWNsvM4Jos1+TDNWQLc5PjAjhv17g+MwE8HvduNOJx8g2pA4sV8IdrlgxA5FxGDtV6pTTXaY3utRH2MoOLJR/ONa3XEXKmJbGSWRUlTrkWqCyL7BXW62yBWck9SMZ6BIwST+algT2lxVsimoQpLBIv2juJI29J3cPjhE112ysZuv9r1m7coHlehvMUUHym43ESeAY8lJ09GTLoDrrCDp+n9GtylbYfB1A3H/FIpJS2RmERZuR0sLSN0DPDP08c386zHymqPWg0kVkxXC9UYpHheNg81WEUO0u4MK0gq2PhmR/1U9TOhdcENIiKVYaKisOWv2J0NKJBDPx3phI0xGxGgym6sozAqOzE26cDK4I3Id6gPpywpVB4cyObqAwHWQ9bS06Sv6gIt6I yo+BjEJB uXjK/c727qhp6g+xzytModj2oaXY3gISxBnOuN0tprvEb97VdXblzsjWH7coHYCY6zBgYsJC+choQCWPwdWzSKpGMvr36BNNhWXTB4rVclJfoVoGhYD7pO6Z5zYa0Q/7g8qJVkZku1g3Z/mlYmUMZYWjmlQzEt++T032SrDN80vMPDYdN2cIqW6SdBr3iGxyxmqzp/+CgifkgqHRqvryfD0GXuPcUQi1qDi11QmEF+WD9b7Mo18z0NpcWPHb9gOoNTDQey4ORVIcO3psiaVlvlvsg35teweRKTs44gjOoo/IsOGfnmXKySrIX36q+Qbi3JwkgBnPFPu0CHgQppi419Gt8SepXyiFZ2E6UzWKh9Cn1VV/FcHapNUFYt+tEAB+Ln+JYAtEKA+0ZFnKwqhI9nhhH5PFMzi5cFjYuuHUBTekRGJx1SjJtOBECoI/jtVUtEFbGFUaNRy6VRtAjxFYq/60q1p2hTxbeuyb8znwJK3jzn/Xm3ZsQRKo+KxH5P96oKS5d 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)" Although, the func may pass a tail page to check its contents, but only single page exist in KSM stable tree, so we still can use folio in stable_tree_search() to save a few 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 | 58 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index c2afe2f926db..e92445f29685 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1828,7 +1828,7 @@ static __always_inline void *chain(struct ksm_stable_node **s_n_d, * This function returns the stable tree node of identical content if found, * NULL otherwise. */ -static struct page *stable_tree_search(struct page *page) +static void *stable_tree_search(struct page *page) { int nid; struct rb_root *root; @@ -1836,28 +1836,30 @@ static struct page *stable_tree_search(struct page *page) struct rb_node *parent; struct ksm_stable_node *stable_node, *stable_node_dup, *stable_node_any; struct ksm_stable_node *page_node; + struct folio *folio; - page_node = page_stable_node(page); + folio = page_folio(page); + page_node = folio_stable_node(folio); if (page_node && page_node->head != &migrate_nodes) { /* ksm page forked */ - get_page(page); - return page; + folio_get(folio); + return folio; } - nid = get_kpfn_nid(page_to_pfn(page)); + nid = get_kpfn_nid(folio_pfn(folio)); root = root_stable_tree + nid; again: new = &root->rb_node; parent = NULL; while (*new) { - struct page *tree_page; + struct folio *tree_folio; int ret; cond_resched(); stable_node = rb_entry(*new, struct ksm_stable_node, node); stable_node_any = NULL; - tree_page = chain_prune(&stable_node_dup, &stable_node, root); + tree_folio = chain_prune(&stable_node_dup, &stable_node, root); /* * NOTE: stable_node may have been freed by * chain_prune() if the returned stable_node_dup is @@ -1891,11 +1893,11 @@ static struct page *stable_tree_search(struct page *page) * write protected at all times. Any will work * fine to continue the walk. */ - tree_page = get_ksm_page(stable_node_any, - GET_KSM_PAGE_NOLOCK); + tree_folio = ksm_get_folio(stable_node_any, + GET_KSM_PAGE_NOLOCK); } VM_BUG_ON(!stable_node_dup ^ !!stable_node_any); - if (!tree_page) { + if (!tree_folio) { /* * If we walked over a stale stable_node, * get_ksm_page() will call rb_erase() and it @@ -1908,8 +1910,8 @@ static struct page *stable_tree_search(struct page *page) goto again; } - ret = memcmp_pages(page, tree_page); - put_page(tree_page); + ret = memcmp_pages(page, &tree_folio->page); + folio_put(tree_folio); parent = *new; if (ret < 0) @@ -1952,26 +1954,26 @@ static struct page *stable_tree_search(struct page *page) * It would be more elegant to return stable_node * than kpage, but that involves more changes. */ - tree_page = get_ksm_page(stable_node_dup, - GET_KSM_PAGE_TRYLOCK); + tree_folio = ksm_get_folio(stable_node_dup, + GET_KSM_PAGE_TRYLOCK); - if (PTR_ERR(tree_page) == -EBUSY) + if (PTR_ERR(tree_folio) == -EBUSY) return ERR_PTR(-EBUSY); - if (unlikely(!tree_page)) + if (unlikely(!tree_folio)) /* * The tree may have been rebalanced, * so re-evaluate parent and new. */ goto again; - unlock_page(tree_page); + folio_unlock(tree_folio); if (get_kpfn_nid(stable_node_dup->kpfn) != NUMA(stable_node_dup->nid)) { - put_page(tree_page); + folio_put(tree_folio); goto replace; } - return tree_page; + return tree_folio; } } @@ -1984,8 +1986,8 @@ static struct page *stable_tree_search(struct page *page) rb_insert_color(&page_node->node, root); out: if (is_page_sharing_candidate(page_node)) { - get_page(page); - return page; + folio_get(folio); + return folio; } else return NULL; @@ -2010,12 +2012,12 @@ static struct page *stable_tree_search(struct page *page) &page_node->node, root); if (is_page_sharing_candidate(page_node)) - get_page(page); + folio_get(folio); else - page = NULL; + folio = NULL; } else { rb_erase(&stable_node_dup->node, root); - page = NULL; + folio = NULL; } } else { VM_BUG_ON(!is_stable_node_chain(stable_node)); @@ -2026,16 +2028,16 @@ static struct page *stable_tree_search(struct page *page) DO_NUMA(page_node->nid = nid); stable_node_chain_add_dup(page_node, stable_node); if (is_page_sharing_candidate(page_node)) - get_page(page); + folio_get(folio); else - page = NULL; + folio = NULL; } else { - page = NULL; + folio = NULL; } } stable_node_dup->head = &migrate_nodes; list_add(&stable_node_dup->list, stable_node_dup->head); - return page; + return folio; chain_append: /* stable_node_dup could be null if it reached the limit */ From patchwork Mon Mar 25 12:48:58 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: 13602027 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 F08BECD11DB for ; Mon, 25 Mar 2024 12:46:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 114EF6B00A9; Mon, 25 Mar 2024 08:46:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 04BE26B00AA; Mon, 25 Mar 2024 08:46:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E07446B00AB; Mon, 25 Mar 2024 08:46:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CCF126B00A9 for ; Mon, 25 Mar 2024 08:46:22 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A1CB1C0404 for ; Mon, 25 Mar 2024 12:46:22 +0000 (UTC) X-FDA: 81935534604.18.95D1A5A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf14.hostedemail.com (Postfix) with ESMTP id 46877100017 for ; Mon, 25 Mar 2024 12:46:19 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=at0VDuHS; spf=pass (imf14.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=1711370781; 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=46nx9WN+IELbCOLBNTx6JiC62N+qW0GfiXNmj7LQJ80=; b=D2QBlIAsl9GiGau0RQ/GQQ5YfLnh0ORTqLciWoIeR1ZZuOWvG1kr0z7GBlpc6gEXTrdVoU /AiWNJTk9jearMY0VTk5S4Bqo8TnbPjLo4OYCR6EMWiFFe+tcDe9CHBcbZCgNlSdgiBx1K aHE3ba/Dhyj1GdOvpFLAMA0j0zKXQFY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370781; a=rsa-sha256; cv=none; b=Ad2i42GYXARAsg6/34EEQeoFby6sLuRKzyOzJA13ouA9HoT6xMpSTAR4FMMAr2Oq3KZSiM ZDlhraC5Hv2HqgIrZeAgYL82VHPbZCRTVcCPvOV1lxZsUwW3/LuwEeUE3tYqHu4gl3WXZ5 tzp8n0lQhcm4VdRmx3H8iq5Zz94NT9U= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=at0VDuHS; spf=pass (imf14.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 5999DCE179C; Mon, 25 Mar 2024 12:46:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 457B1C433F1; Mon, 25 Mar 2024 12:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370776; bh=wVJDweO+3+nZNvpdxD1sOnabgczsKGATc/r/G9PfpiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=at0VDuHS1UFGvZa2neZdLri042ZbLa6A9MUgGRBNE5qGfCI2bODuBIA+VXldGpWmz AzJe9wHMcmIBUbmnO5/pHRIsv/Q/o4PcTWzYXvcIpEEIuGuXBKeuXRMIutXAYCR1I3 /0LHpeFZ6sCQ+Qk8HwfLlumd0YNfJHFmIrE72awqDsW8FNVinqkiaFLuaQswCaZFxq ewFRlvWp135MbtvT4KguhzgPncItoNY2Twe1cufEpby7VJdZTZNedABe6Vo7sqMiCF swfeW+jnM6fzay7hnPM43ksTBiWNp3G9ZwFMuxYPKn2m99dxG82erlMJDDYcuPo63N dtMH7Lhm7e9Nw== 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 11/14] mm/ksm: remove get_ksm_page and related info Date: Mon, 25 Mar 2024 20:48:58 +0800 Message-ID: <20240325124904.398913-12-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> MIME-Version: 1.0 X-Stat-Signature: geqbxsn6uod7r3n8sh1eh9jyinccqamd X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 46877100017 X-Rspam-User: X-HE-Tag: 1711370779-585327 X-HE-Meta: U2FsdGVkX18dHfl+4tCm/1VBQzjm47ROvbRGWCenLsf2aQvVDYZ/7pZooIvD03qoV85twgG/IfX8OzBsxu79glRVZipnxxBnU/VPsynzq05OLg1420MBZZfrR7pGHk5rd1ydp/P4Y6JV9QwP43YwgjwutvrigFhnNBJzzb8NoS9/j6J/qVbSkzGttuSdrK2MseCPQ2fowIuSx/JQWldUwwuYlpGPIk2mIhLFBo7scsAhpFDG1XdpSaNNduy9v2qbdMWKs8nIe6oRfOUZC9W6rGI+kJOBWf4ove48nkAKBJlZ9l6hKlxTLd8nQBROYgGqch3iyzUuna7D62mcn7gOTIZYjtSvzDD7kq1jgnX0aeOmKwm5C60w2/3Y5dAn5bblqKsvfhDAELWeiir8+5eyKQvwrgcLxW80ljZZAmSiM6qbpO2GBPUUYpDre8I+mxpWglWtzMY+8YAyA6qsjl4aSdrQVmzQK8z86RMydLnw1o97tQduvq1Urr00tEoD11LO2AgarfxipQd2MofqMxdMu0XjX4E2c6ORShobYQHNveEYs1+Z8hilJr6JHf3+Gd4F/Y/mfgIS25mD0Uv4ZCmgal4XL+0/F6FwC2+omK+yRjuUL+FITjc1A3aKEGd+FMEklYsAv1tBt4nuUrGJeoG9OkCO6xRjK8+WxQ8mF9Il9eq900JgEZeIDAukRajsYsmDEv14NP3OGSIfvFcw3ES9SL0ZXleJH3o8oEqhHOnbKcs52YY67kg/Q1NhuejbCF28tMUM0W41ctHySl7Zirx7THf0ekHenILnW7IBghXjOLEmc9mz2zbLnscacVJE0UvCX3vkYCxUwj5Z2iso777r1/Tbs3rFprfyyPm4s/qQYCuWiEZsvsrxum2xtYNZKvehUPsh9yWLbF++sUCOhNANBUIu/GtLP9iuck6Ao+S3Ht5+zlE+o7gkqWZZukXBziOnqjaOjFhJcrhfw0yJeFR xOnC9gK3 fFTepZPeUtVpPnM2RccLawA+9IJt9DWekUUv0+xmetmca4t5E8ekoKB0sOKWf6NyMnp8bvYvUK7DXJYNFJp726eGpZnx4Ds6cdpo3wZGeFKoxYMs2KRZy8pfWz/mcndBkdNJlCaloOVZbVUPsHZILCixT4mK4kteq0w0Q+1dXNsloJJk32mOx2qlxXeEDqX79XhEEoiRM6G+bW07/GzkBNYYwTfm7NCRTcUJma1cqbW3pz68jXpoHPlSqhob3U+57/SF7V707SWlpnn4Ot9ejzxyX7Sva+spFhShadG3nA/PJrKL15AXe7z3i3rcMmgkQ28aerRg8nRKAo922YiQBHnw+ODiAr66++yAed+z/mjoiMPIbaDVSQUpHRmcRZ0us+wmUlfpb7hQTJRj47MngVcQa1sd4ocqCKnRb0Ujf+ozReYD0b8a/NvQHZQJOke7GpBMv7B9jrNBtJEPbx+vBd7xyWKEZLwnfPjPi4O5MkuckQY+Mk2o0lKZam2Sn2FiVL9pj 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)" Now since all caller are changed to ksm_get_folio, let's sync up the related usages with ksm_get_folio, and remove get_ksm_page. Signed-off-by: Alex Shi (tencent) Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright --- mm/ksm.c | 34 +++++++++++++--------------------- mm/migrate.c | 2 +- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index e92445f29685..0ad02524e363 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -890,14 +890,14 @@ static void remove_node_from_stable_tree(struct ksm_stable_node *stable_node) free_stable_node(stable_node); } -enum get_ksm_page_flags { +enum ksm_get_folio_flags { GET_KSM_PAGE_NOLOCK, GET_KSM_PAGE_LOCK, GET_KSM_PAGE_TRYLOCK }; /* - * get_ksm_page: checks if the page indicated by the stable node + * ksm_get_folio: checks if the page indicated by the stable node * is still its ksm page, despite having held no reference to it. * In which case we can trust the content of the page, and it * returns the gotten page; but if the page has now been zapped, @@ -916,7 +916,7 @@ enum get_ksm_page_flags { * is on its way to being freed; but it is an anomaly to bear in mind. */ static struct folio *ksm_get_folio(struct ksm_stable_node *stable_node, - enum get_ksm_page_flags flags) + enum ksm_get_folio_flags flags) { struct folio *folio; void *expected_mapping; @@ -990,14 +990,6 @@ static struct folio *ksm_get_folio(struct ksm_stable_node *stable_node, return NULL; } -static struct page *get_ksm_page(struct ksm_stable_node *stable_node, - enum get_ksm_page_flags flags) -{ - struct folio *folio = ksm_get_folio(stable_node, flags); - - return &folio->page; -} - /* * Removing rmap_item from stable or unstable tree. * This function will clean the information from the stable/unstable tree. @@ -1127,7 +1119,7 @@ static int remove_stable_node(struct ksm_stable_node *stable_node) 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; } @@ -1140,7 +1132,7 @@ static int remove_stable_node(struct ksm_stable_node *stable_node) err = -EBUSY; if (!folio_mapped(folio)) { /* - * The stable node did not yet appear stale to get_ksm_page(), + * 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 folio might be in an LRU cache waiting to be freed, @@ -1657,7 +1649,7 @@ static struct page *stable_node_dup(struct ksm_stable_node **_stable_node_dup, * We must walk all stable_node_dup to prune the stale * stable nodes during lookup. * - * get_ksm_page can drop the nodes from the + * ksm_get_folio can drop the nodes from the * stable_node->hlist if they point to freed pages * (that's why we do a _safe walk). The "dup" * stable_node parameter itself will be freed from @@ -1764,7 +1756,7 @@ static struct ksm_stable_node *stable_node_dup_any(struct ksm_stable_node *stabl } /* - * Like for get_ksm_page, this function can free the *_stable_node and + * Like for ksm_get_folio, this function can free the *_stable_node and * *_stable_node_dup if the returned tree_page is NULL. * * It can also free and overwrite *_stable_node with the found @@ -1786,7 +1778,7 @@ static void *__stable_node_chain(struct ksm_stable_node **_stable_node_dup, if (!is_stable_node_chain(stable_node)) { if (is_page_sharing_candidate(stable_node)) { *_stable_node_dup = stable_node; - return get_ksm_page(stable_node, GET_KSM_PAGE_NOLOCK); + return ksm_get_folio(stable_node, GET_KSM_PAGE_NOLOCK); } /* * _stable_node_dup set to NULL means the stable_node @@ -1900,7 +1892,7 @@ static void *stable_tree_search(struct page *page) if (!tree_folio) { /* * If we walked over a stale stable_node, - * get_ksm_page() will call rb_erase() and it + * ksm_get_folio() will call rb_erase() and it * may rebalance the tree from under us. So * restart the search from scratch. Returning * NULL would be safe too, but we'd generate @@ -2133,7 +2125,7 @@ static struct ksm_stable_node *stable_tree_insert(struct folio *kfolio) if (!tree_folio) { /* * If we walked over a stale stable_node, - * get_ksm_page() will call rb_erase() and it + * ksm_get_folio() will call rb_erase() and it * may rebalance the tree from under us. So * restart the search from scratch. Returning * NULL would be safe too, but we'd generate @@ -3245,7 +3237,7 @@ void folio_migrate_ksm(struct folio *newfolio, struct folio *folio) /* * newfolio->mapping was set in advance; now we need smp_wmb() * to make sure that the new stable_node->kpfn is visible - * to get_ksm_page() before it can see that folio->mapping + * to ksm_get_folio() before it can see that folio->mapping * has gone stale (or that folio_test_swapcache has been cleared). */ smp_wmb(); @@ -3272,7 +3264,7 @@ static bool stable_node_dup_remove_range(struct ksm_stable_node *stable_node, if (stable_node->kpfn >= start_pfn && stable_node->kpfn < end_pfn) { /* - * Don't get_ksm_page, page has already gone: + * Don't ksm_get_folio, page has already gone: * which is why we keep kpfn instead of page* */ remove_node_from_stable_tree(stable_node); @@ -3360,7 +3352,7 @@ static int ksm_memory_callback(struct notifier_block *self, * Most of the work is done by page migration; but there might * be a few stable_nodes left over, still pointing to struct * pages which have been offlined: prune those from the tree, - * otherwise get_ksm_page() might later try to access a + * otherwise ksm_get_folio() might later try to access a * non-existent struct page. */ ksm_check_stable_tree(mn->start_pfn, diff --git a/mm/migrate.c b/mm/migrate.c index 73a052a382f1..9f0494fd902c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -616,7 +616,7 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio) folio_migrate_ksm(newfolio, folio); /* * Please do not reorder this without considering how mm/ksm.c's - * get_ksm_page() depends upon ksm_migrate_page() and PageSwapCache(). + * ksm_get_folio() depends upon ksm_migrate_page() and PageSwapCache(). */ if (folio_test_swapcache(folio)) folio_clear_swapcache(folio); From patchwork Mon Mar 25 12:48:59 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: 13602026 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 CB257C54E58 for ; Mon, 25 Mar 2024 12:46:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5CB166B00A8; Mon, 25 Mar 2024 08:46:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 57B636B00A9; Mon, 25 Mar 2024 08:46:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41CF96B00AA; Mon, 25 Mar 2024 08:46:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2E45B6B00A8 for ; Mon, 25 Mar 2024 08:46:22 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EDDEB1C04B0 for ; Mon, 25 Mar 2024 12:46:21 +0000 (UTC) X-FDA: 81935534562.27.DA79120 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id 4CA6AC001C for ; Mon, 25 Mar 2024 12:46:20 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Rff8wy/g"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370780; a=rsa-sha256; cv=none; b=ZZ7IB3O9/D9N1y3BV90Ya853ywI1fC+/V1N+PJ5qw3PIssbNR1CeB8ioWTmIJHdlUADp9Y skLe6GzGm0fxCIvdyLhlHgitjgSZrtnA+nc3xYNRtqIjy3w+F0LzSf4196mEvNuVr5OHkU vnI8aBvXaL8fwSQ4UazfquYy+JdeEu4= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Rff8wy/g"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf10.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711370780; 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=Su+w/May3HQEw0sTqjdP5gpPsA6SjVZVsA3paXcbads=; b=rkTO8uvSv6I3I0Evp+5bB5OejaML+yaKFJJXcwbCQtXbXOV5e5NE3pbrTtxsjSlAkc0Piq iKp/ge2pnaN8jHaDcA5gBWfSqVIoBf2RIJWnvQAuCRk6Zx3Ook7FtS0Xv9lKizQVU++2bH vB3zqniZdYScDAulHc7YXkygA6sk8HY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 95CEB60DC4; Mon, 25 Mar 2024 12:46:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38D82C433A6; Mon, 25 Mar 2024 12:46:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370779; bh=arZB3IpTCMJ2LTtZkVucxq3hez+AmaxlVxPKhMFKVEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rff8wy/gttXaTtUeASAh+hMee0l3Szue+pd80LQ7k9jBYU7wpVMjckiX7PPi/CCDY JmtuOZ96Z9NiUesHdgS7I/17APw8F8a6shAI8Hx0MOMOvcotCH045NHl0562JFdUyM uR63wRqfAstz1MfVQh4UgDxGwrvMYSPNgwH8m5jXkWM2VQXmwhd81SQ4FTsCp/J4Zi ASIM7LKrdIOomYptlMN/ZXGzrO2+KbvRDrzVxpWKq6zTzqlN44ppN7BDBeNUcjUeaf +s7Q5kySAFuGKdy+Puod7mj35GfQEifImvDyWAVmGQxwyF0PB0kNQk7JtWv3EfKXTS QBdN/da9IUlNA== 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 12/14] mm/ksm: return folio for chain series funcs Date: Mon, 25 Mar 2024 20:48:59 +0800 Message-ID: <20240325124904.398913-13-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> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 4CA6AC001C X-Stat-Signature: w9h388ecxnm641g8bib6f8s6c18ruosj X-HE-Tag: 1711370780-602171 X-HE-Meta: U2FsdGVkX1/gV0hFw5patbAFY2e9QPKRcRKuHJm8LeFYegibSyvOPkd+j0YupyH1v0SAF61d9SpztKaxbyQwYBZM5zwZnFT6rrlA34ttXkVVB9cJPOy2pQ+Dn3sDnzEMqBLsXL5g8F3B9DntERanU8ml7qHm9uriryFSgl/eiN8Q5Hstso1dt75udKm6sq4k5bUkVNG0C+zmB4qnVkPjAlxB5pI36zZtEVwkj/PdGYz5VDcp8cnhO4KlWqp7m3KcRVZY1V8bDUDdUzHn86QcHAX6Hi2I7YVhH8QSuZzh++E2jhz5ZgoxC2lmp+8UwnppbKKhe8PAZixrlLAsgRrL7A1WfyJvyQnWVm+Jjfz2uFERqbjEpVI/zxcwM3yRfFlYfyfxhYrLC27DrZGD2iqjQZR/SwFks2BmU/GsbM0tYY0Vc/TXkwc/8I/FvfdiNmij97qRQXjwz+k0sK4/cQe8ZT+hVA4pT7BwIpQF2MNB2b1qARlgT6wv1H45MotwR7teIcXCZzGa9GX4yRd8nwzkTO7ING9qwjkawczdvKXIbksjMeYvk+jNUhCec4Vbgct1lV4M/IZPPNr37FaPmG+RcneG21sgYWL0x7Zi70yp51XVuu9FVb10K6jSFhXjseTrBWHtI3ujo5dZVZRzVRSHYvhJNMDpyIkarufSpaYKE6wwzJPcWgzI78MFfg6UCYvbLWKf7+olewrakxXsv92mIm+LoOYs0WfsQrwy++w51MHQ33aFWUkJH0J2NzrZORfX7/PwgGBMigqKvhOzuTRg1GRIhSZ5HhH4njXVoCscJiagUyTZnmyY6j3/elD3y3dE3itEgpKN3nJGYjolgD1FInq40I85LVQajdirjpaCieAApQjMOb53yi9EW9HOrlo0YToqpn2Nrfyk9wutMkwV71LDjU0gb+BXtimnkvIV+owpqHA4NnnyEXByLM3k6f4zE9jLwwJLUviycyaBxLp TaVgjqLw pOo4gbi8MRGqiZ7BzB+hAlfS0/0enQkDGrhBgCIChuUpf2jjlop7Ej6hO61UJemdxnlXBokVBai5OZSDNkTAFyBtMGwz0CQzGPJxSl3TTY/bqQetoPQjfL8pKboD1SBiqi4oQdwafoBzZStQV+GBdp+VZwaqzbCG1o/6d5ucfBX4TK79nuWDOXTKhuilZBM6oGPGhS5Uj+8wy0+/KF+mpwLMG+S1qUV/OM3qzLG4RVsK56GKCDLdV7Kr6NA8kNO1dS1iYVgUwEk+8o3Wx/qL4O2sKxtDh8pVqLTMXrWC3ZGoiHQayL23Rd/rHxsfv2DVKQ0TGPWKDYmP+uZxX5gtYvIFqEH8bswbmdFSa2+9ak17to5JxPDoLdPwqbvXts6pn+xVcrKGxNTum8jSXFYEjvmQI7dfE/N8RC3dcC0aGy6/MSwYa5W4yvhairPAj5eLI6MoC0txElnQD4UE= 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)" Since all caller changed to folios, change their return type to folio too. Signed-off-by: Alex Shi (tencent) Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright --- mm/ksm.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index 0ad02524e363..15a78a9bab59 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1623,10 +1623,10 @@ bool is_page_sharing_candidate(struct ksm_stable_node *stable_node) return __is_page_sharing_candidate(stable_node, 0); } -static struct page *stable_node_dup(struct ksm_stable_node **_stable_node_dup, - struct ksm_stable_node **_stable_node, - struct rb_root *root, - bool prune_stale_stable_nodes) +static struct folio *stable_node_dup(struct ksm_stable_node **_stable_node_dup, + struct ksm_stable_node **_stable_node, + struct rb_root *root, + bool prune_stale_stable_nodes) { struct ksm_stable_node *dup, *found = NULL, *stable_node = *_stable_node; struct hlist_node *hlist_safe; @@ -1739,7 +1739,7 @@ static struct page *stable_node_dup(struct ksm_stable_node **_stable_node_dup, } *_stable_node_dup = found; - return &tree_folio->page; + return tree_folio; } static struct ksm_stable_node *stable_node_dup_any(struct ksm_stable_node *stable_node, @@ -1769,10 +1769,10 @@ static struct ksm_stable_node *stable_node_dup_any(struct ksm_stable_node *stabl * function and will be overwritten in all cases, the caller doesn't * need to initialize it. */ -static void *__stable_node_chain(struct ksm_stable_node **_stable_node_dup, - struct ksm_stable_node **_stable_node, - struct rb_root *root, - bool prune_stale_stable_nodes) +static struct folio *__stable_node_chain(struct ksm_stable_node **_stable_node_dup, + struct ksm_stable_node **_stable_node, + struct rb_root *root, + bool prune_stale_stable_nodes) { struct ksm_stable_node *stable_node = *_stable_node; if (!is_stable_node_chain(stable_node)) { @@ -1791,16 +1791,16 @@ static void *__stable_node_chain(struct ksm_stable_node **_stable_node_dup, prune_stale_stable_nodes); } -static __always_inline void *chain_prune(struct ksm_stable_node **s_n_d, - struct ksm_stable_node **s_n, - struct rb_root *root) +static __always_inline struct folio *chain_prune(struct ksm_stable_node **s_n_d, + struct ksm_stable_node **s_n, + struct rb_root *root) { return __stable_node_chain(s_n_d, s_n, root, true); } -static __always_inline void *chain(struct ksm_stable_node **s_n_d, - struct ksm_stable_node *s_n, - struct rb_root *root) +static __always_inline struct folio *chain(struct ksm_stable_node **s_n_d, + struct ksm_stable_node *s_n, + struct rb_root *root) { struct ksm_stable_node *old_stable_node = s_n; struct folio *tree_folio; From patchwork Mon Mar 25 12:49:00 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: 13602028 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 9F0A0C54E64 for ; Mon, 25 Mar 2024 12:46:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 559446B00AB; Mon, 25 Mar 2024 08:46:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 506EC6B00AC; Mon, 25 Mar 2024 08:46:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 381346B00AD; Mon, 25 Mar 2024 08:46:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 21E916B00AB for ; Mon, 25 Mar 2024 08:46:25 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E0ED8A02A9 for ; Mon, 25 Mar 2024 12:46:24 +0000 (UTC) X-FDA: 81935534688.29.764CCF2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 4953940010 for ; Mon, 25 Mar 2024 12:46:23 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=R4e1gCa0; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711370783; 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=TfVtUpv+bViU5SEY+5vl7RzuFH++KFzflA9vTjEeuyc=; b=h+Hdye/l8cDHzb+vok3my4tAufoPVguZdfvQoSARGT7hhhI531m5Bfxwt9/fRKqqn7QAQM qpKdVX80iYTOTWLUpEgMnD8LWEzpcTBVZNNCjxNR2s53ozEnyjcicRLa20+ArEPtr6lTZU Oc4+i2bOYHAZJgZZbqAL5S8M9bfVrgs= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=R4e1gCa0; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370783; a=rsa-sha256; cv=none; b=QhIjS/gNyT+HbAF9uBuhkVYFL1yhCUGpKNAk/5qv+WuZvXaYEwfLboeyYK8FQjgKJuJSOO Sq9Vd7QIbiAEo82/ydQqQ+N05YK4Ljok6/yHOBLK/hhmK3qJSbasowZl5fWZeuOo2VVSee Qstr0Ormf2qPlcG0gNd8+F7X+amG3Vo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 8B09C60FA5; Mon, 25 Mar 2024 12:46:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07108C43390; Mon, 25 Mar 2024 12:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370782; bh=ZriKAGE58KVGgk3LtHqsYBhdOJzv7LI/X6J606D1xxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R4e1gCa0XXthXxDX1BVjSpCwAOrXN3yXEnOKgM7VQzdWV57yKkfcA6jTRuemNBpPk cB15ux/wXrKv9yHhvUufFYr2882U4OjiVTCQGdfIigsmAadPt7KopB0roJ8VFftt8a ui44vFdFuoIKw0rV7d8UOx42w2pV8KnpkkqT4L/pnhwDAT6g4KoPWYmZB8HemEl3hU bkNVVJKYJ6yao6nAcZx3Z4aDvnCRwp/dX041t87HyEv3ahSuOCQwKWNtjXiz/IZKxf F5ssZsBvG+eP5J/A2c32/8//4yXzJ6pe4Wgcr9nhm1SbFY4WMaTTMJVug1bcTPZTb4 EgwXN9kXAKISQ== 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 13/14] mm/ksm: use folio_set_stable_node in try_to_merge_one_page Date: Mon, 25 Mar 2024 20:49:00 +0800 Message-ID: <20240325124904.398913-14-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> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4953940010 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 4a9oi1a8cmkqbm8xe9fdgzousmzwznpd X-HE-Tag: 1711370783-905798 X-HE-Meta: U2FsdGVkX1/aBqPzD3bJsQSzMzmED2skW93T953nI286YyodMnLN+T/RD2v/f4XhR6Wv7Zy9QE/vj2v9d0Sqijb/MGaqR12C7IgSoFQ9KYR7Nk7eQcfs1Fo397Tr1HqrT6gqUhHFxnflednoK/EWct34XV7HkLHKWUV/F1gnL+p5s039izQBytoW6XY4TqcR0cN8wpUa9AYyqoQOUzFR3Z1XXL58DauT9Y1406Vx3MildyiZgHR2VnlsPHeLLZkpzDCkv+GlBdqWRLcO5pqQiGYGu2yRd8usPu016ZukQ9U66ooybSeljC1dvf3HXnyMEap6aBHYBBUmB+9XN30/R6Y5tCCX04WFENGEoYTY0D2/MqZehydIrv7Qu7pDOTaL/qSe53RywwJiUdt/33zyvMvbr9Bl0TVuGRjtqV7Mn0lgN7Vy6+orm6HDD59wdMTDNDwBIPzJmgS00p/EyJH/fp4FLmydnqWs1Zeow/GY7sIwQNgxhqy8KeABcjCZCvOaXF9SOWFEsFBSof3+pp+USoi+9xFfzcbv6DEqOB8pbRfK+1vBsmrUIvVSDpfut9yn4wxBkc3AgG1XA805yp99+xaEuZuZ3IGGKjadD82YUEjOL9ul4TxVb209GeZsmdV07xcH4CSbIb6R8BnKcKpCQZpczjYzLFDfubEqgQ7yRzXXvGiB3Oz3GGzhNM9jqBb86w3GXF52EhQyJkY+4tLHxrFCJplX8cfsUsDa/7dzknwD1UUfrdSzRoymyiGGFpgLq947pp4HWw+WCX6GwQ8OdbptNr4SUMdjNCZnDK/1d8bHmLEGF/KkxqpHqSK3Z2FTjWcMoPOlVMqfht1BC99U0JyIwSjEvSbP18wCA+c//QCEV2XHUz+gH/BUQm0O4r+Q3ADXt4AOXGrJfPeXk7IKZEnJRFFNX/vTkenSCwd4QroNKKPKn051zp+XRDNqd1VVp3TVgEPjFvhvysnWti/ O91kxslp jWpxZ 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)" Only single page could be reached where we set stable node after write protect, so use folio converted func to replace page's. Signed-off-by: Alex Shi (tencent) Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright Reviewed-by: David Hildenbrand --- mm/ksm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/ksm.c b/mm/ksm.c index 15a78a9bab59..d7c4cc4a0cc1 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1518,7 +1518,7 @@ static int try_to_merge_one_page(struct vm_area_struct *vma, * PageAnon+anon_vma to PageKsm+NULL stable_node: * stable_tree_insert() will update stable_node. */ - set_page_stable_node(page, NULL); + folio_set_stable_node(page_folio(page), NULL); mark_page_accessed(page); /* * Page reclaim just frees a clean page with no dirty From patchwork Mon Mar 25 12:49:01 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: 13602029 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 A69F7C54E58 for ; Mon, 25 Mar 2024 12:46:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35B4C6B00AF; Mon, 25 Mar 2024 08:46:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 30BE66B00B0; Mon, 25 Mar 2024 08:46:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15D7A6B00B1; Mon, 25 Mar 2024 08:46:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id F19AD6B00AF for ; Mon, 25 Mar 2024 08:46:30 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D30B01A016D for ; Mon, 25 Mar 2024 12:46:30 +0000 (UTC) X-FDA: 81935534940.28.4EFB948 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf24.hostedemail.com (Postfix) with ESMTP id C547C18000C for ; Mon, 25 Mar 2024 12:46:28 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YvNscglB; spf=pass (imf24.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370789; a=rsa-sha256; cv=none; b=GE+9bM205Cv849EfgMSXTmReplUqbYvVA6KPlhjWTb3MuYMYYfAb/fDogWhP78aNcITMZ4 orH2+jvtlM8buKukU6FTiD6FRu1LTzXc7ZBszJDHEDAQrr5Nbl4TAMmG4VN9LJ8rjTzQtL x9Gp61EoAccW8GGEGl/mmZr5rRcx8lc= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=YvNscglB; spf=pass (imf24.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=1711370789; 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=R1OQtnh64xl9MrWkPZdL6QeNOkhw3aaTLSRXVdWp5+8=; b=RAlk+bCFNA2U1Tk3Oa8QcHNgCGpoN/m9aLoW/oLldiOYkXk7mZpG1B2NIwhnp1qY7HmRr1 rj0ekq985ev/XWg3lVkiD7G01ay1dPH2CQjUpnEkmFr4kSeXQN2Pi4TrJk44WuarMIhucm 7mbSlVvCOzg9QrZe48ZJARISDKRUFP0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 1C7D8CE17D2; Mon, 25 Mar 2024 12:46:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9A90C43390; Mon, 25 Mar 2024 12:46:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370785; bh=S+tu/Us/naajLYwRUmTRqpD4Xo/mrCDuxEPxhqR6e8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YvNscglBOtArFIziHJISGyWfpSQgvEjzi2V85RJigyMkJAUyjE4z1ReQJ/PIJSSXK fnB7wj6WL/CVS9I7Oeg6UH7+80lg/zNhOGX+YNQlKNlh2LmFzlLW7BkoYIvYvEpQds Uccm1d6RduJh5VK4zvtMgDW9YJKv7K8+0fskz7o1dBrAFz2AGE2B6pjndW+KT6PwEw UTFfg2NyGuFyG20oDXmM0LrLWcuLmLpRPAIPk7dUgiYvCpFV515hW6hEWgKf8Mo1B0 WrSjM/A2arN5eRndkDsjXZTbtHZX7K7WUe9EhnDP6M7JmGydKPrrRDCRq+Tpo236Co Q3B8ZPqKqhPBg== 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 14/14] mm/ksm: remove set_page_stable_node Date: Mon, 25 Mar 2024 20:49:01 +0800 Message-ID: <20240325124904.398913-15-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> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: C547C18000C X-Stat-Signature: bfpq8gsph7uemjb6eg9q9o3e53heqy6c X-Rspam-User: X-HE-Tag: 1711370788-746044 X-HE-Meta: U2FsdGVkX1/Jvlpz+oaz9VCnX6uEeO5qZU+IuJrVoQIxHJHJ++1el6l6ScNiUggr6E7u0eSQRSXHpXrTWquB1rn7v87CpT9NGHpmj+d3de/WAaKcy42hcDeZm9Gzf7Rf7yn4ezZENVgDSS38BMr1XwoC26vug34q9VomJE0rdxcIaUE3gGaWSUWcCCEe8QEPiwBE1Nr+BVaLUAfRYQgqA9GNdrsH3BmqeuxjkHm0o//wGN+NCwue1dXipu7pJc9cPr5fdSkoLC0xq7sf8aqeAjX0wQieY1sqgA0O39LtaxcPy9Ou4XkizoAeZngcT5mY1FABaG+uGTqdTo/VLE59O6Xbjzlyv4UlQ/A0BwGj2ozMtRb7M6ofhyjkl/6kXdRfyMduUiGB73J2JeheMTL4bQ3k8Pwio5/Ifcp4XMg7NMpL9GhYgcsztSU8V1nrikx8ua3nV0vYNzCgDFFJTMZTcKDynmBbjW/inOfvc94CpCodnJua8nqZm9MLh+O0T9Q/eMBHdlrjon0r6kzn8vzTp8ss3irAE0q/MxzsAh10AqXOHggqiPyjH9jhL7P0k8133vDvJWtFn0fl6f0eIEVF9KLyE/6JHudIyiMZtY27CQGvokcumMYtSYvvnK4sZWeQg4XWc0sExGDoHKvHcfy/AFDDB/+CX4FYhSU9J22QCQ6qhMV1gJXBC58VYcaXkJGU+NkP5awyhRZrHTtniIqGmGEa+TITAnKUDzCjck1MIBJiecNY3xsdthO08rTqPvSKziwEHpOaCns9QRXiNjGKhNKnPcDMTIEsWYq/xfK6f+qqDjXlnKNFcme7p69IF6fBrbZs0YGTSVdTCQPLY/kqS4J80Ru1ae7zVsJo1dVmy+pDnN3xUzbdE0yF2n5uzMxFghNNaJYdvzzHkzVeLuXSOFLh/vzWjZ7xIUBIgLmcvKaCZmlJjlhbViast/mQS89+Vok3sSsI5WqOKeD/za/ aKi20JAE eaEDqq73tr1hnUHbsJExr2Xfaw9JY8lW8l1PthTt9mnKrNxlIe3QoF4xURD/FqUCcZXb82qapzFbofYxYGkiCh0t/K7OX7ekZEmu9L9vrSjnnHE8wyEMCb0jHpATB9bRLa3BKmy4EvksNopCLuyx8sl4qAYIC16C1a90Iy08FRcZYZkRJOJvZibC3UHx2Un5Z8gsFa2IdIPxsXtp3NKfpXj9ECwYtT6imgKO2eEBrq4xv5tQkgMO+FJQsb5AQbGU0RmhzeTIzPLH7VNnK11yhNy1+tFARjiZn8oxLI2qlaxB70ejPkNRzpB/J80dq5XNaYF9r5eJvXbV/30RrGqRHPp3xCiJX6LzBn+KzUhggdkn2m8yaDvyKMm1yhR5A8w4t4xgbP65OqT1OvZ8MbbHg5khPuvLVL6L0CxYmLBsmR7njQhWoI2btoGVFR3x3FP8HULln5+mrFPy7akmsb6B/cYN//r5s7Sg8GzzKgCDL1rJCe/Ko1MGp9rddm8Iem8m/8kiZDJEhvUiWh0fOWLromXhL9UQw0jZq+KOQ0nNM90xI93gL51CwgCZSIDXR9+TFo5TavvIgyy2nJlFnEwjGC3MFM9+c5QGQ4+ORlDaKpb0sIaEu5ozfZs9Phw== 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)" Remove the func since all caller are gone. Also remove the VM_BUG_ON_PAGE() because it's not applicable for a folio. Signed-off-by: Alex Shi (tencent) To: linux-kernel@vger.kernel.org To: linux-mm@kvack.org To: Andrew Morton Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright --- mm/ksm.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index d7c4cc4a0cc1..136909f0c5d5 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1094,17 +1094,10 @@ static inline struct ksm_stable_node *page_stable_node(struct page *page) return folio_stable_node(page_folio(page)); } -static inline void set_page_stable_node(struct page *page, - struct ksm_stable_node *stable_node) -{ - VM_BUG_ON_PAGE(PageAnon(page) && PageAnonExclusive(page), page); - page->mapping = (void *)((unsigned long)stable_node | PAGE_MAPPING_KSM); -} - static inline void folio_set_stable_node(struct folio *folio, struct ksm_stable_node *stable_node) { - set_page_stable_node(&folio->page, stable_node); + folio->mapping = (void *)((unsigned long)stable_node | PAGE_MAPPING_KSM); } #ifdef CONFIG_SYSFS