From patchwork Fri Mar 22 08:36: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: 13599728 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 46728C54E71 for ; Fri, 22 Mar 2024 08:34:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C57296B008A; Fri, 22 Mar 2024 04:34:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BDFCA6B008C; Fri, 22 Mar 2024 04:34:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA8136B0092; Fri, 22 Mar 2024 04:34:38 -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 9881F6B008A for ; Fri, 22 Mar 2024 04:34:38 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 65A1012112A for ; Fri, 22 Mar 2024 08:34:38 +0000 (UTC) X-FDA: 81924013836.22.2595368 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id 5520318000D for ; Fri, 22 Mar 2024 08:34:35 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UAsYbdgL; spf=pass (imf24.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=1711096475; 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=lv4bMyhL95/nxMNEOkGX0YBTLBK3IDnPRoHWqaBZgPFrNkgNuq9AkaCF1FrdYU9d+qBx+W TUMSACIHZtPmeczLpz/jaSlHpHsSi15qsqMpoZ4dbmQ3bU+Y2ojId5PMLyqGoZqJvNJBwf 35UZuo8LWBNvGx00SMmWkKzKijK6OIs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711096475; a=rsa-sha256; cv=none; b=zusiaRimATXcepCs/QQ9C5aOPDKRiLEhSinPuNllVEmcM6XR1FppBAwwslcm+uFT1hjOT2 SyhZophd824x/3L1V9xnWxnr/wvfkcGQXCVWvzyj18yuGTwRiIr8JWUXoQqXJNHfhBxx3u GAnOVikfBB7UPmuxZ6OE7o8fyeVJCCc= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UAsYbdgL; spf=pass (imf24.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 7B5DB61333; Fri, 22 Mar 2024 08:34:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7644C433C7; Fri, 22 Mar 2024 08:34:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096474; bh=QDhgdKPLSZ+LCN9CDxfi2X7NfAWh6m7wtgm+INCh864=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UAsYbdgLPm6ColwLuGvdCRPIly5CPWzeKDimqEmd+ahSq/lji8PuZyO5ikptMXNRE 0tN4+9vjCPhdJSaDLadCTU3io0sosPse0dDeI6FKQ2pgfwAemBf0qoA+v3qWYHKnEL 7MznxUdS1LckQw/aHwXlA3ZFmNKMQguN28vs2gLoNP1+0neQAeiUc0mcZ4dwY64YiL 5gypatqFtmUoPs7+xuYnnWR+CdUeeLwrrRtJKVaxpvTom1yRJ8lGxDHp4jBIdacHTo pU3UuLwbIwtPPqIK3iAJwZJ+psijiC4YyAKdZEB5LFMfWXVtIN3kitnpzNMn9SOplM P9GkJonvDhM3g== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 01/14] mm/ksm: add ksm_get_folio Date: Fri, 22 Mar 2024 16:36:48 +0800 Message-ID: <20240322083703.232364-2-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5520318000D X-Rspam-User: X-Stat-Signature: i5mmzahgq5pkdgyo9xyofk9h9r9p8n3m X-Rspamd-Server: rspam03 X-HE-Tag: 1711096475-960796 X-HE-Meta: U2FsdGVkX1/HYQp/s6MUA6pix8cGKd/Ksm9z9vxcZ/2EumS6vDK7f+ZMFIA1GHT9w64OUPYh1DCi30nFElYTIqU8IwNcsxC6ri/ejqSNHLSsB26msjeTxl7sYcmtGRHlF17NHpUH6OxOzZdXtbz7RwXZM51ngc+QjWfSBd/oqWHWFyYt3Jq8HPThska6gI2AFK0kTXA9rxWTQLZ/YLgS/Z5AznwwJUXK8ZGyHR6PueVKZf+LICrCKbUuCvCssz9s6l+EpnD/G+X3wfYg8U9KJa25mBQrBxRVeIoHu6938B+OTBDhOaH8zJtuYfX4GD62rxVyGi+HxGy3skunkC179ZBQGQWB6Uk/waX5jcqtG4ojpVHugVIOFbYbY4pWs97YLDThwTb9wgX8zd7IIg0/s4w0ucUP2jdsKi0ljfPNRQFDExFZxoqA0F76PK1tsfhvGML90pDYOU21nls/z16xs0eViADCFaxhOzuheB7/NlPGgCo638ZdbLH290iYa7tudvU4sCzNZ29JUhxQZOrYOL3PekqjTZhuxglf8Zzas3eVQzZRZr56mBZX5EyYNaAjccHyroOboLz8H4uwepjxvSXL3uI7qPMPR+uzHUcuV91LSbEXeu14PQ/eH5bvsuotjfLvxj8THh9O5iT+ClrZE0oWAuEjOTDfiZmnqNpCIK1jjAcMp5cxLyFt65/kpTHVva3h94mN9gVepmhdCzQ0q6zY/1oBRlaf1hY2losBwDA90rvd+TOAx+Y+vybgdAt8gOWjd5iCn9sYEne6mYy73lnLBSa2CEDwHOJjybPnBDJhMerj0eqvoVOlIJ12UG9w0GJ4BlotBpZKu27cAUyEBKLDw82R+Iai4bHcs0AXZH9ia6jo/2lrTyz+2sA4tdnF715+3rB54KZxuHiJW/kjWjvEglBr4ove2lwU1xFymhn0+DXCjfEnL1T0vxWsHOrkOTpGEaOnbJMPkBbQR2p tByqSrOM 4zfvGBUpArhk8tNfc8dj/eBw38uQ8mUUlkhq0H8WM02cGV1PdaOZVoCjcR6trauXv0AipuDRk+He6FuNOPEHIjp/bDWk1THJ++FBxFz05YIevMzDLWWOsFYVdszeCpaBkSa62p32onbvfygUZSUBF9ZOrZY7AolOWbDHaOt5ioRAv2I4S+IwvyVvi1xpFZB+x/QEmDXE5MRKC28fhL/7A36fYjEklfrXGHLHpuBI7/xPMyQmx6mTrRSome6bzagBLTHUM8nrItCGdBqRnb+73hQn+4KYXKgk0spbg5dp7Bp9RMjwF77iAR+m4L49O5GERHjHA5/Rvdy8NelXQcDV92a3xtcB5rRuxM7NtNvaIeZ3SuHoJm+02XBaahAhm9CctZ6ma8iiqCYKOQ2aPvi/pVfTjs09LgFZSA3LLtATSt6RiUcYeZHMIGRatC0XM3qXvyDK1LSIZn7kGS5+9J/dRwOpWzHme4IKoZOCYAwxE1sZOMhuB8oy7R7ASPiv11RqwgbcV 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 --- 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 Fri Mar 22 08:36: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: 13599729 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 EBD0CC47DD9 for ; Fri, 22 Mar 2024 08:34:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BCA86B008C; Fri, 22 Mar 2024 04:34:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21D776B0092; Fri, 22 Mar 2024 04:34:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 070316B0093; Fri, 22 Mar 2024 04:34:39 -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 E3C536B008C for ; Fri, 22 Mar 2024 04:34:39 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B6C7C4131F for ; Fri, 22 Mar 2024 08:34:39 +0000 (UTC) X-FDA: 81924013878.13.20864C2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 23CD52001C for ; Fri, 22 Mar 2024 08:34:37 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=AaBhc3oW; spf=pass (imf13.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=1711096478; 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=zpQpQ5AduNCUw3vz8O0m7nv2b5QFG6bhMkYGwKcOJxjk5ukSU+21GdIvDtcsgBv6ici0QZ 0VbzgNznsIpYojrW0kLdEvp0l7xI7CHea3bWJcYWPG0ZEmm8GNWhHmBYBo1BDtavazL7Rg xXytMpUJpR4ppFoykjLSAP5Dd7WIceM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711096478; a=rsa-sha256; cv=none; b=3+ltad1dUEChC2+7N9Q+xFLx8MjncouEy/CKrQ/B0tW/pnFJGJkVoPDxHBMfXTrf3wZtXx JoyugYkayW0LfvD+9zH5qu4qwKJvuShfsLQ1YmYZReM1vyHII1bI8N4Lvflyo5AXiYuIwp 6/w3uuaqJgb4wZbLuTsUG7fWHc/n7Wg= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=AaBhc3oW; spf=pass (imf13.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 5AABA6140D; Fri, 22 Mar 2024 08:34:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4E41C433C7; Fri, 22 Mar 2024 08:34:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096477; bh=u2CpON+ylVsyq590GuxgPX8aACtNcQ54tsZFdjhyaWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AaBhc3oW54M2fVP4zko3bI7wwqPbKFrZpITxoE8zMB09nSGioEQ8ciGrhyoNVw9dl 5YrCQpT1pseBVwA33cgDlGFOx4FQlanhgK2UjNScC+SZBglLPfDqK1UofWxdr47roq 6GMyA8MaGGHVqiCCLVMQRL+VqScXIDmuLZrG9NMJ66kWpS40p0Zaj/cm+2GbhOMhTu e0ethnI0isP9gkZHmiQAYCHBVOZaM2T/frovkexYNf6fSyJbKzLJGhv/JOGivKU3Zb RCqpiaOpNDTHCBh4+Tx8KnVwnrqI1pqgWU499eH8OT7ssfyiP0MU1lfCoLJ1RBaMHz M4RaK8HjY2+1A== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 02/14] mm/ksm: use folio in remove_rmap_item_from_tree Date: Fri, 22 Mar 2024 16:36:49 +0800 Message-ID: <20240322083703.232364-3-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 23CD52001C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: sgaadugk73kwypq7cjdf9c7x3txb7k8u X-HE-Tag: 1711096477-701864 X-HE-Meta: U2FsdGVkX19uxr+8Bi6ICi2HKAtCd8UvXorAI20g1SXsk9skPQZCG1pABx87AvJB0W8Kj0YSbdDiJGtRbIEmPvde1mmC+4/bHyBBeg5G0UttoEq6wY0GGmwTlDPd9IQRkDyEFi/DovFOS6twClTAy1VWx0pKtlJLe1zh8/QGA9L5VIDbHwV2gbvunvZ1Hahf/EzgYPzcznaDSMM0djGD9nAOsMBf3xjezIz1C78hGuL2QAuQQkbs23aCnfwu2/uHYthTDkA5Wm7vgZNmW6gTrdvidXjHJzsVH5B0zNmjKo+QR1UedBsWDpWkdW9him9+sPXmqog6kxXaZGS3IHY3coHcihR/8BQ1K9wdhvYlPsBQcWrbssBfxXWtiVejE2XKi0ymlEC3BT3Y6PAM8Ar9Klu+6XOhX+Tn7yA0zIAUIcYKmKhROZL3v9wumIQxhpYGo4JhlMKFbefSSIlqRD5cCCUbYCWw9LeRijX6oByt6If4j0HtEadYCRR+CHjwnVGzzGe52g4JDRKz1myIt3mbvGjt3DO0rG+yg5cwiyDUEk2+LC2P+yuwG8SqkvLioS2j3aWDKJLWm/WMmpIkNaLTUtlbaPvAvEl5g20j/r/rM8n59Sw9kbwAWS2+v+3PVIBAI7BN2sHml6s6QaaCltY6fL5WAMIxtZQlqiI0eIJX9SazMstuzjARqv8AVm6lFlV+ZxgGxUXGEy4CJyBCbfkL1BN1PCGExLx6DwUmuDqfNVCOz4Nqjka3amXrQ5LUdocHQHfF3c+HvQYITJDrFPeYlKsanSAWHDcn0AL+Xr2cjZ/dolb5yAHpjhx+lXhwMRqs5p/b0PuDANR3KFBJ9SR04HPZk+U2mmHT6b0HCPETwnfs/2oW7DuP/gXk5DGdfBxDgZWEUifywp2812QcFnaDgpWZnT+W6b0yTWCvmK8UrBtN8EGcp4rMjEvkbVoViDh/ssEvEv2GEmzrv2NMuKR lX1uI/+i JpwOLsCZpGzJbSSrWGiRjbWzoWy77kU54wkGo4y6jXnxNrZtswXH+cSmObngQUPItIlcUEiw/W7S9HdAOkOcLcVA2R2qMf2YnBlQvKIVSNfNtOM9oHt7APtQgHB6ALbxxgqP2v6e64V0uUe5Q3apzh7yVoyGZib80927zIH2ZrBeXkbCMijg6E1UAONNcQebWkMzre+YbJeVTrQtQRwFQp9yJHOcO0WSO/vF3aabll76ZQ3W+4ZjisKScmeAqDBgam97AiQn4u6YnaeOfIu/6koUAKzBvB8mFfc/K+oBH7xZi6TQlpy9sfDHndAO+0SBz0R5kxptwNUPWqman3/M2Og1J66aSuNuvTiCSdWhKYTCPf75BT1Uej5IdjXvPW44Ix5MTT1Q3/xIlLBrbQF64kV6/FtrKmksKaY45saHef8OW8RAxLayH0HA3rYPJV4ATwWAKsv4hqou+IienGnHPAFjOPU25gMsDuJD5eIF4TWA69t3VOZhzCweudVG3pDvPqb3N 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 Fri Mar 22 08:36: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: 13599731 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 7A022C47DD9 for ; Fri, 22 Mar 2024 08:34:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09BE26B0098; Fri, 22 Mar 2024 04:34:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F3BFA6B0099; Fri, 22 Mar 2024 04:34:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE3356B009A; Fri, 22 Mar 2024 04:34:47 -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 C19266B0098 for ; Fri, 22 Mar 2024 04:34:47 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9E75D161325 for ; Fri, 22 Mar 2024 08:34:47 +0000 (UTC) X-FDA: 81924014214.29.252C322 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf11.hostedemail.com (Postfix) with ESMTP id 98D7E4000E for ; Fri, 22 Mar 2024 08:34:45 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oZsUV3DT; 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=1711096486; 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=DJ/6hVTwm4R4Dg96iKRpSWO0N2Uz+NhJBizWootQv5kAo6iiWqiNvt3OpcXCadsrGp6Wdz DndlKyh+4i9ePCbuVTOQZgW7r1NchZJcYcK6n4E0fAb5iNlz/c+KBB2GCIVIkCgjrIMjK6 9geCvuMgKC0/NcKNLRKdiLcDmY5T768= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=oZsUV3DT; 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=1711096486; a=rsa-sha256; cv=none; b=qLkm2lFxiRfoikL06aoqMvV6VElHg1ikfEu9gSpE+cnj+FmUU0S0pZFuTSNo2e0SJo4CPw swL1Gog3ECac+86KRlPnjLPQdpmIQi/QJYR6carZxJt3sA0Ovi00HtPSWPbRzeCtt4XRkP N58X5/6SAMMtEYXxDid93t4x6I4Lejg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C7711CE175C; Fri, 22 Mar 2024 08:34:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6D24C433C7; Fri, 22 Mar 2024 08:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096480; bh=JrD4352jMaYHyAz8IW4Sk3DaQV9z/B+p1XK/ErSE0cs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oZsUV3DTdJGLOu3ArzMd4oBovBPkSTl3ExBe2TyrGm2/jsGBl0k10Tvb00FSPq3S6 HrYImJ0RI3HDEKE7ufsczVtoViNfJEwZN9YIkae2ZLk6e3LzCTFevFL5JDTvjrfEi2 1Krww+MAEQwxg1AHgGsJp/Ixwx4wJqSIL3gSdw6vxRe5OKsZC9Q1IKRshBGsMmOMOI CEvi84IPNAKHdOC78TlZvwbMIAMRx/CYz+BIm3cTd59Td9FnlatulZGWWUAh0h/2Zo QrPXJLuUfcwuY1AVKIhMNeokjf9qdt96JM8SbuxOL/2KIkf6uHch3y3hWX9UK8wv3P OYqn8jLHP5OCQ== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 03/14] mm/ksm: add folio_set_stable_node Date: Fri, 22 Mar 2024 16:36:50 +0800 Message-ID: <20240322083703.232364-4-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 98D7E4000E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 3jnbxomfgahmswkfyiqq8ngt4qgpt51g X-HE-Tag: 1711096485-74302 X-HE-Meta: U2FsdGVkX1+BtBuVR2u1qCdDTo7LfBHOwJE4wpXZL4roQAaijIQvlp4aYDEGU2rdqJPR3YX7HuEvouvkSLMiqE6JVc157nrOOSKZQctguodfadUsGMGf8y+HHDThVSuPAEP3CGL0Vrba4W2PbiGU+l5y9Pangs/mIfWhhlAe50NkFYtbwgggKbeQ9CJV8/76E/a2qdOP5hCL/2F4U9lJfXVJD+CBFoXL9g1oOPFqmYsIiaDYYYZbxh1SEU5PE0bIQ1fqZmWK3TZZ2DVLxSIkQdAZSaOrYNxhBOXhR16m7/1yIWzpy8ReD8sdWLUFF/fSp3jl3/+EAxllnAR93ppWFI09aMboTxdZWFcW9B1Xnlr3lwq+k3ZwvAfce5pqsQky3lTXDNgqCgP95tBEDjznQBd1dx/ZdhDB1luUY7t5aM9FA4DA3OZ+yH6YAWv5dI1URUdzgN+tnaGxeAfxGFy9ZouLSUhy3fFCYKVS8B0RFWSOs6W9FK9/9Jgslso+lw/n8jr8Ml7VhsFa+zYw3j8H0WmdBqFiQmfBnkYFBDnl5TPiIiz5NINfKnKrRTjMbVhRfmkF9+EhPIudQW+v660mw9B9h5lcSOOCOGgXRsgr0cgo7FbNAxMquFcifLCMPSRYuh7XDLZRqynBQZGAhWXvWa5OmmGSCbNrvjbmYzA9XB1a7BJlP/AYMBCgOVzrm9unjay4ZczQr/LZmAgm4J2hxeYb59MIA3uOxdbuBGG9bCAqMgLkARj4cjxfjY1kJV7EDWKF1CJGjloAYCoKY5OpZm9H5hbhWtWmB+V1/YUZvKqMGzgAD2/bruEP0V8dkG02t2eDOP2DD5bq7koDs1xeNEX1zh3ZhABZ1phyZ3FJ0F0xM0cxuKwVBfkCoyFQr4CmOALrFKBYkPIJe6X5UViqHEzDwlniFdrKuGBpFaFhU/ea2WZ9X5eotoNNzBAv3DNW3ffz5SBxtb/wSQiCSXk noLOpEZM TvfROAo/N5E5DaQ/rfC8J+oE/J4N/d62cWcH1Km3stFdsMkSOP9S35fLqT++wD5VJEjCLEFRWKf57THDsbz9wfJOuXk31pkTkK1tL19rk/pUOplbAw1Rsxrw1gEGM7EtusvuKjRYlgXnCSvnL8rZ8K4+zMvEUmGySWAuXzJK4+ooVXJOV1S6DqfjJHiDX8yBN8ncCvPupyOYbr8oLfIzPBh+RI8mdj9R1E0aOEv/g8/jveaV5amaTAldijeIpudvOf/yEndMHWGS+hnpdF44REArjo1LQawKE/z3lDZmD85tZp8lPuXFTP2CQn5Vgj7hNmFUvvtW+YGB2SbOBcckTIEttfSi21rf1q4I5yaY5Kb1UC3T2ztYqX7UsVV/e5YrxzkFLwNaspL7SRsagy3g6vaZOva99gFbajq/E4ayayUNVsRd1lcUU7HElSIzv1cX6oUfNa+dbHeFh+WF9nI9FK5fwDehrdfBcW7qohiH9gj8Xy2UHX+plur5xbqJeg+aTOv/9 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 Fri Mar 22 08:36: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: 13599730 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 8F466C54E71 for ; Fri, 22 Mar 2024 08:34:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1FB6B6B0095; Fri, 22 Mar 2024 04:34:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 182226B0096; Fri, 22 Mar 2024 04:34:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3C516B0098; Fri, 22 Mar 2024 04:34:45 -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 DBFCB6B0095 for ; Fri, 22 Mar 2024 04:34:45 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 842AC1211A7 for ; Fri, 22 Mar 2024 08:34:45 +0000 (UTC) X-FDA: 81924014130.07.14E6E2F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id ECA9840010 for ; Fri, 22 Mar 2024 08:34:43 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=imVmTgVq; spf=pass (imf01.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=1711096484; 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=fdERHi+EaMJft7mQ/Y9P/3kgU0mrYpma0/0RASjig/pU4f3Ipb26WSe679rOf2a3NsyhJh iiTC0If2gSjxh//b0F8jeEOm8QvRtjNvENCbB1mCXpaTENNSx/OAgh58Lc45PPNWJFOZyu 56zUabaaG0A9hQj912NV1pO40xMArkc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711096484; a=rsa-sha256; cv=none; b=qzuF/GHA6zkzx/jQEg/xhu8VjWbxm49DP8iREJduol/hM5oMVxL7jzfuSYMfi6vriPKcpb mQOL+i3QDWtIyx4cgVUFx8mJKrJ4yQWd7rAytB1Uw+2wAbmTrPhIK/0kF96NUjxJKhqKoF FIXewxwmLSmDsolamUY0cLAihvhOLc4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=imVmTgVq; spf=pass (imf01.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 38D276128D; Fri, 22 Mar 2024 08:34:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5AF0C433F1; Fri, 22 Mar 2024 08:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096482; bh=k8zytA2A5T1rgDUiIACZ6hBdX8Fv5Jcn+9QWsQNKn6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=imVmTgVqlm+AmLk8Z+ZTMWUVNgNEq2BRlwccjhVyXLCB5qbeGmW6fnWIQVCdNlzid 06QraqFqwlS6y3vmnpi4Ap+WlLV/fStE6rPaOVtdHzI8NrNZ42fTJC9XPUrPp6ir+c GV4rj/JQSVNeSlk0ugfN6JCQ1XDjD1pSqTglUpse/EvLUm2T2jWrtq9YXKNEu9fuzn t69uwVBV97Ya9HH95qLpXX8br7iG5co6wHQvXztAm3v6yEEo3yOuQ4k31/8fwPTdEs MBLkSjMg134iZq1KJzMzfVW8NG/QHXg85sUGpSMLwN1pLXyxCrtZ7TX+M/Nl8s3kO0 7Uingur0uvApA== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 04/14] mm/ksm: use folio in remove_stable_node Date: Fri, 22 Mar 2024 16:36:51 +0800 Message-ID: <20240322083703.232364-5-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: hebchrgro66wumwjwjosyhky3fmpzyw4 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: ECA9840010 X-Rspam-User: X-HE-Tag: 1711096483-371528 X-HE-Meta: U2FsdGVkX188T6gAjLRnEQE3x7OpmsYjDy10M8jUbWXi8q2cN4spwnWsd1EeH+2AFKM/bmtkYskr/w8tXMSzFQ3TA0v+2D2jPzXAnCtbs2LIjNth+NiC2TqLqtHF++UVhB2iEyz4bWqSrQKRKmuNetDeYUVAX4sHxm9uVLmbcNlVCbxIqmeFiRbj/45b/WuO4VXK/2f0/mWPdGZ9t79n76udPBtS3ll5XZT8CUgedi8Tz6y80L0YQiqSB5SFIcY5HpAORSt55NpzAoOmwfHmIi52g/bex3LAcg0L8DZKpvazW+q+Rl2oboQKZfnDYgM1a0m0BgQ3nqOxzKvUYMktEbD449WqXOfHvJojsPOG+/LmeusDI8Cc3UrAh7HZGwheCohMBJw/tT/mZgEEPymMYBPI4egLd0cqzejQgRjSda4UFGALCmBVPrq7eNcFIWd7PwqUA51K9Tk2A2yPZnNLdwa6aEj6WVk0itFtKb3zWTx2FXKf+bRX+fnZLf3uWY637KMU13UmURVr5zCJz9Mk6rjFgK1WXNGMgzWVyy3FNg1zxmNgfwUM+Qr9wnwH2JMiC8TiK1bKj3CzOYVlcET2ZvqXlm0l48e01T67csNHDpVz1+3XGdFgWDlKB3sn/ZJ+qlNQzGLyL2bSOlWXI/g/PrAkYcrfFamERxUVOS9wcD7oyc7Gdpns5PdtqImOdchbqsrcnApcIyEtkHTZSbJ0JCroLA6/TLwM3FBFNZ+L6yJ7L0bqTdZdLHN1ZS10UiWSC3cyjKo59FE2snofqb0A01MtEGcvXJw7VPAt30K4R7v4gT8J/pMzHBNssL+TYT5u3rBK77sZDzxADUzpmPcwp5fUut7uTOep9G0jGjlb9jYeJBOWFixNdDuza8cwuhLL6AD6ARuVANqgV/+NnQOIGFDjbbRTxU69anDsSnD8MdIlWZmkpYLcX+KVZRDDynw+g8ck0/hNbndPRCJP680 GzL19W50 E9xbbFE8nDyNAk4/Hbbwm8CorcWmLwPlckxZAe54ywgmhXpVybgDCdv7Glh090rzbpEDaB0IwexBVYOrq/HaVCIBEjMA4Gph7Yu4rPO7j7Rd41JdKIlEBfNxWJQZjvX5eqzU9qTSBWuCc/tMxkkpLN8Phj2rKiYEbejCTd1yjPi46HTA5jFq/qLU4w1TpC2fg8X3oCQe7mJ5Rf5OYyyN3WwNqyA9MEVRnxlLga2YSVsrcNR5h4/mgk6Hdc8GkVs5D81BxT+F1sFFDoBYY1Sx5VjQdvYvZOb6Oh9hckMaqZT1YWCftXLfOPjLAna8n2P+M/MoJAeOo3Hu3sQIgtlE5WptHXNabpQD3XhXP0TNlKhqrqr5BVSrDzrVhmUtD2UC50tbxnUM07FPlrKDjYSruX5yn86BkYpxLM40GoFZzXQ9grqPOAaKaao5mV/FNYsT9ZqDfHf5aapZUf6f8ibIEnx1HnGcsURuljYxK+skAx2wiUEtggPsPzrmBdBfQIDHiXBE4 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 Fri Mar 22 08:36: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: 13599735 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 60824C54E71 for ; Fri, 22 Mar 2024 08:35:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 205E96B009C; Fri, 22 Mar 2024 04:34:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 15F606B00A1; Fri, 22 Mar 2024 04:34:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E04816B009F; Fri, 22 Mar 2024 04:34:57 -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 AF3E16B009E for ; Fri, 22 Mar 2024 04:34:57 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7BF9B1413BD for ; Fri, 22 Mar 2024 08:34:57 +0000 (UTC) X-FDA: 81924014634.24.F06A5FD Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf05.hostedemail.com (Postfix) with ESMTP id 35939100010 for ; Fri, 22 Mar 2024 08:34:54 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tGS9D7Rv; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf05.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=1711096495; 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=abZKdZWqgpqATcN0E2cm42vDhXwfWSfcAYNHtPBFWlg=; b=Qzvgvw2ZZx5l+eMyJuVWUu7MtPU4dpsnrC8NXbNl9LczFqw02C+Eg7Pkif6PEMcIjOgQHB dYoDtvtywcHIiXpNLMNVbgagUcNhvcRdoP+lgOuVE5dP8Ua163wObNi02XdRKB24mYNkTm DV6yH4Z1kpcruq4Gsfya7xS8Igd9CKg= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tGS9D7Rv; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf05.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=1711096495; a=rsa-sha256; cv=none; b=lwXOczhOBAcCb67QdPsghIRs82CKEUtzFVTP7o4pha93oDBLMYsg1xf70IEjzjUftWFFPk MHJrY6GeaFmcPX3HwSOT0IRkKC+xWOnGGwiiKBsJxbWRlbHB8TulhPKLUm1R6TVJ+Kz0Y8 uepAVRPNqnTMM4B9edWx8Dy/wbtYYO8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 86A94CE169E; Fri, 22 Mar 2024 08:34:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87C74C433C7; Fri, 22 Mar 2024 08:34:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096485; bh=swBWDDTfKPZfIshmO9+8+Tzqpp1exgNxKwXg3dE2124=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tGS9D7RvKPTXxnlUVQ0m7lLcLgSe2JsQ/C16nFNsWIGdx4hoVu89jKYQPZ4pVIQkm LUZdfrNIl0j5qWWmh4/GQMYf3eOKTE6mHp5fIGtBMuuvvVAP+R5SFBNQbMPnw36m3V Rf2vKsB8o3WwISyorzm7bMYUo9LsItXJR25HAL8vwOxVRpln+3DCSY0tLqkFXpRFcx xS1EuUj37mxQQVQ1p71HaIYocf9QpwNj0O7EzfE4w/5f+JtGoz5o3C1LZy8CGETqLl Bm7PkXRuP6Zq38bMbL9QYNQNM6p9vGLqBrL3lahxrNBsWhLEtglFCySXScJBlQ1LDs bCd5xTUf+YRVA== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 05/14] mm/ksm: use folio in stable_node_dup Date: Fri, 22 Mar 2024 16:36:52 +0800 Message-ID: <20240322083703.232364-6-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 1u83x61swo1h1r889ydrrqqd9tdzg4xj X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 35939100010 X-HE-Tag: 1711096494-455729 X-HE-Meta: U2FsdGVkX190dyPi2dacQ7nwR/0bkTd8bmzfu7uP2hPv0Bx+BVloTNBueiljyKHBafW0dG1wqu1hygJeCm7xsE2i2JrF2Zb24fcHAClWVyzrCOx9UQOeowsQ6FbOVzImA+dz5pRcyFnquqTrNZtFRe2SyoAtpCw5L5aEpRqc4CzlU+rJU4UuXK3LzHGPGZYTjqhv2xLJdvv8PLOreDAF+XGV+KR+LWYqop89/2yYcjII2NltV5uCbFIfdqMmE7TpEN7b1UNx4qHtC41/s/FWGbWkoIucotATq4hqW0ZvZ6+Lj2xZf3Nn9AcbJS3Qney9z+A3bgmXfxOnQbbRAVvavvFFmGMte9wVepBHFrNGMOXM8uoM90mEbNZ3rEOrlDVAF1rH8VycSzHmjv14O7Zh+jPQWJ4QxplWQDchevMHuqBHsufosKRrpUpA2wpRBQ5i0ta7sr0q++0zIEdDuNuRBefl0EYsyHvJHsJUxtIhZCDxF2OdA875Gyc7uTK05mPcD2n0a2EHfsjY9pKgC8+13T6cXRk/7X5hR6bX6tN/pJ/AX4pnznu8yHFkYd/euifyKBGjCpa9hy8LfjGSmgetd0c6QltmNWTkzEBuGC0EGEXFk2gNRPW4hL+ELHqwIxIaHTI7lcIELRfSjMb7g6ASiiyaYcLW6up7w3TCQaPC8M3/EbArrNKsNeOAKil9y57RG0m+vq0uEbinio+r5vVu/hlYrCYOI4JWjcyTNhLSLfn3q3wgpYox8fdtjqnppXuVMarHt55mKePprd8MoMKK1rOXgc+mDfBI0wX8JrwQvX7iIqWMfDrUYBZVESKRcVxnARgxeeEy8Bumv/jFuVNERL3farqkYtGsPo0u1gQ/XQTUsp3NJijc5donOS9AyJhl9MGe6kwKk9cJDIkVnG1fnHw0x3zdBQZLoOpmrMw1iiPx/JwkDbNuXUpp0LxuvwAFz+MA4MXoJW4P5wZqmnp WvvdxOoT bwdoq6UVnP3KQUDOXN7ryTKy+ZQ6zsD8lzqWw3JzGF2k/lY/VIY1acs4egAzWCAbGOAWwQz0+ttxc1N/jgdOZwAHeYob13tqLHay7XWeEsUHdp7RDGzYtpPy8vX/7dTuyNAhrCOGMIeMiHiCawGaHi0rFftGxpbAgjtIwZlJLI/v76vd1utgz0Rv4hpP1a3SOfE814QxQghs/STLDqvAQK9ifB37BXafbu6wU/dUHH2SzWT/OcaQjfIJqEAJGQ28DhnCRlkN7uMJYOdSh9VWiwV23LP9vHcJ6PjDarO9mln/ha8F6/Hj6wmGEcSTT9HGNvAY9Tiu10y3MnkEqju1UvDtQs7q35VDL7mt895y4CKu+lnYQ8TlBGILcFKfBnFHV9koo92YS0UVI3hLXPKuA5T8qtJjA7CjrYsy90gbTodUGGr3370KwfbWtKpVZcuq1h1FpBo4IhwhJWmaJXHUv4KEobraifrTSqaGn3oIFGoACqT6AJ3j+gJPfan0AuOsEzy7w 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 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index b6ee2bc7646f..a1e382ecd501 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1631,14 +1631,14 @@ 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 void *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; - 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; } static struct ksm_stable_node *stable_node_dup_any(struct ksm_stable_node *stable_node, From patchwork Fri Mar 22 08:36: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: 13599732 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 B3979C47DD9 for ; Fri, 22 Mar 2024 08:34:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4905F6B009A; Fri, 22 Mar 2024 04:34:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 41AA16B009B; Fri, 22 Mar 2024 04:34:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26D3A6B009C; Fri, 22 Mar 2024 04:34:53 -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 0F5D46B009A for ; Fri, 22 Mar 2024 04:34:53 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DDB301C09F5 for ; Fri, 22 Mar 2024 08:34:52 +0000 (UTC) X-FDA: 81924014424.23.F13527F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 4513A40009 for ; Fri, 22 Mar 2024 08:34:51 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZymVidz3; 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=1711096491; 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=LxZK19S2i+sGKx9/CjW/VzjA82ar5TBD7OJl4v0Q18I=; b=0DdkraljH6rs4fMSVLjK4GzSqjjPeFl/WVv/9WLFEnPpq1WKiwuZPtPt/FseVy8UtD/TI3 lwU82DLXbf2B1YhWLqynz9uPQRR6nMvnaOjvSy95BoTul1FvVGZXT1uiXRReQvXYLZj9iu RoraNhWrhws+3yKfQDjfnXtkQ97tDLw= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZymVidz3; 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=1711096491; a=rsa-sha256; cv=none; b=o7CLucMq0GiYjbHvTElVavsiIld89/Pru4ryxnPINmBWvgDklmP2lMq0dvQHEoq2VmT8d8 Lst11AM2KQf33hqjeAA8HX3mSFzzX8YrARkPTSIzjd6M9yP2K9u28m0XsFfywRxZ2saGyn 6+mWn2AzBcNrGsq68Q5vvNYDdgmQH70= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C6E4D6140C; Fri, 22 Mar 2024 08:34:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61807C433B2; Fri, 22 Mar 2024 08:34:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096488; bh=mMH/7is2PyQdNPPcgd1XKt1tQVN1U+t8U42cK5CGbhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZymVidz3av9KUT6Go6vA7X/x8b1ArdeFvYp18yRZGRi7LFSF5BGygSy2nSAuNS48N oV//U8dnoMVOjWa0BZ4rHVLr0EJ1qsYlNQfQ9RbKxZMY2/ATKY8XT1JCPMhq2ivANK u/nMXB+FYxQ9VgJFCSrQ+X7XAr1LA5u2XDrmtrwHXsB1AFYesR/Vm1xs/IKR5jygoU n2X+VDFIExCWPIFpToJPdrk1bWwaZmv3OEEGmZ96CEje5LCAjnu9xki4q/3PG0umlS B12ZuA20VXl0otZBh8fT6hYqd0DzBi8jxdsBwcVHmIBZBPffkFvku1uFrC1z8tcL0h oikhkdgIYR9Rg== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 06/14] mm/ksm: use ksm_get_folio in scan_get_next_rmap_item Date: Fri, 22 Mar 2024 16:36:53 +0800 Message-ID: <20240322083703.232364-7-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4513A40009 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 9g11ua4415wyg9wxcozr5kwfdfhpjdtr X-HE-Tag: 1711096491-667357 X-HE-Meta: U2FsdGVkX1/KUL2yWuuhUtBmO1v5l3ywo4Z2H7X3QOcxATk3FDBZw83iESRQLcxRPQkhoaGWgUWHz8MONVfXQvpMQIX1axWj5CSEUqkugg4OhHOKl4oN23J4Y1QvRq3i1cSlt84bPiRb9YMi1DUsFobRPAtube89bVjI4o5Yzo1szS/nnld3ley+qhXdNAJWubg/7rYd0UAEycl2b9qhP5C0Z0U02m80Wz1P4U8d4xkaRuvjwl8F4LOYkkQWCOcpcBOURvL8BLo4zybdhLX9e8iOtFIGeBZ0R9Cfj2tZkmfS5IdjK3Ccl1B2/Xj2jxrtq7THVc3vM2wNt532CxKzg0xgzAJo9lVmDE3+aTLUKaeWsuWlBWI24OzhYbNoZc3urwFBFtbD90EN3g+jhhAjBd2JUt5BCunUS67+Opo103aZqpTf45opT+6TwkpfDKNqhHabCOGb1DJk7RsY0pBqVUcqIrF5GWliH5aCB0JORLzQpe/zUKU2DDQq6m7jHPtNCtTe9UrUFLVTYbm+6LjTBmZHpw4waVyzRORlS1uBIBhIbAVaFGo3PtvkXTZbVGVMnNfUUQxBUAqLQiUlkXm1js2i8CA4YomoGvVzdlKP2K4l+qmmuJpB4POmuKdnKjVqhMG3A6y7gZVlnlloWifCZez/IknNzCPEGls+5YtCy5kKsuTP4zumF7arBZcTzcxYRdzcXcLE2YEbcVWmhfcD/Qp52vlu3yx7RZbfAxNzLtdXkEgTsGnzXTJfmasHMLivZUjakx+5OP6kIJXbCDewfg42VB0OlF61rUJZ09OiuVnW15Pv0P/+RquP6HWUIPtIUFfFwjiiZHJAC4C1AwI+UJTDw/5KYEORNHszu3PKeTknAr0UvVZ642RQKuiYw7X+PEzynGExwfLM05ovBB4AYsOSHt5pFKRaeoXRiocAo8hj0jdUBzm9UCfoLoDR0y+f6eZheGwbpRPwy5BWIVa lOgxMm5y tufuL8WUGMMFW9WOIp5vjlytp2fbmWtA19XmCriJ/S456NqHGXDIhx3rnZw7yO/1F4aPwQYLa4nbuHnepoQ44XDTx+lmZdJOnAJO1Z1RurzSEZc8f2yVLXYbsLofHVV6rdiObNjp5H3FDBAY1AahbtB8XxhD0IhNbjOBZFzagCU+yk8ucUIkUbxCknQ1IU2eERSIbMTv/0oTYpLsJCZjNvq/4nnh34zUE5uD8XOixLnSDL+5d8+aNwQq6sBBcQjMz2qcWqKSQxsYn768bTEg4EY0l+tnFz59Tql3PVM2b7njfOpn2zuq8Otf8VmE6WT7WRe66/cXxCjjsX8TTtf5KvNqjomUBp0eoc0zEBl2WwQl8bTHqxQeo/8b7gloG4fNeoGp00Niu8thjAya6dnWjdtSkGQv+iyu0l7WsH2fAqRElxIxgiaAHMfKUELv9GQlFl/3Tw9aUFAak+tAHQZASIuXEinE7mYGIn24NOoWOLDlYKyM7J6ViMrNqrf5hxikg0GPO 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 --- mm/ksm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index a1e382ecd501..cd607b942c26 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 Fri Mar 22 08:36: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: 13599733 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 2967CC54E71 for ; Fri, 22 Mar 2024 08:34:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFDD16B009D; Fri, 22 Mar 2024 04:34:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A8E1A6B009F; Fri, 22 Mar 2024 04:34:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 923076B009E; Fri, 22 Mar 2024 04:34: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 7FE916B009C for ; Fri, 22 Mar 2024 04:34:57 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 564781C19E9 for ; Fri, 22 Mar 2024 08:34:57 +0000 (UTC) X-FDA: 81924014634.22.95B00CC Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id 46BF91C001B for ; Fri, 22 Mar 2024 08:34:54 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GPndUjay; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.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=1711096496; 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=zepfTSSuU1H47LHDp7z16x8iMxIzac+uuTIZHWvltoI=; b=uYCOdRkveKML2Cq7WPujdi6N/jxJW+LiAidmkauBpgwyBq7fK1ayxYesr3CBnBi9muNo1P QwdoRNR5DBRl0RoRzJobzXmkyogAFwPV8elMSAf0GpDrJimbKA+joXon2xm/gBcjln6KDq f8uuL1CNXMqhpMpJnyhtqxNScogoahA= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GPndUjay; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.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=1711096496; a=rsa-sha256; cv=none; b=7bVEdDx/Q/gvcFcDLQRElXbjVOVOqX4CWyNBEtTsMglJIqIym8RG6I+mcm5pMgzY0nuVL3 yTBoEqMAaW+gpFmHql5+SmvP/yX8SsWL1hEf0H5tWFgP5xaZPeGxnQsapCafuTbjr/QaGF 8sp56R8i9cNBnizRrJ+P27EDmyf2RTE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 75919CE16C2; Fri, 22 Mar 2024 08:34:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42C56C433F1; Fri, 22 Mar 2024 08:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096491; bh=CRD+qsq6X8eUY6+mfkkDNsd4MjPhDaxu0Mmm/KE7kcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GPndUjayFYuvxAfrdHVpgbn3recU3ex9yh6yyygkZajGGC43bK7JvpNx2k8KyYj2J SJ3AcquFw5gxtAwAzsgJcAX10ry74rQoDSQg6coQUWfwSoNnkQ4hPcT6KoDm4Qj8/U 6y5ZJFVIIb9ByKLPS6cnCjQgKXY/+0LepUrK+9bYUtm0y6hw/KBKkQM+3wp0RX2pLG neO9o9EmWT94cbmzT1QVbawxNScHRds6LaBQoT+obrK3rMc57EGxTIrZysRoIg/vO1 UJJsrjQG4U4+0lxFljPG9881vtHf5Bm7IZpbJ8h5yXFaMcVQg9g2Fa4AhjlRGpICqL z8SLLhp6LhmDw== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 07/14] mm/ksm: use folio in write_protect_page Date: Fri, 22 Mar 2024 16:36:54 +0800 Message-ID: <20240322083703.232364-8-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 46BF91C001B X-Stat-Signature: arw4s8kq8i75qjch4fyyp96omttphw7a X-Rspam-User: X-HE-Tag: 1711096494-839626 X-HE-Meta: U2FsdGVkX1/EMoBouPA9vkMtWV82swAv1PoSJgqyGL3ByhnV3TPAGI1EfqxNXOCkFaIzZHix1VZ4YxLxDuXh3fFIuEggY989ojwoEm3zxB+JGWmDKtt+4uUYfVZaWzdvQRsTZAXQXiB7QoE3kdt6mansB6WWgfyhkzm5Zp3qaGK/W4viS3tWkf4WGzrjrpt5N8cXuiVGNBPwmBlUhKTk5YlttHxAA0M4in7nBnzOxg0h1SP1BJudKlZuIPN/oGeBjWZBYSCB0zr1MuixqnzVpFJKm4Bd977RcSRZugXtyk6J1ctNEBAVu59DFQhF3TrXU7jppy9l0S2eH99J8gOCnkwVUyM6W28zcGdOzdJOZpMOpPvWmhd+ZZ1g8siC19rqQoi2FoGVYjEu82jAOkjYJdtE6xczb3dOLA6zB5dqVwztdiYlIOLmoIN9KqaPSjSpepktnkqs9PiC7UA1zT2G7l3NluTdN8tuZWrhFHCl5/cCvr1IuzyPQE6bmzIAycXq1DOr93v7lkPjMpJQ++2ii0wgsNDVX7E29dly+Vbw6yFku8CccyMlBrh8lzjCxX4YmHXySTPf3w5KZS4ILJBmdXSjbnzTtYP82y5em3OGe9iIpm9eVoIHoPDABUuEZNqTO9+iPPGCoU0kk4AmsrLnVwsKRFyWRwi57F2RBEJrVL5FCz/I2/Mp7jSzi2zeLH66FSmMBH552/BQgzsvHEtyw9fggXpBXDdrEuPVcchwv3uyETqtSbEKmJIlf43VnmR/eODHvjNoaqzzgXImo2FVeec1FwMxXqVWoanxxhspKpOxRCSOryGAWnJFN6jezfQ+z9J1O/bIazXVTYyA9TIoOFsgMFgATuqluWj/DjRWTsPwELuyfTBlAbtL/WE0swfpcVMvKjt/j5LGtZBAm6NAAI/4wMnyMZUUTuWvoI7y17PTgDTD+07iyu9eOZnmWOMYkV+qdmUH0fv+q1Ch/sk qPX6fQRx O1eoQ 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 cd607b942c26..f41491cf13c6 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 Fri Mar 22 08:36: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: 13599734 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 660F1CD11BF for ; Fri, 22 Mar 2024 08:35:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF3B16B009E; Fri, 22 Mar 2024 04:34:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E7A896B009C; Fri, 22 Mar 2024 04:34:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CAAFF6B00A1; Fri, 22 Mar 2024 04:34:57 -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 A429A6B009C for ; Fri, 22 Mar 2024 04:34:57 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 80031C0C64 for ; Fri, 22 Mar 2024 08:34:57 +0000 (UTC) X-FDA: 81924014634.22.6E6927F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 8B3E740003 for ; Fri, 22 Mar 2024 08:34:55 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iSqvlKnQ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.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=1711096495; 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=fH8PCU7tcCjvM0wdZXSe9Jm35IXTtS/JFGEFHAYLlnc=; b=UC8EscLa8t/w0MPfuiDiSazCUxxbYr/fiRyZmGPwYv7cyJ7sgW/ungj6IPxCzfvTRAkJFR 9xAqpsbPzoi903m6TYhc2ZvFPaWECgwMypma3wwvaZDJFyhPg+CJm88KK7LgaWXFYEPxin e/OYSEVkIOWFqi2K3I+xOU96Fg84Hr8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iSqvlKnQ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.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=1711096495; a=rsa-sha256; cv=none; b=V1cwyzB3v3i3bSb8RUgaDcQPobMimROIzONsy81DRbFE1v7NORz7+strxFTkEA1vrzW+GY bxK3NENQZ5PsLRsPk9KWwwCR42re9UsZhlZaz3VxugH/uiXdD0KmVksc4nf42yFrNqtLqB 4pj9sM+JWSxM4dGpMoiciiyXSADsWjo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id CA69A61405; Fri, 22 Mar 2024 08:34:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45184C43399; Fri, 22 Mar 2024 08:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096494; bh=Czj2cXDjtWaQ7qWM/ntpEjf7pxB7Zlc771aFb0A0Wn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iSqvlKnQKbuzNlo/1UqKPoPip2scXPO84E9+9X8dNblrtlYt2FWgou2idLr2Cf624 8JDv38d4rMAdgz4MTUUko9xkN20vVseInMkafo4ridyT8QrSEK6mUIMSW1s2bGoCWb 2oA1/SD9crmzZec6ZPZSk2pUNViw39caL5q+bQOFPvg7lP7aJp0rZC7ZSkDGyd6tr1 fZxBXpnGQ83pK0lK/Su/GbJrSrPEaS2sLnmOcnErBD6joRlbQsbF4sqsMRfph6EfUs EJCIbyKNVbuK1tMDzHm/u1kuRYEqAnEIsJ/orGgHG7dy/Yqe89xaP0SuprV37NcFFC 2Stk7Cot+7HvA== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 08/14] mm/ksm: Convert chain series funcs to use folio Date: Fri, 22 Mar 2024 16:36:55 +0800 Message-ID: <20240322083703.232364-9-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8B3E740003 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: z6oghs4s6y65r6oa4epfeh1u6ti53rui X-HE-Tag: 1711096495-258365 X-HE-Meta: U2FsdGVkX1+nVVa+E8omuxBKaeSTrKBD9qsqnmgheULhv1qYN4dloWYMELKD6Qkyf568zGREmtAwdm4G97aslsuVJ/58WVAovSXOH01yBpnGXkJ2xaGmaHeaMgXhM+x4fURH7wGfc4RjT3P/OAeO+bg58G4OvOtCuumV95kycM/9V9aEyDdxrcYf/r/JizEkZIJLs8wTRuJusmChzyuL91a5B0HB/vVk4k5QVgsl545E8hw+73a94UEKaQqOBdR7QJFqz33SWu+Ij34RQ9CwotdfyHwBk3GkMQtQ04MOjymeqaI6/yflilzbmNFjI9ZcuwZTCZq9p3zllN1VwAA/TbD0q3MwDuLA0f0s5N/2ZaAplYqPTYRVFAOxsrGf3c58HrPLKFW+br7GPOhe9jDphqtuhpixsiAVZocewkMEA/+JwYBi/VydJlTdIRW5t9ZKSpG7aC1ZOdtg2vSYMWKqhfIpIPrSMT4y+WsuLBNaccGX+OW9eaK2nPbmpG0igmsJ1R5rczUM1StGWLYbAkEZi9S0HquREpjhcIrxH4GFcs7TbduhB1V/K+O4ZNwiu3R/DlZoavEB7ljCVWqCoauFcCzvcHS3uJK0RfKJKgizmKPoRTeWa13SfjoPvbIltreljxtGYz71slE+HTjeOLf+MjOT6HJWkiok1QtQ7tgSUC8O7Xm59T1NOBhxFOX/LV3ydiYB4POwZqYV5shffn8RDCsIMFke5xuKVafpryKshvBXy2Lry6momQw5g+g29srFBxLVISOSLr6k5T9RAQvmv7jJwKWelJK1Xk+da00fCPr0+s93+KLbOWf0EylDkwIn7UoM/kro9PhZVt2McGsb+fccgPiPDVRl0f394Yw9Iy/zpcB/uFr3H7hTDeUqQKEzoPOLDOxkDKjYFQW1fIb6NL5srX7RtuXb/YzYnvW24G+jJlH6ik9g45YtbJUiRh9MuauBhiRyhSRs1Kjg8Hk 1j8zFM+F 4HfTtn1LX2W9Cz7f3guHVu1YFOX5WpMqnWjmc5RPiqrDfPzI7xUsAg5q8VdYLIICiX6+fWhfhO0aNBZwkCBZIKbxxFA/ZogWMo+z26Op1UHOBxPNdHEYNlIfhMjBta69nD7Ed6u7RME/I7Ba2fbNu5k3+eWFfBtAL39dce66bO/OylDlOvghaCvnxZP8NyO9nNKGha84RcWZ4p3iywmeMQbEihX08vBOwFUwnQEdNiU9Vk60Trvk3uIb+jlRJdvZO/PmwHuLDQbBqthl+NHoi/U3zTravu0ITzBe3ntzWltOLMnLfVBarOKugMbZjthTGlp58PzDEJGUmfD6DW6ogCCHlQ5VtHVLBMYF2p539GMKXUs3K+aE8x7f6Y2W4qXYZvgAZIcmMk+ha8w6XGvADRBfEHBr+C1R/qRlEbY1ddUyugyUCh0TRdQ7rwhST/gN6FODZYX0o+DhQKiw= 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 f41491cf13c6..30570e1f68ec 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 Fri Mar 22 08:36: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: 13599736 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 3AB0AC47DD9 for ; Fri, 22 Mar 2024 08:35:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 641236B00A0; Fri, 22 Mar 2024 04:35:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C6AF6B00A1; Fri, 22 Mar 2024 04:35:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3CC8E6B00A2; Fri, 22 Mar 2024 04:35:00 -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 239866B00A0 for ; Fri, 22 Mar 2024 04:35:00 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EA5D5C117C for ; Fri, 22 Mar 2024 08:34:59 +0000 (UTC) X-FDA: 81924014718.03.7FDFF42 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id 75738100012 for ; Fri, 22 Mar 2024 08:34:58 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="h4/d94dF"; spf=pass (imf14.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=1711096498; 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=M5OZV6oozIQ/jl7bklYmdOsNVkzp3G00p0hMTEP2k1U=; b=VIPVrJ0lWi+3ctvCKHPhs/9IW7WQGhke/VTNoviYZ2g21G5ZQvIU+V57qjxGsxmjRVN08l XvLuGXbqfoLAGwXYsH7A5aNnfyYGPNo4FGA98SSKpzJVUvqL42Z8Z63CEAVsJTBqkbMj2c zMoN5eKT+WOoG3GyqW8ZVn9nGMi6pbI= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="h4/d94dF"; spf=pass (imf14.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711096498; a=rsa-sha256; cv=none; b=3xY57U2lQkiciRKSR9BAZK4bJl2aLXlAYZNFCxl22CUbCbhf7oJOo7PBgHEigguVKmR51T 7RkCezRFofLMzYai225d6x9Wtp+k0HKSecIwEhxgbh2T5PyWnbBoE1RldxNVZeXpRA2pLJ w/bnwhYaBUrblzKZE1QZj6FysOJnZHA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AEA8B61423; Fri, 22 Mar 2024 08:34:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26435C43394; Fri, 22 Mar 2024 08:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096497; bh=WVA5iQMpP6XRPAUdm6BGPXwO6vUlPgINWjhmK5fNggI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h4/d94dFJHh92jVFstIb123+K+uECJMzjhO5h6qNXziYhpASueY+JlCKsaASBC+B6 /kJdoOCiCE9/rxMx3VTLNNK1Dpd34UZDHm+FWEqaJftEAHTC+UneL2xXg2HGZFNUHH SVcA+FYM77wBYYMu6uTlKeYWFjsJhs8wJfd6mbR6slOLLb2dGCEg0O7Rbfjw5kEDmw VIA8AsLhzenXMSa8OzzAKuSoTa2rW3/BOkmCBllehPo+yTPgSWRNyM07qug6chSimL WEgTi0VvMwYWegCZkEERh5MdlBztXBBTNm7XvJcjUUfg/eP/bZe+UzB5S/hrpwq/ND namI+bYeJFPvw== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 09/14] mm/ksm: Convert stable_tree_insert to use folio Date: Fri, 22 Mar 2024 16:36:56 +0800 Message-ID: <20240322083703.232364-10-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 75738100012 X-Rspam-User: X-Stat-Signature: zx9319uknrf7dpgrbys86sco385gy96p X-Rspamd-Server: rspam01 X-HE-Tag: 1711096498-461546 X-HE-Meta: U2FsdGVkX1+c0zYvaydxf2x6QyfllszAYU2zPB8u5yJhgo10gecbGIaMtI03Z27HOtllDn/shqM9ux7tudMId6Ss1u9GPch5zKV5D/QFBxpA2yePVJ2fY0+qkpSDIy0YbJCyK+dowAaiaC2Nwk+Lr79Jey1t4nNcT8qIVuKfKG5Xvh981F55cqZ4VWxfjDpkc0ttLZVPaFfsXMppIZi05JJ6Zva+Yxf96iLh/5DScCIFJKTo/k/fEjQBvEqVfZLqwsrtKwqbvOeYoGvW1ozfeGMd0e/NwM7oGPP3Lbti+p3lrhdNwQDo09JqhNx0Y3DmModq5NJpax00DOUQFD748TVh6zx7828wDJu+3lzlj1UVDZGxc1Rs1rcRaN2WuZFyhmmX9AwpvzV4UowP8OPrZxWYvmLzEkqhiyWpTTMULNFEYp+4CFwLvH/ap/fBYiX8DCXzce+k2ft3Q4Ho8jltzeDPUf+2MdylpSaTFe8FwMO/Wbd5TntW0mERZ+KIlzmeu4LDER0e8t/dv7jplCSCoM14Um068tjC0bgJIywr11XdJ0W7vrHCNW/kiXASQ1YHW3DwRAelVkt0ezTiO3rplPB5rRIbCSxGb0TyZnxLbA4R9JH2JSKvCuQzC6ypX0LBqTy07U+uqLA1znr2LtAZgjTgUv4dJvf54NvbTQ/sviMn9kyMdPn+JBKNTtkPNcHSwGvGk5k2LSb6wW3s8LJOgfD1RhcDYvXgzuS8sJpIBfMihO4CVAttk0juCI+vzLAqtwxWU3xzTBZe3Rc1DbC2o/6l3pvv8XIG/fSgJ2bbey5z/v+rOyDRhp8ROwGDTP3wa2Tgyv8abEns/6pWVXrEKSDugmHEvnb35ABGIwqxIfHsYQkkYZ7Q/AJbYaMKwvt3knVvqXAJSHViNp9rmQDEKJMFsBXStbZ99dFdGWQ1m3KFtSq/hwvUxWWK9ZJIU51LW4VNC8VUX2XPoAz7gQ6 J5l1S9dk uQ/wy 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 30570e1f68ec..e6837e615ef0 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 Fri Mar 22 08:36: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: 13599737 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 37E48C47DD9 for ; Fri, 22 Mar 2024 08:35:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B98546B007B; Fri, 22 Mar 2024 04:35:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AAB766B00A1; Fri, 22 Mar 2024 04:35:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D6106B00A2; Fri, 22 Mar 2024 04:35:03 -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 72C786B007B for ; Fri, 22 Mar 2024 04:35:03 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4BCDA40C0A for ; Fri, 22 Mar 2024 08:35:03 +0000 (UTC) X-FDA: 81924014886.18.E69F204 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id 913C2C0022 for ; Fri, 22 Mar 2024 08:35:01 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NxgLxxat; spf=pass (imf10.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=1711096501; 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=O4+CNYBiV8ESo7ClEjsaF8u2fKS65m2uzzLH53JtmBs=; b=tYXhImA5RN0PPDnQyo2Q4QYgl6rqyJoD1IebV6A7WN/XrhGfqDWsuFFPgO7LGc/waBQKip WMF6EQNoCCDZsOlHkKXZpq/5ctDGSLXON6B/WC3dLwSfSHBHZqXqvAOdRKmSuimRxh4JtI 72geE6hyt5IarZ+zs6C80A7SnX5JOwc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711096501; a=rsa-sha256; cv=none; b=3jafrSPCQGxeldIOpHxSHCZQ3tkg9aYhIAm0YelSKRZvSpS2dp2ZwnQynhTtgMu6DgCFUd oSezazk7C8Gjr7BtVmXtTfgu40/utgC2+qsYJQQVSV9ZIpnCwMu+mhm1eAeG1riwpa7lLa CL5qs1S4++ICHQoHpRFUd9MubGSvO08= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NxgLxxat; spf=pass (imf10.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 D6AA761426; Fri, 22 Mar 2024 08:35:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2ECFEC43394; Fri, 22 Mar 2024 08:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096500; bh=tE7d8xapWcivudbf59T+rNoo9gKt46dsnpm72y6dZEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NxgLxxat8Cj4ildJ74x/Fd/oyvTl1lC8ltXuHcrbg8hA9W1zCZaJwjeSNy0rn0GOA SnyH5kIw50hurn5c6Vaan+FsIrUW+N5/afbMHvwifwhnnWZeEQNmCSQf6BpVtapgJr e1vIoiyqsT+Fd/JEnk5QypnCg23X1NgbzqS3mBCE267Cpla60qvsZX7Dz4cQHrkxMX 6kmj9zi4Y/iNjz2q/n5RXZtusItg5eiJ1Xl8TAeDTXPKOXSrjWXweEa1YAH6GP6x4t 7vVZuVpgCZBXUunmMK/veTVNgUvUx4zqzzis58a/Ce05HwTSQ5nmNZVG8giIaaqX+W tclwJALa4D3TQ== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 10/14] mm/ksm: Convert stable_tree_search to use folio Date: Fri, 22 Mar 2024 16:36:57 +0800 Message-ID: <20240322083703.232364-11-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 913C2C0022 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: tijwxdcdzo6x9k1gidju94tmpp93sspm X-HE-Tag: 1711096501-566841 X-HE-Meta: U2FsdGVkX18MAThZGwMiodwfXI0JLgf6wbNkvFCiuwXVy7nE0lqvHRwHpH9GWyKoWtfJAVKMFKjKJZoPxGMxd7pYx64W39cmf3WcjVhqxzigVYeP7S706sEo+BkcEOWMHwxzGUid6rpr3fQ3fPRm0Z2PmbDmsrzRnhkLKpBA181Hec294eZGpBMY0J6EJqKPVXn+ppXJvLN+ZSx5w22TmKWJXSQibcR9T7nNaBzzTYVsrUYy4IKpoJAnmEygWFHfxcybU0/hNPtsbojSj3q4H8aqaHwb4SYYrOIWWTg5ZO5FqoCiNH2+KcDRmTnEmSj5P6S34mko/5D1eLVzFi+4Phy0xhDuemnmy/RvdfOXb/1eotPiGY6bqGx8MFKpqixx5rpT001GMQzei4YVKAYdEF59Ef/oeet46WATI+85pypFzDTPdG7H5qvzuG4jxv+jpOt5v/Wh75svRgKA4epBrotg61EKRlJwR+KwpnIqAoldfOuJNiUqojRwYGy3qoMZTEiR34kS3RiR0sE4R784/nWyN09JjY6nVtzJc2hjwaMGRvUOcpANJRHrP2Eg3+z01/g4tozAf7ZwTPTwFxEcBO74sjofR9lagjcfbvi9LCH7nEiU9lo40X7T/o7sTXya0OKvmGk8qtsLXbtFQzNafn5UilwYthabozPqp1KBnC+/aQVkytqcXkDOE7cs1r6GtZ3hi7EWqSqgCAgwkJTF1KIGMvtnb+9uKVuPeo2L8um/QwBMWbKcexZv8stA5qPYxVloOTAl4hRIweZ7fwX8He/T78wz28k4bxGOFDx+9VVcYxd1oH4eLe9Ag5jX7avLPyEo51H07QAXbLLTcN3agKbrouVxntV4r6JngwNBvgFzt0D0Q/c0bR4Xp1yMa9HcMBxT7DxsXcVfNfvapPiFFipU5rPhSzt+GMW4re9xB9WEywqY/hN/OrGDMpey7l4gtZNxdby3NeMO7KJxGeV hcP8gM1U Uy4ejePMNW1vq1F/hPr7Oyhs3UBZyMpuM/C1ohU92vqfDklNq3H8s92R3S4lMW2WpU2FRYkWMUktDTJqi2QtGTnrZJ4Z9NGjkUOiOWsmO/bS4rwTrYcFrY4XimN/xh80VDOIHcCWHNtB0fsw9C+6wRg4YrpE+amIMUkvdZASLX7m0Fm3F/8Yi8LfJmOYUYChb7WXUK6nlF37YcBEjyTdeJU66yy+27zmZ5+Js+FXJswyARkUAfa9l9pGsPQuJ6eFwl6nMXWKZk4QDuUnyMhIIAtzNjebHxmLpmDYAyKgVGPEV4PwY3JamziTafcYI1yWI4ERB9xCs2Ap3Jn4uZJie/2I/kQ1Nm8xbyNGYI5MmyFUT4I/AudSmRy+mOLFhlFt9AzABC1P2Md55rr5UfHHKudkuCSvf/UJCLC3lFv3phPulkxhF+w7fHBEmD/uHW5u8S0h1Xw6JkLaf7LtfkRO0nU38E2IwhKN4ongtE/MSPTf1e3yRdmhkTuSlpEryh4PUQMCN 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 e6837e615ef0..0692bede5ca6 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 Fri Mar 22 08:36: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: 13599738 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 19241C47DD9 for ; Fri, 22 Mar 2024 08:35:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B99D76B00A3; Fri, 22 Mar 2024 04:35:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1D196B00A4; Fri, 22 Mar 2024 04:35:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 973146B00A5; Fri, 22 Mar 2024 04:35:06 -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 773846B00A3 for ; Fri, 22 Mar 2024 04:35:06 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5763F81169 for ; Fri, 22 Mar 2024 08:35:06 +0000 (UTC) X-FDA: 81924015012.01.92BD4B9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id AD84D2000A for ; Fri, 22 Mar 2024 08:35:04 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=FE8y6dUc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf03.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=1711096504; 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=t4pGU2VEOwJh7Fxc7TNUW0udYTZDkgymt74V8DAfons=; b=BG/z6b3hw/oYAkDESADolaJvmyZnkmHg8IKZQsZxClASAtpbBVnWvlAinDBFUqKklcjyu1 P3NODfEHws4odLcDBwhayWHni4g+vbZr7MKqfGJPd3WQiC6Drw8MPdcOgruAsoqcGjRuoh svDiVnrR9h5fM8x0s+vosw5CeV2XnBk= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=FE8y6dUc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf03.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=1711096504; a=rsa-sha256; cv=none; b=3XVB+YqEF9Irm6KP52IufMrmAy+wkTKYXQEFFvLT/EwbkSkwhpoPtEwp2LcbKjhUWytQ+9 ClZz8PacwuUhE4nTEV7AQHDv/a/Jgq+oS7Q7hzdG8NUtIPGR45RlBS4gMX8aCGWT3oZ7pY 600MDjVwuhO3Oft6LeLEFLZjkZ218ts= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EB79E61407; Fri, 22 Mar 2024 08:35:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41FC4C43394; Fri, 22 Mar 2024 08:35:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096503; bh=OQPoYyqG65JjgdV3GI4xIDPu6WE8F7QAfq111enlmHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FE8y6dUcnrwOvrjSqoZfUtGIkZA9NFddagJQg6rqBl50cP0LbOnPqZl8yV67gnyTr CFOsvYS3sekAjUnGaaf0UU8qaCwx5LZ6HR6A6vvSP8n7woojxWf/BiKg1RE14V0Dce k4NXLyenhP5ztZR71GJT6r+C2lQHpcVhLTmFJJY/fJ0KPu/LppQFfMKVvbxn45dkrr x21PByGcOiNgNiAjSexMAi2rleYLB9pwrCeyHivrhu35RHCgTV8k1DfTHAXX9ZptS5 YoChjPk4azvx5NCK/oZ9D1PR8YvKzDxNO4zgknce8OgmStaqwRit+uUyhOHMaubTG6 Myo3Bak3dkwwg== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 11/14] mm/ksm: remove get_ksm_page and related info Date: Fri, 22 Mar 2024 16:36:58 +0800 Message-ID: <20240322083703.232364-12-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: AD84D2000A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 8qf48fjiyhqihihdcncr37u71r4arhuw X-HE-Tag: 1711096504-333489 X-HE-Meta: U2FsdGVkX19hJHQHsavV1Uz/QXLqpVlKsHsKuh2Vye8uqLZgvyuwZcVfi6sAJ/H+CRGElE2BapvJpoD0LPD8QeFrIUyf8SanKE5gshgIjznlG2UtCVUJCvZsL4X0kH3zR+t+ImPgIO93SP7i4RI7f7l4ceVNR41AoYlNmAIxQmwOeLPaPUNLUvG7XiZdYS0diG9PX8yxy/35PoQsTEK0iWnWoMBnewEGZJsU0IaM8iXiPTSXZkqN8FdPFLuUfUXmu7PtkMIAsMzC3lFJrLunOHoh+pt7oNzQedIDGzWfpABSAWH657xPxfm7rIYMP4ll+jvfvJcmOL8CW+zuJQ9Iskrh3ZvVOn+EIWERHVpKVVHcFEJFJGtmozbTXkadbIxFKIrt1aQ41ajSh4i5sRMrEic+tS7pwgek4LXcmIOMq2hneQ6T1NKO4z/wTo1eOM3URrBR0Ho/nOr2BWdFkFMw1/UwTM4YNBw0+4leZ1j3DldSArtjo92Wf5M1FfgCdmQe3ldGfRlCzxP3TlLTO77HMgpSDRGimHS1k6TkAEkEb6tx9miaq3M6PbAncuEUOSGSxXX8eIzPOvvAj/tukQmNne98H5uFiajuf0iq5jweZ8aKxaNDnjzva8qT4W2E00CB/68XzxTSI6d/ovHZyyIy3o3QdeqPbjez8Sd4ZLiOzbqCL2TyFF2Un3TKWr4g5hJAoV6Gannc5S75oExwmOUHqHDYWMXXKy8awfJwuPvPecaKo78vWIyg9CsWRvaAjxgehyczlsOXBwlASkRq+b2LGl5p0acLZPexzXhlxmpg25HE9sywjUvpxrgKKIruo9UvHZgqkNmZfrj/x0XcCi8GxYlQL/lH1xbzU900xDNAWG7vUnVc3mMzVlZlIt5FH9GQQrSOZVyvKdFovUvbC7dGitODwUSk6b84vtt3wjYikNn8AkPtquNrRJAo7jxyVq5pHvNg3/yAlPFIf4BM55U QnxA8Q4C 1WywM/5PiO0mRWtOxqmOU/02hTxR3MR4//16T2eMPCF3g0IBYVqTWzj+bj9k6nkuDooQac14/iq31iBJ5UXxcXrxsGfpe/g08/YIigNI7a1PqI4DDpvEpPC6KzxgpLDDl4KZqG34rHldyZWu5B5Kwk0un+dVUeKdksDSWxNyS+4O5sTdd/vjZ6ERzWDTFFbEK2wN25hV+M8TtkAQuPb0O1wmVT1okX8W45bGL1C5LroDgPQ4DrHBB46Ae0rgCO0GHnXp1sbtuK+u6qXrid2754nKr2Q3eYtAm0jznDie0YM6+4sJF4VtxcD3KKO9ukXHJUedjH0TvA5A16F0avkVWxKcOVleNcPQ3OPFFicawQnZ5yIBdYGyvc7po8UEEIp7sUF0NXohzidzmunOj+WAbD5JH75cCSYfDUy0TwvWjJ9+ylw+SSdKnt8MyPZSVcR+0b/j9udzKEuOzCK4W23I4ICR7pgpUyxMPCYNxob+uQ3nqH0H2miZzt1EwRn9mKDcrFgd9 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 0692bede5ca6..afcf26510669 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 void *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 Fri Mar 22 08:36: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: 13599739 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 25D6EC47DD9 for ; Fri, 22 Mar 2024 08:35:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 380336B00A6; Fri, 22 Mar 2024 04:35:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 30A176B00A7; Fri, 22 Mar 2024 04:35:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 137466B00A8; Fri, 22 Mar 2024 04:35:13 -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 EF43E6B00A6 for ; Fri, 22 Mar 2024 04:35:12 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9A9E9811DE for ; Fri, 22 Mar 2024 08:35:12 +0000 (UTC) X-FDA: 81924015264.18.7F08DA5 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf11.hostedemail.com (Postfix) with ESMTP id 5FAA24001B for ; Fri, 22 Mar 2024 08:35:09 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="fj4/oAXX"; 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=1711096511; 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=+Lap9gokREHM1CtNYHdd3OK1hASI/gvEjkP56yp8AbE=; b=vxdP/guoEFSkTb41WiE3c5hNpS/46zOgwNdwEhjRaFP5x3jsPaQgeCx223JvRS2qAcpYfb XNBfVX6YbcAOc7hiFxy9vWkTmP7CSEWp7kL3QwAK0q6jYQY16C+nvuTy+Yw0yMAc1EDbYC Fpse6hGs5r5Z0XlA1VlI+GCduAYO2nM= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="fj4/oAXX"; 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=1711096511; a=rsa-sha256; cv=none; b=iSeF7tl7ZJ5Mmyyjpe8qWM4ssyQW1IGYYdf/uk4QG4YZqgGSX9/Wz0iE4Jb7Gk0etpFGZE rYm3PlHrgiFk7rf41pfm6GnJiDykyB71klqqMcaJVNiK6qd2+FGyFwwUB40tFBxLe6vIlI 3w0WK9yFEWn4gre4BaM0bXRuZpif88Y= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 76814CE1779; Fri, 22 Mar 2024 08:35:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45DA2C43390; Fri, 22 Mar 2024 08:35:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096506; bh=58CYkIGbUXi9LAju+yb3HIaI5P0/xOPsOLCuC4bYl0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fj4/oAXXwJyK+lHuDuYpq+4X/X/wDs8aqMGx/io2Y3zhIpzKnZ2W8eoxDqdGLWBQh HwOg4I/Ld12Y6pOsSFTvCvXolR8RtLGSxIn4SsrsivuZhZg2LXyp979uG+TYpMIO08 Zmam5au1soDjXTNv/A6/P1VgSggAI7xIzJ3UxNmqGdXRLrVNqpj0YYKIDl2Oq33eyw FyEneaJRsoSxoubL3WMyaCjxt/SetSyb5la5KpXDdNHkbmk2W1A3g2ojs8q+F1+80Z Z+Z9kFNFmk980SrvTfKIhObMlUuK4Z+77hkFoOHgVGZUOzOnsHGQ3f4zX536gcsn7n sANRg6w7jqrIg== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 12/14] mm/ksm: return folio for chain series funcs Date: Fri, 22 Mar 2024 16:36:59 +0800 Message-ID: <20240322083703.232364-13-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5FAA24001B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: wrwz57mtowcfqrkb9deerb36dha5tkim X-HE-Tag: 1711096509-2859 X-HE-Meta: U2FsdGVkX19atslSObwjZ86h8BBdB2dtQoEnWx1KoY616Kdrm6JV6cIXxCRl0gvyYVQynWT2N2dDK4eGFYHGtDnTtBpZ9MqhizkKUYTyMekWyYgvZVMMy6aoTGZcqWtxogkw1jki+xDd3M/anccf8zCxlRpfqbwpVtdkcgvFCrKFx/TsRv5X5JlQ4XBj6MVHCTJqUuRRN4mk2HdxoXncZi9/7UUlfy6r+tY5ryOUmp6tIurD3MWbY24di+s+NRpRa2LeY6iiOZjGicGFEissRO1UaWNoj0q/5F07kBKv1FCl+lllHMjzadLdhQ6jhro5pljYVO/kydGAXrKrNA44BDf+cX1lwj7SaN6YsGaH1zRStWjP5z7cFU/u/BqfbvFPHQ5Qbxww83X8XxELuDstWKqGYkQh2MZHg4t1DLMlBTcIMrrjIcnSfletZ9G3xObLMdfu/hwAOsQeCd6GNeqyydlf9ouO1CQrSwlzVfxSN7OdUEeralifpFsQaP9Sni+3azJ1mn4jG54Kw14DWNbz6U+nlHTaRbaX3JLUKIrUKZjE5yVxhfX0theYZZeH+ms7Dp7sCd49Qer0j4BsIGBYjm9tiKB4APqUsW+P0yyaTZ0oxtz9gNMDOaU3Kf97p6mvsjXJOtgw8ndTFzQEo/i7P9LSm8D4e3IGSJeWk2fz69vF2eguZNSmoI2g3FfkjSpb0D6PzGzCVb9Lwt6vwM+OCoErnJ1h3ux3OTL6bRCU2Wrz9uz7uZJ3x0Vx9P1jukIjMu2WxcPsxNj2x6Hmh27V8fuFHhzv8Rybc0M7rP/usAz0Gg2VoHHSnX/y08piD8VUb0mOtrofxEF/+130sdGiq5zSOPysXw3lD1iyC+eCRLHXDIE5AOJvJTxcu3om4vXmha2mmAhcv+08R6FRe5iS1cojZLhowNEzBCf8GSZmY5B6THJM8nS6t3w4RhyjdGSWsqWH0oFleFOmz3gfFsV 98aqWcEO XWqR0XV1pQPga5eCOJFitni6Qjn1CsutVlKuaUHvo0gePpfG0M9a3AHd7SdGbY6aLPainhJm32paOvkNXQLqdBlDKzelRKavBvGFm3RZB3+bB8cIZGPbWVlyojmK8v4/xquGnV8nc0jyB2F8f2sv9NhtpQh6yRcs0pYR2FgqC/Co4iOEwo83r1PpERIYP1XZabvVERBdqrgEBLBkKvVH0YyV6PicS7KUyGHUOkMqOSmMRIZ6f0L61z1rrs3FF6NTvyEyxufU6gDK7v2K+8HWPWPRDqY2X+JpsrTVSdKsS5EwDZVsGo5N0QPTgI4T3xTyBtXZ4YAeVGv7BbEF5oHVsTQQ5+bvqNera/81iNLIOC+AurWzZBE/y+5VY0VqjDF6IBS2BajaLuDjWlmrgBzC/WW5ESgH8cadlNuc8ztIvTX+1zyaXIYOLw/j+xvVjRRv+jXXPruW7R7kGLUY= 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 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index afcf26510669..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 void *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; @@ -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 Fri Mar 22 08:37: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: 13599740 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 2BA51C47DD9 for ; Fri, 22 Mar 2024 08:35:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAD4D6B00A7; Fri, 22 Mar 2024 04:35:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BE836B00A8; Fri, 22 Mar 2024 04:35:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 810F16B00AA; Fri, 22 Mar 2024 04:35:13 -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 5925C6B00A8 for ; Fri, 22 Mar 2024 04:35:13 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3045380568 for ; Fri, 22 Mar 2024 08:35:13 +0000 (UTC) X-FDA: 81924015306.24.9C14958 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 6A21320026 for ; Fri, 22 Mar 2024 08:35:10 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iAcwg2U9; spf=pass (imf13.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=1711096510; 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=k9DmXlNRXarnHLU7T3zxO1vUmMl/bFcvLvIQJkfuZba98PF7YKk57b7VPoC7lTx69DVkDE 5bXjZ5ZP4ta69wsEVxmzeEeksxoNfQ2/EajV2mzBWhhLbDvGpCV9B9lEPp2EUfALGZwg94 ivLdhSLk4n/47xc6tfenxD3bNWwRxDw= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iAcwg2U9; spf=pass (imf13.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711096510; a=rsa-sha256; cv=none; b=hy0bng71z977xfnhaHF9pH1uLW3GzrCC3nISbNtUZIwAHR6Qlf7erLqIzR2cU7ar85/G8Q YdrwqXrhE726TU8exKhb9NPuUpNEWI2aVcdkjf5PxJC9XtkzBFXO1jc8UNRuv2c+S+G0o2 9NMOg4ZZSd44lX40AvYbVOq0uu8eENM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id ACDB26143A; Fri, 22 Mar 2024 08:35:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 484F1C43399; Fri, 22 Mar 2024 08:35:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096509; bh=ZriKAGE58KVGgk3LtHqsYBhdOJzv7LI/X6J606D1xxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iAcwg2U9TA5i2WgtDkxRMvKzkar2T0ss4NV9QTixbCGq/vdCNstF1KB7VAtunrssD roMaD4WVS54iqRVPCPq+8eu/D56fmO+XQtn/NRSeXhJuc2PfZCkA/BLwhnS5EZdZy7 y1acuH42/rzI5sikMvS+UcpS+RP522841XB3DOjkzB+uGxSBmrjUq+InQ67lNY75c2 v2AOGRLtDpSo45fcsKX+d5T7ViAUoXym1Jh4dNGUDI51D7Y9GcF3fNZvf/bPUPFI5K sS9y+mlzPqzI3051GE6T8aiyK68i5He/zcTKNaQfSGI9ORdzAnckSHwGeYYok2i8Fr X08VhSxlTW+Sg== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 13/14] mm/ksm: use folio_set_stable_node in try_to_merge_one_page Date: Fri, 22 Mar 2024 16:37:00 +0800 Message-ID: <20240322083703.232364-14-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6A21320026 X-Rspam-User: X-Stat-Signature: 1ot6s7866zqfeqtr17zpbotki3uub3jg X-Rspamd-Server: rspam01 X-HE-Tag: 1711096510-268265 X-HE-Meta: U2FsdGVkX1+3zWTRAlJ72NqLPsEpoDvbWZzYwKE82AgtPf2/RA328Qi/jNUxIR5Q5AEbGsp+M2QLd9fuQGyzDignxS0A3iBiDzzFibdxhvOqUrABTKkK7k18qSQjlv5mYPDG0C2y0s2oMNAV/X38vyVsTnuszGALBxsgDTiD8bg6YHfPqng94wShvOOlS9A8plqt2XwQcKNAM9RJDQZtHhbn/JYk36hwrWyCLoWNQoU2YdvEAeOVienv2n3VBFLango4tfEQS+7SmuZ1YJ/yhceDb76AuVcB9AOAPmeYKY3RjUD6VhNQpV89UVOEBXcfEuZAx4HaofNxb+3N4Q/tz62k/SJUSU0VwJ8with5bfjYjg3Ojx38k5uaIa0PzUOfNnP2AwNraFG1eJczD1bN1+bVGCPtd+Vhe/KvNhJjn3yMMe/+mJLGZdPr8gYlTyY/2aCGIZSz1UZgu0CxorIeS4ODtFloVPExXMViMrt1GVS7iqXkxQLozpTWTiHxDNiu7qY6tAWsytPKTSedRKaIB99uS3UG6BFTkL51So3Hz/TA7TixWo0BJOenmiBmEfMBj4M2xfG1XWFnhnfr47Kwss8Y//EpoUy+cNfEPZYXUVocvw1YEbmN1Kl7zy5i5hgc3eLza/sk0fVQ1mDsxJ3qfkeDOYDnGqEvB7gc6X4AwiwUMfeF09/a3oMwy4CI7nRAkJIkU9sC+t5ikdyP4xgwCmPiCKJsUkfm20eC3l0ShuzpCSamW6M4sSo/zc82WDY3HKzmu4sm8KL0VH2YFAXselHO9+4oWarcKrxhWoiYH4bS4nZF8FOCBxXUj6drUZtb13olKDecIZ8BK1lUqbZO8SCIglXDMMQzF92sCzzzjb5Z1lQ4x1D4WzABVnytorxI4Jy+zXfa1xd3HrIJdkUqgzmDrO+hrdVEr4p3MrFFdO4IyJTaaVIdI+JkUsudCaOmZAV0MUAi7Es3hAIXw87 AC7RLLuq 4QSpRE+JjdSCDtuvHWxroxFaa+sQaDKLN0wij0q1ieDtcwYCPCbqTwrtcsC4sq/uj/nbK3KT4ptOCPtSpNw6ck/1sIHKq/mp1OPqnRuQh2QQY1a+jr35YTFNX0tIUUuiHejvrFnE9Q4/zf1WECd62jEkIplu3Ljf4u0Y+brTE2chQa438DnxbGUj732VTKaEohl0GuBlWkOTOYe9GZMR0TNlJxw0cKStlowu6xsZtkvS0Huj2yhhgbwfOWJwtOQ+3hQLiEm7Ptjbn11ofYfpcugGnnr4uPbxP9rto5TGu3LCio4H44D8JQqNr9QHfm7D6QVXK0qk/ods25Vo8hnLB6DlQiBjC4p35nwlHbsFn1BlLPMdLXFlRMRZT7wUifTeiJUc7BFnNj/bXv8PSQgs2F9T66cH4wTDmAaU7yc1d8iMoW0cWTll9Z+7y0AohTwaltrGSF9ffksswp+vwYMnnplU89e4dfCbWcsGK/H0Q6K+EjJMFlBWCAXMf4ZodhjqT4Ubr 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 --- 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 Fri Mar 22 08:37: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: 13599741 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 04D8CC47DD9 for ; Fri, 22 Mar 2024 08:35:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 618CC6B00A8; Fri, 22 Mar 2024 04:35:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A1D66B00AA; Fri, 22 Mar 2024 04:35:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4436E6B00AB; Fri, 22 Mar 2024 04:35:15 -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 23BCF6B00A8 for ; Fri, 22 Mar 2024 04:35:15 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id ED3051A11ED for ; Fri, 22 Mar 2024 08:35:14 +0000 (UTC) X-FDA: 81924015348.02.1894E97 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 606A1180006 for ; Fri, 22 Mar 2024 08:35:13 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PhuQzHg2; spf=pass (imf06.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=1711096513; 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=pmUSpL3QHOSykPGYv4BenNyoClD+UCyO0ng9JAI9eIlYwBUdvSfQWhbknKBfE3v5kwluW4 WHFZ9dKJAutQ+/VVhYbImqwefVeeEb9DsGv5NfRPKGLFvB7ws7ogcsf3vsxUKlGNOVIOU+ LwmjODP/TWXmwUueTGnZ0TQzvi+wn84= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711096513; a=rsa-sha256; cv=none; b=xGm+dAU0u6v+z3/Voiigc8GJMl3c4gThryKTHmVgF7iP0lIpWwngrIm5io8qBaAG+nZADK zB2FWOO899De/mFfWvafwZRE1bvBU4Rb/O4VaAjpkZoiWFOLpS8SwwEz1q1l5Vs9OnpgZB pqzzfgXVTmakzc13ho9HBdvseg80ZY0= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PhuQzHg2; spf=pass (imf06.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 A37036142F; Fri, 22 Mar 2024 08:35:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25DC7C43390; Fri, 22 Mar 2024 08:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711096512; bh=S+tu/Us/naajLYwRUmTRqpD4Xo/mrCDuxEPxhqR6e8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PhuQzHg2zIDfH+NNdpucuHBPSFDXUngQkMtXneTPOFB3EXsUgkeeJH4rsslCkfhG5 4wFPvYbHSCE1xnudBCQq/bBl6/P0nYNJuw0bYM9e5eLZxxb+YECPnd20i5Txxb4zKs gGttqYPNlKI/hzAMzVxPjsOAuaBXmXgrApgVatUr4bxEiDjBVgiiVca6abAnh8U2g7 k7CNbcR2g5fpVxGiJbyhueHZGdKDDJIz8FplT+V78W6m8/Vb9yRVw27y5h1+wbwVth M0199e2qvjbnu+xUqBsqOJYP3AyHoE+7ixgaOs8916eariT5tsdciqmT0QRoiDGDPy kyPPjQTt5vogA== 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 Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v2 14/14] mm/ksm: remove set_page_stable_node Date: Fri, 22 Mar 2024 16:37:01 +0800 Message-ID: <20240322083703.232364-15-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240322083703.232364-1-alexs@kernel.org> References: <20240322083703.232364-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 4oai4zfqma6uyf95i434dtj1gffkf393 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 606A1180006 X-Rspam-User: X-HE-Tag: 1711096513-162719 X-HE-Meta: U2FsdGVkX1+PwgMT0S4Ew5iqqcVkd6LTrPnOlvaFOP16ngOc5noOmYDuscGTiwzXtBAGB6DnzumnyknINSKP7Fmd+WWv+YJhYWOJa2s5VwSyXYrIKS0Yv9mGnoWXPA0xNol/xkCg5iBr/L6mHLymqgPPJggWOKZ64YufOVKp/uhtV/cJn9X86h2G5v85dtfECAujQotwoOdlGzsFEs/2gel6EP3aZk2wCTZkA+jSe9VZ4NCVc8hKyoZOVT39JKRYsoXuu6bmyVoa2OQDuGmku1SoSZSGCHZKGuaCvLO0LhoO5cVcfAoYT5A5mVHmG3gV7Lz/cdKZq/tiRJ1URr9anovq4IurP4+RH6gM5Mf8wSi9HwzItIeSi5zS3fc5GOK8/O4qeeF+gyeKSiWYSAL6WvW6yUrfnQjf6F1+u4ww/y8F2vKgtRHMgvMY9HqCzOb+26MQM7RbFirhMdSS4ZoTIH1p6FzAIjACk27ZC3UGry0/zVGMBgy+ShG9erKld+JC/Rac8JBU/P0mTzLsktQtkd2RQkFiSMPZbRnB+mfWwgsRr+KXOTdHk0NICa4Gk4u+B6M7P9cYCVcDTV9a2ZtXbY9t4Zy1q0vXPsmotV/0acqXb4IU4jwxzkrWBUxaVCZk6OK+oKLaTcz2RmRyJkUK/nxL+30Qk2tpdMHsllW+kNA+FXx5NuTwrAR/+u71qACKoc/nqixhMp47/ADJCWX6jj4ormMNIGTa2Wnd933Tb5qX+fjlZh9ZZTLDNALnPBUJ52hTNy54bCB5j79dvzSL1tc5uZhL0bK2Cviu2HzhAOTH19ShebYLvAac5P7vVlmPZWgtSMVNfNZSCo68Y7+DQeR5FpROclWnhWoxVTPKfIL9EN1y4ZDlMMWPZtiDSrzNxxFyx+p3ZzEr34Yj0a2iyJVyvwAOmxwjWNYFeC0F8lGkhsWVAo5ePjQFK+tcRLfK30iLkVUo4Q26M8IV+Qf SyvVZay9 thBh5JBX1Hn2CJnvwB0LDkkwObChgPMwtXY8KRh0XmIHbuz1t6AD5zn+/u8MA8Yt/l9vCiwc+GeqxOUzMVAPoP0k/tyn+mYZ9FOLqRL2Tyq7RdV4iSlDH2fGGpJnxZ9cm/gvFAaMsNczhxNYYeBBFmaK3NZ8IbuVOYbItYfV8moL3ztuceHgSq4IDbVX9kHrqjyy/nDsy08LhdPNx1ByPyTbzK/ueEDALGRQEXS64d0MhbJcHU2hQb09I0vTZlffF/vqbV01ophAdfrMyEJ2F1cQYqb7x4wBaxVa7Bab4l+Ww/BZToFKzKZUCjACWCrkHKsyyAeJodysW5MK61LkWtRQMXnces1SqmETvfpLE6acZwdU19vXxCk0SgH550NWKG28qbigX3MS7jnD/CaLtzWI4BU60IG2bOi+JLhZVzhhpedJ7BR60ZwPOPDZDp6dvu0ToG16kRRF9yhz+kjIEebdKdfQvzx7DoLTVZaLKC3mPQnOxQxelGOtMhBuK5e3lPcm/u2gq63xz9L96mqux/rWcCnmyQrH6vIzPcxRu2q7/auX84vAlaBKOACdQp+QKszKAPELpRp9NpAVLV8B2Yts7qIR/C7OfORNv9ITgy2RS4WymbEBg06vH7g== 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