From nobody Tue Dec 16 16:23:31 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7F3DC4167B for ; Fri, 10 Nov 2023 03:33:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345819AbjKJDd7 (ORCPT ); Thu, 9 Nov 2023 22:33:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbjKJDdx (ORCPT ); Thu, 9 Nov 2023 22:33:53 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A5864681 for ; Thu, 9 Nov 2023 19:33:50 -0800 (PST) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SRPV373CDz1P8F1; Fri, 10 Nov 2023 11:30:35 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 10 Nov 2023 11:33:48 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Gregory Price , Kefeng Wang Subject: [PATCH v2 1/7] fs/proc/page: remove unneeded PageTail && PageSlab check Date: Fri, 10 Nov 2023 11:33:18 +0800 Message-ID: <20231110033324.2455523-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> References: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" After commit dcb351cd095a ("page-flags: define behavior SL*B-related flags on compound pages"), the slab could not be a tail, remove unneeded PageTail && PageSlab check. Signed-off-by: Kefeng Wang --- fs/proc/page.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 195b077c0fac..466efb0dadf7 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -184,9 +184,6 @@ u64 stable_page_flags(struct page *page) u |=3D kpf_copy_bit(k, KPF_LOCKED, PG_locked); =20 u |=3D kpf_copy_bit(k, KPF_SLAB, PG_slab); - if (PageTail(page) && PageSlab(page)) - u |=3D 1 << KPF_SLAB; - u |=3D kpf_copy_bit(k, KPF_ERROR, PG_error); u |=3D kpf_copy_bit(k, KPF_DIRTY, PG_dirty); u |=3D kpf_copy_bit(k, KPF_UPTODATE, PG_uptodate); --=20 2.27.0 From nobody Tue Dec 16 16:23:31 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B781DC4332F for ; Fri, 10 Nov 2023 03:33:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345828AbjKJDeA (ORCPT ); Thu, 9 Nov 2023 22:34:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbjKJDdx (ORCPT ); Thu, 9 Nov 2023 22:33:53 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F0324686 for ; Thu, 9 Nov 2023 19:33:50 -0800 (PST) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SRPV436p6z1P8F9; Fri, 10 Nov 2023 11:30:36 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 10 Nov 2023 11:33:48 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Gregory Price , Kefeng Wang Subject: [PATCH v2 2/7] fs/proc/page: use a folio in stable_page_flags() Date: Fri, 10 Nov 2023 11:33:19 +0800 Message-ID: <20231110033324.2455523-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> References: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace nine compound_head() calls with one page_folio(). Signed-off-by: Kefeng Wang --- fs/proc/page.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 466efb0dadf7..dcef02471f91 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -109,6 +109,7 @@ static inline u64 kpf_copy_bit(u64 kflags, int ubit, in= t kbit) =20 u64 stable_page_flags(struct page *page) { + struct folio *folio; u64 k; u64 u; =20 @@ -119,6 +120,7 @@ u64 stable_page_flags(struct page *page) if (!page) return 1 << KPF_NOPAGE; =20 + folio =3D page_folio(page); k =3D page->flags; u =3D 0; =20 @@ -128,11 +130,11 @@ u64 stable_page_flags(struct page *page) * Note that page->_mapcount is overloaded in SLAB, so the * simple test in page_mapped() is not enough. */ - if (!PageSlab(page) && page_mapped(page)) + if (!folio_test_slab(folio) && folio_mapped(folio)) u |=3D 1 << KPF_MMAP; - if (PageAnon(page)) + if (folio_test_anon(folio)) u |=3D 1 << KPF_ANON; - if (PageKsm(page)) + if (folio_test_ksm(folio)) u |=3D 1 << KPF_KSM; =20 /* @@ -152,11 +154,9 @@ u64 stable_page_flags(struct page *page) * to make sure a given page is a thp, not a non-huge compound page. */ else if (PageTransCompound(page)) { - struct page *head =3D compound_head(page); - - if (PageLRU(head) || PageAnon(head)) + if (folio_test_lru(folio) || folio_test_anon(folio)) u |=3D 1 << KPF_THP; - else if (is_huge_zero_page(head)) { + else if (is_huge_zero_page(&folio->page)) { u |=3D 1 << KPF_ZERO_PAGE; u |=3D 1 << KPF_THP; } @@ -170,7 +170,7 @@ u64 stable_page_flags(struct page *page) */ if (PageBuddy(page)) u |=3D 1 << KPF_BUDDY; - else if (page_count(page) =3D=3D 0 && is_free_buddy_page(page)) + else if (folio_ref_count(folio) =3D=3D 0 && is_free_buddy_page(page)) u |=3D 1 << KPF_BUDDY; =20 if (PageOffline(page)) @@ -178,7 +178,7 @@ u64 stable_page_flags(struct page *page) if (PageTable(page)) u |=3D 1 << KPF_PGTABLE; =20 - if (page_is_idle(page)) + if (folio_test_idle(folio)) u |=3D 1 << KPF_IDLE; =20 u |=3D kpf_copy_bit(k, KPF_LOCKED, PG_locked); @@ -194,7 +194,7 @@ u64 stable_page_flags(struct page *page) u |=3D kpf_copy_bit(k, KPF_ACTIVE, PG_active); u |=3D kpf_copy_bit(k, KPF_RECLAIM, PG_reclaim); =20 - if (PageSwapCache(page)) + if (folio_test_swapcache(folio)) u |=3D 1 << KPF_SWAPCACHE; u |=3D kpf_copy_bit(k, KPF_SWAPBACKED, PG_swapbacked); =20 --=20 2.27.0 From nobody Tue Dec 16 16:23:31 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13D77C4332F for ; Fri, 10 Nov 2023 03:34:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345862AbjKJDeH (ORCPT ); Thu, 9 Nov 2023 22:34:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234881AbjKJDdx (ORCPT ); Thu, 9 Nov 2023 22:33:53 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1056F44BD for ; Thu, 9 Nov 2023 19:33:51 -0800 (PST) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SRPV46W0Gz1P89B; Fri, 10 Nov 2023 11:30:36 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 10 Nov 2023 11:33:49 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Gregory Price , Kefeng Wang Subject: [PATCH v2 3/7] fs/proc/page: respect folio head-page flag placement Date: Fri, 10 Nov 2023 11:33:20 +0800 Message-ID: <20231110033324.2455523-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> References: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" kpageflags reads page-flags directly from the page, even when the respective flag is only updated on the headpage of a folio. Since most flags are stored in head flags, make k =3D folio->flags, and add new p =3D page->flags used for per-page flags. Originally-from: Gregory Price Suggested-by: Matthew Wilcox Signed-off-by: Kefeng Wang --- fs/proc/page.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index dcef02471f91..553a7c921cb4 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -110,8 +110,7 @@ static inline u64 kpf_copy_bit(u64 kflags, int ubit, in= t kbit) u64 stable_page_flags(struct page *page) { struct folio *folio; - u64 k; - u64 u; + u64 k, p, u; =20 /* * pseudo flag: KPF_NOPAGE @@ -121,7 +120,8 @@ u64 stable_page_flags(struct page *page) return 1 << KPF_NOPAGE; =20 folio =3D page_folio(page); - k =3D page->flags; + k =3D folio->flags; + p =3D page->flags; u =3D 0; =20 /* @@ -202,7 +202,7 @@ u64 stable_page_flags(struct page *page) u |=3D kpf_copy_bit(k, KPF_MLOCKED, PG_mlocked); =20 #ifdef CONFIG_MEMORY_FAILURE - u |=3D kpf_copy_bit(k, KPF_HWPOISON, PG_hwpoison); + u |=3D kpf_copy_bit(p, KPF_HWPOISON, PG_hwpoison); #endif =20 #ifdef CONFIG_ARCH_USES_PG_UNCACHED @@ -211,13 +211,13 @@ u64 stable_page_flags(struct page *page) =20 u |=3D kpf_copy_bit(k, KPF_RESERVED, PG_reserved); u |=3D kpf_copy_bit(k, KPF_MAPPEDTODISK, PG_mappedtodisk); - u |=3D kpf_copy_bit(k, KPF_PRIVATE, PG_private); - u |=3D kpf_copy_bit(k, KPF_PRIVATE_2, PG_private_2); - u |=3D kpf_copy_bit(k, KPF_OWNER_PRIVATE, PG_owner_priv_1); + u |=3D kpf_copy_bit(p, KPF_PRIVATE, PG_private); + u |=3D kpf_copy_bit(p, KPF_PRIVATE_2, PG_private_2); + u |=3D kpf_copy_bit(p, KPF_OWNER_PRIVATE, PG_owner_priv_1); u |=3D kpf_copy_bit(k, KPF_ARCH, PG_arch_1); #ifdef CONFIG_ARCH_USES_PG_ARCH_X - u |=3D kpf_copy_bit(k, KPF_ARCH_2, PG_arch_2); - u |=3D kpf_copy_bit(k, KPF_ARCH_3, PG_arch_3); + u |=3D kpf_copy_bit(p, KPF_ARCH_2, PG_arch_2); + u |=3D kpf_copy_bit(p, KPF_ARCH_3, PG_arch_3); #endif =20 return u; --=20 2.27.0 From nobody Tue Dec 16 16:23:31 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 533B9C4167D for ; Fri, 10 Nov 2023 03:34:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345855AbjKJDeE (ORCPT ); Thu, 9 Nov 2023 22:34:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345803AbjKJDdy (ORCPT ); Thu, 9 Nov 2023 22:33:54 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0D9744BD for ; Thu, 9 Nov 2023 19:33:51 -0800 (PST) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SRPYb14PNzfb7T; Fri, 10 Nov 2023 11:33:39 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 10 Nov 2023 11:33:49 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Gregory Price , Kefeng Wang Subject: [PATCH v2 4/7] mm: huge_memory: use more folio api in __split_huge_page_tail() Date: Fri, 10 Nov 2023 11:33:21 +0800 Message-ID: <20231110033324.2455523-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> References: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use more folio APIs to save six compound_head() calls in __split_huge_page_tail(). Signed-off-by: Kefeng Wang Reviewed-by: Matthew Wilcox (Oracle) --- mm/huge_memory.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 3f74a063f7d1..2b03c55ea425 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2509,13 +2509,13 @@ static void __split_huge_page_tail(struct folio *fo= lio, int tail, clear_compound_head(page_tail); =20 /* Finally unfreeze refcount. Additional reference from page cache. */ - page_ref_unfreeze(page_tail, 1 + (!PageAnon(head) || - PageSwapCache(head))); + page_ref_unfreeze(page_tail, 1 + (!folio_test_anon(folio) || + folio_test_swapcache(folio))); =20 - if (page_is_young(head)) - set_page_young(page_tail); - if (page_is_idle(head)) - set_page_idle(page_tail); + if (folio_test_young(folio)) + folio_set_young(new_folio); + if (folio_test_idle(folio)) + folio_set_idle(new_folio); =20 folio_xchg_last_cpupid(new_folio, folio_last_cpupid(folio)); =20 --=20 2.27.0 From nobody Tue Dec 16 16:23:31 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE0E6C4332F for ; Fri, 10 Nov 2023 03:34:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234961AbjKJDeK (ORCPT ); Thu, 9 Nov 2023 22:34:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345807AbjKJDdz (ORCPT ); Thu, 9 Nov 2023 22:33:55 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ADA64681 for ; Thu, 9 Nov 2023 19:33:52 -0800 (PST) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SRPV46ygbzmXKT; Fri, 10 Nov 2023 11:30:36 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 10 Nov 2023 11:33:50 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Gregory Price , Kefeng Wang Subject: [PATCH v2 5/7] mm: task_mmu: use a folio in smaps_account() Date: Fri, 10 Nov 2023 11:33:22 +0800 Message-ID: <20231110033324.2455523-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> References: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace seven implicit calls to compound_head() with one page_folio(). Signed-off-by: Kefeng Wang --- fs/proc/task_mmu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 51e0ec658457..fe15f99a4908 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -445,23 +445,25 @@ static void smaps_account(struct mem_size_stats *mss,= struct page *page, { int i, nr =3D compound ? compound_nr(page) : 1; unsigned long size =3D nr * PAGE_SIZE; + struct folio *folio =3D page_folio(page); =20 /* * First accumulate quantities that depend only on |size| and the type * of the compound page. */ - if (PageAnon(page)) { + if (folio_test_anon(folio)) { mss->anonymous +=3D size; - if (!PageSwapBacked(page) && !dirty && !PageDirty(page)) + if (!folio_test_swapbacked(folio) && !dirty && + !folio_test_dirty(folio)) mss->lazyfree +=3D size; } =20 - if (PageKsm(page)) + if (folio_test_ksm(folio)) mss->ksm +=3D size; =20 mss->resident +=3D size; /* Accumulate the size in pages that have been accessed. */ - if (young || page_is_young(page) || PageReferenced(page)) + if (young || folio_test_young(folio) || folio_test_referenced(folio)) mss->referenced +=3D size; =20 /* @@ -479,7 +481,7 @@ static void smaps_account(struct mem_size_stats *mss, s= truct page *page, * especially for migration entries. Treat regular migration entries * as mapcount =3D=3D 1. */ - if ((page_count(page) =3D=3D 1) || migration) { + if ((folio_ref_count(folio) =3D=3D 1) || migration) { smaps_page_accumulate(mss, page, size, size << PSS_SHIFT, dirty, locked, true); return; --=20 2.27.0 From nobody Tue Dec 16 16:23:31 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB1A0C4167B for ; Fri, 10 Nov 2023 03:34:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345838AbjKJDeC (ORCPT ); Thu, 9 Nov 2023 22:34:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345805AbjKJDdy (ORCPT ); Thu, 9 Nov 2023 22:33:54 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78D354682 for ; Thu, 9 Nov 2023 19:33:52 -0800 (PST) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SRPYW5dvJzWhCv; Fri, 10 Nov 2023 11:33:35 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 10 Nov 2023 11:33:50 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Gregory Price , Kefeng Wang Subject: [PATCH v2 6/7] mm: task_mmu: use a folio in clear_refs_pte_range() Date: Fri, 10 Nov 2023 11:33:23 +0800 Message-ID: <20231110033324.2455523-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> References: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use a folio to save two compound_head() calls in clear_refs_pte_range(). Signed-off-by: Kefeng Wang --- fs/proc/task_mmu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index fe15f99a4908..740d5c4fa33c 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1161,7 +1161,7 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned = long addr, struct vm_area_struct *vma =3D walk->vma; pte_t *pte, ptent; spinlock_t *ptl; - struct page *page; + struct folio *folio; =20 ptl =3D pmd_trans_huge_lock(pmd, vma); if (ptl) { @@ -1173,12 +1173,12 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigne= d long addr, if (!pmd_present(*pmd)) goto out; =20 - page =3D pmd_page(*pmd); + folio =3D page_folio(pmd_page(*pmd)); =20 /* Clear accessed and referenced bits. */ pmdp_test_and_clear_young(vma, addr, pmd); - test_and_clear_page_young(page); - ClearPageReferenced(page); + folio_test_clear_young(folio); + folio_clear_referenced(folio); out: spin_unlock(ptl); return 0; @@ -1200,14 +1200,14 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigne= d long addr, if (!pte_present(ptent)) continue; =20 - page =3D vm_normal_page(vma, addr, ptent); - if (!page) + folio =3D vm_normal_folio(vma, addr, ptent); + if (!folio) continue; =20 /* Clear accessed and referenced bits. */ ptep_test_and_clear_young(vma, addr, pte); - test_and_clear_page_young(page); - ClearPageReferenced(page); + folio_test_clear_young(folio); + folio_clear_referenced(folio); } pte_unmap_unlock(pte - 1, ptl); cond_resched(); --=20 2.27.0 From nobody Tue Dec 16 16:23:31 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B36DC4167B for ; Fri, 10 Nov 2023 03:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345869AbjKJDeI (ORCPT ); Thu, 9 Nov 2023 22:34:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345813AbjKJDdz (ORCPT ); Thu, 9 Nov 2023 22:33:55 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBB8744BD for ; Thu, 9 Nov 2023 19:33:52 -0800 (PST) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SRPV55pKYzmXKR; Fri, 10 Nov 2023 11:30:37 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 10 Nov 2023 11:33:50 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , Gregory Price , Kefeng Wang Subject: [PATCH v2 7/7] page_idle: kill page idle and young wrapper Date: Fri, 10 Nov 2023 11:33:24 +0800 Message-ID: <20231110033324.2455523-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> References: <20231110033324.2455523-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Since all the calls of page idle and young functions are gone, let's remove all the wrapper. Signed-off-by: Kefeng Wang --- include/linux/page_idle.h | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/include/linux/page_idle.h b/include/linux/page_idle.h index d8f344840643..1168d5f58ff2 100644 --- a/include/linux/page_idle.h +++ b/include/linux/page_idle.h @@ -119,29 +119,4 @@ static inline void folio_clear_idle(struct folio *foli= o) } =20 #endif /* CONFIG_PAGE_IDLE_FLAG */ - -static inline bool page_is_young(struct page *page) -{ - return folio_test_young(page_folio(page)); -} - -static inline void set_page_young(struct page *page) -{ - folio_set_young(page_folio(page)); -} - -static inline bool test_and_clear_page_young(struct page *page) -{ - return folio_test_clear_young(page_folio(page)); -} - -static inline bool page_is_idle(struct page *page) -{ - return folio_test_idle(page_folio(page)); -} - -static inline void set_page_idle(struct page *page) -{ - folio_set_idle(page_folio(page)); -} #endif /* _LINUX_MM_PAGE_IDLE_H */ --=20 2.27.0