From nobody Fri Jan 2 15:11:31 2026 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 6FCBFCD8C90 for ; Tue, 10 Oct 2023 14:29:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233188AbjJJO3O (ORCPT ); Tue, 10 Oct 2023 10:29:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233348AbjJJO2x (ORCPT ); Tue, 10 Oct 2023 10:28:53 -0400 Received: from out-200.mta0.migadu.com (out-200.mta0.migadu.com [IPv6:2001:41d0:1004:224b::c8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AD56103 for ; Tue, 10 Oct 2023 07:28:51 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1696948127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lBUz50yRXYSwkMpVqbF4xKRgGKpQYvwhtcgTljx7wmY=; b=YUXjCIGKTxNpExiRwy5wj5HYemZEfcJ9ufogB+8cHg/UjkS0SCbQYARvOV3YrvQJ8h+xbz Th5rey7xD3OZISdwToRtGiUKbk9WRMhfP9YBFG3zk/ZKVyPJvSt0FCzAdLhCmhLVFpVm/Q O+0tz8vCi9Sa5w73oy9N7qPq9/zVhQ8= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , "Kirill A. Shutemov" , Mike Kravetz , Miaohe Lin , Vlastimil Babka , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 1/5] include/uapi/linux/kernel-page-flags.h: define KPF_FOLIO Date: Tue, 10 Oct 2023 23:27:57 +0900 Message-Id: <20231010142801.3780917-2-naoya.horiguchi@linux.dev> In-Reply-To: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> References: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Naoya Horiguchi Define a new KPF flag to represent folio in /proc/kpageflags and in-kernel user page-types.c. Note that in page-types.c I chose 'f' for the character representing folio, which conflicts with KPF_SOFTDIRTY, but we have no other choice because all reasonable choices ('f', 'F', 'o', 'O', 'l', 'L', 'i', and 'I') are already used. You need to pay attention to long flag names or the position of 'f' in short form. Signed-off-by: Naoya Horiguchi --- include/uapi/linux/kernel-page-flags.h | 1 + tools/mm/page-types.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/uapi/linux/kernel-page-flags.h b/include/uapi/linux/ke= rnel-page-flags.h index 6f2f2720f3ac..9b43dadb7f49 100644 --- a/include/uapi/linux/kernel-page-flags.h +++ b/include/uapi/linux/kernel-page-flags.h @@ -36,5 +36,6 @@ #define KPF_ZERO_PAGE 24 #define KPF_IDLE 25 #define KPF_PGTABLE 26 +#define KPF_FOLIO 27 =20 #endif /* _UAPILINUX_KERNEL_PAGE_FLAGS_H */ diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c index 8d5595b6c59f..b78448d19e88 100644 --- a/tools/mm/page-types.c +++ b/tools/mm/page-types.c @@ -126,6 +126,7 @@ static const char * const page_flag_names[] =3D { [KPF_PGTABLE] =3D "g:pgtable", [KPF_ZERO_PAGE] =3D "z:zero_page", [KPF_IDLE] =3D "i:idle_page", + [KPF_FOLIO] =3D "f:folio", =20 [KPF_RESERVED] =3D "r:reserved", [KPF_MLOCKED] =3D "m:mlocked", --=20 2.25.1 From nobody Fri Jan 2 15:11:31 2026 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 103AECD8C8E for ; Tue, 10 Oct 2023 14:29:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232288AbjJJO3W (ORCPT ); Tue, 10 Oct 2023 10:29:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233386AbjJJO2y (ORCPT ); Tue, 10 Oct 2023 10:28:54 -0400 Received: from out-193.mta0.migadu.com (out-193.mta0.migadu.com [IPv6:2001:41d0:1004:224b::c1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC34B91 for ; Tue, 10 Oct 2023 07:28:52 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1696948131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ct5h8XiEF6Z6bh0u0KQdOShLvibauoLK/pnF+aCIbHs=; b=bpjtc/LFwjIYuknqBdChdrg6pH5LhH0gERemOAwGNiqO/B0yhaIPcKkXhCyk1Y+6QiAB6D pdmVPLFHqF8iWcxI7QpWy2AkvCdR7eOxKKaViIq1Qya/PPl2bRQHZMcyklBZ8+34tDxuvO QoG/rGqvVIFHC+5eFcdEu8fJDv1/1Hs= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , "Kirill A. Shutemov" , Mike Kravetz , Miaohe Lin , Vlastimil Babka , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 2/5] mm: kpageflags: distinguish thp and folio Date: Tue, 10 Oct 2023 23:27:58 +0900 Message-Id: <20231010142801.3780917-3-naoya.horiguchi@linux.dev> In-Reply-To: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> References: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Naoya Horiguchi Currently a large folio is considered as thp in the output of /proc/kpageflags because stable_page_flags() does not have resolution to distinguish thp and large folio. This is confusing and the readers of /proc/kpageflags need additional checks in userspace, which is inefficient. Check page order in stable_page_flags() to distinguish thp and large folio. Although thp (or other types of compound page) is a special form of folio, but the KPF_FOLIO means "folio" in narrower meaning (representing folios in page cache), so KPF_FOLIO is not set on thp or hugetlb pages. This is because thp and hugetlb (and other compound pages) have their own KPF_* flags, so those are already identifiable. Thp and folio use some struct page's field of the first tail pages for internal use. There's no point to parse and show flag info based on tail pages, so return immediately when finding thp/folio tail pages. The output below shows how this patch changes the output of page-types. Before patch: // anonymous thp voffset offset len flags ... 700000000 156c00 1 ___U_l_____Ma_bH______t_____________f_d__= ___1 700000001 156c01 1 L__U_______Ma___T_____t_____________f____= ___1 700000002 156c02 1fe ___________Ma___T_____t_____________f____= ___1 ^ this 't' means thp // file thp 700000000 15d600 1 __RUDl_____M__bH______t_____________f__I_= ___1 700000001 15d601 1 L__U_______M____T_____t_____________f____= ___1 700000002 15d602 1fe ___________M____T_____t_____________f____= ___1 // large folio 700000000 154f84 1 __RU_l_____M___H______t________P____f____= _F_1 700000001 154f85 1 ________W__M____T_____t_____________f____= _F_1 700000002 154f86 2 ___________M____T_____t_____________f____= _F_1 After patch: // anonymous thp 700000000 117000 1 ___U_l_____Ma_bH______t_____________f_d__= ___1 700000001 117001 1ff ________________T_____t_____________f____= ___1 // file thp 700000000 118400 1 __RUDl_____M__bH______t_____________f__I_= ___1 700000001 118401 1ff ________________T_____t_____________f____= ___1 // large folio 700000000 148da4 1 __RU_l_____M___H___________f___P____f____= _F_1 700000001 148da5 3 ________________T__________f________f____= _F_1 ^ this 'f' means folio Signed-off-by: Naoya Horiguchi --- fs/proc/page.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 195b077c0fac..78f675f791c1 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -154,11 +154,24 @@ u64 stable_page_flags(struct page *page) else if (PageTransCompound(page)) { struct page *head =3D compound_head(page); =20 - if (PageLRU(head) || PageAnon(head)) - u |=3D 1 << KPF_THP; - else if (is_huge_zero_page(head)) { + /* + * We need to check PageLRU/PageAnon to make sure a given page + * is a thp, not a huge zero page or a generic compound page + * (allocated by drivers with __GFP_COMP). + */ + if (PageLRU(head) || PageAnon(head)) { + if (compound_order(head) =3D=3D HPAGE_PMD_ORDER) + u |=3D 1 << KPF_THP; + else + u |=3D 1 << KPF_FOLIO; + } else if (is_huge_zero_page(head)) u |=3D 1 << KPF_ZERO_PAGE; - u |=3D 1 << KPF_THP; + + if (PageHead(page)) + u |=3D 1 << KPF_COMPOUND_HEAD; + if (PageTail(page)) { + u |=3D 1 << KPF_COMPOUND_TAIL; + return u; } } else if (is_zero_pfn(page_to_pfn(page))) u |=3D 1 << KPF_ZERO_PAGE; --=20 2.25.1 From nobody Fri Jan 2 15:11:31 2026 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 0BD55CD8C8F for ; Tue, 10 Oct 2023 14:29:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233212AbjJJO3U (ORCPT ); Tue, 10 Oct 2023 10:29:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233493AbjJJO27 (ORCPT ); Tue, 10 Oct 2023 10:28:59 -0400 Received: from out-193.mta0.migadu.com (out-193.mta0.migadu.com [IPv6:2001:41d0:1004:224b::c1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A212FAF for ; Tue, 10 Oct 2023 07:28:56 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1696948135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/jN8h55KNP3RtmvUZhOGO1MAcrm7V1DX54vKKCbAGW4=; b=FLuxcLJc7MCThBfukRGPV/s0DkOpYhPtv8G1oc+pjfFNMFlePzS1gd3bcdx3OjEWEtwW79 Y93/hs4sGbhOPLdoBK9ceAD39O+cKFKsl5IBEFQ7Vu0D4I1DeN5FK3Bj6lQjjmpW2x8c+Z HfvyEq0sy9NhAJKbfwL6i2M897zQLx4= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , "Kirill A. Shutemov" , Mike Kravetz , Miaohe Lin , Vlastimil Babka , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 3/5] mm, kpageflags: separate code path for hugetlb pages Date: Tue, 10 Oct 2023 23:27:59 +0900 Message-Id: <20231010142801.3780917-4-naoya.horiguchi@linux.dev> In-Reply-To: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> References: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Naoya Horiguchi Hugetlb pages use some struct page's field of the first few tail pages for internal use. There's no point to parse and show the kpageflags info based on tail pages, so return immediately when finding hugetlb tail pages. Signed-off-by: Naoya Horiguchi --- fs/proc/page.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 78f675f791c1..9b6ded8a2c90 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -135,23 +135,20 @@ u64 stable_page_flags(struct page *page) if (PageKsm(page)) u |=3D 1 << KPF_KSM; =20 - /* - * compound pages: export both head/tail info - * they together define a compound page's start/end pos and order - */ - if (PageHead(page)) - u |=3D 1 << KPF_COMPOUND_HEAD; - if (PageTail(page)) - u |=3D 1 << KPF_COMPOUND_TAIL; - if (PageHuge(page)) + if (PageHuge(page)) { u |=3D 1 << KPF_HUGE; + if (PageHead(page)) + u |=3D 1 << KPF_COMPOUND_HEAD; + if (PageTail(page)) { + u |=3D 1 << KPF_COMPOUND_TAIL; + return u; + } /* - * PageTransCompound can be true for non-huge compound pages (slab - * pages or pages allocated by drivers with __GFP_COMP) because it - * just checks PG_head/PG_tail, so we need to check PageLRU/PageAnon - * to make sure a given page is a thp, not a non-huge compound page. + * PageTransCompound can be true for any types of compound pages, + * because it just checks PG_head and PageTail, but at this point + * PageSlab and PageHuge are already checked to be false. */ - else if (PageTransCompound(page)) { + } else if (PageTransCompound(page)) { struct page *head =3D compound_head(page); =20 /* --=20 2.25.1 From nobody Fri Jan 2 15:11:31 2026 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 33E27CD8C8B for ; Tue, 10 Oct 2023 14:29:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233084AbjJJO3R (ORCPT ); Tue, 10 Oct 2023 10:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233641AbjJJO3G (ORCPT ); Tue, 10 Oct 2023 10:29:06 -0400 Received: from out-197.mta0.migadu.com (out-197.mta0.migadu.com [IPv6:2001:41d0:1004:224b::c5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33307B9 for ; Tue, 10 Oct 2023 07:29:03 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1696948139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8iM6qPUOV4SzLi4G7vOLG6YfwWxmIMlrGIRntMRiEaw=; b=LGQ17jWAmO3AzMTEsiisqBbOeFYutV+KmHjON926qys/pAgpt4siIMYDJofdhHOETudxF3 D4Y7Fa+Xzgy6CTNCoSSFTQWg1Owoi4swnyZrRm/n404f16vqJBzEonrBhPIQKvt0miTdvg JaSCNdpTWTvdYNouWp5c6jdVh0y3xac= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , "Kirill A. Shutemov" , Mike Kravetz , Miaohe Lin , Vlastimil Babka , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 4/5] mm, kpageflags: fix invalid output for PageSlab Date: Tue, 10 Oct 2023 23:28:00 +0900 Message-Id: <20231010142801.3780917-5-naoya.horiguchi@linux.dev> In-Reply-To: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> References: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Naoya Horiguchi The flag field of slab tail pages is used for internal purpose and there's no point in exposing such info to userspace. Here's the output of `page-types -r -b slab` command now: flags page-count MB symbolic-flags = long-symbolic-flags 0x0000000000000080 5304 20 _______S____________________= _________________ slab 0x0000000000008080 1488 5 _______S_______H____________= _________________ slab,compound_head 0x0000000000010081 365 1 L______S________T___________= _________________ locked,slab,compound_tail 0x0000000000010080 4142 16 _______S________T___________= _________________ slab,compound_tail 0x0000000000010180 649 2 _______SW_______T___________= _________________ slab,writeback,compound_tail 0x0000000000010181 474 1 L______SW_______T___________= _________________ locked,slab,writeback,compound_tail 0x0000000000201080 192 0 _______S____a________x______= _________________ slab,anonymous,ksm 0x0000000000001080 427 1 _______S____a_______________= _________________ slab,anonymous 0x0000000000409080 237 0 _______S____a__H______t_____= _________________ slab,anonymous,compound_head,thp 0x0000000000411081 78 0 L______S____a___T_____t_____= _________________ locked,slab,anonymous,compound_tail,thp 0x0000000000609080 77 0 _______S____a__H_____xt_____= _________________ slab,anonymous,compound_head,ksm,thp 0x0000000000611081 32 0 L______S____a___T____xt_____= _________________ locked,slab,anonymous,compound_tail,ksm,thp 0x0000000000411080 698 2 _______S____a___T_____t_____= _________________ slab,anonymous,compound_tail,thp 0x0000000000611080 142 0 _______S____a___T____xt_____= _________________ slab,anonymous,compound_tail,ksm,thp 0x0000000000611180 32 0 _______SW___a___T____xt_____= _________________ slab,writeback,anonymous,compound_tail,ksm,thp 0x0000000000411181 95 0 L______SW___a___T_____t_____= _________________ locked,slab,writeback,anonymous,compound_tail,thp 0x0000000000411180 64 0 _______SW___a___T_____t_____= _________________ slab,writeback,anonymous,compound_tail,thp 0x0000000000611181 13 0 L______SW___a___T____xt_____= _________________ locked,slab,writeback,anonymous,compound_tail,ksm,thp In this output, "locked" and "writeback" flags are completely pointless because these are encoded in folio->_flags_1 via folio_set_order() and those pages are actually not locked nor written back. As for "anonymous" and "ksm" flags, these are encoded in folio->mapping and the actual value is like 0xdead000000000003. I'm not sure how this value is set, but according to the comment in include/linux/page-flags.h: > * For slab pages, since slab reuses the bits in struct page to store its > * internal states, the page->mapping does not exist as such, nor do the= se > * flags below. So in order to avoid testing non-existent bits, please > * make sure that PageSlab(page) actually evaluates to false before call= ing > * the following functions (e.g., PageAnon). See mm/slab.h. , so we don't have to check PageAnon and PageKsm for slab pages. So return immediately when finding slab tail pages. Note that KPF_HWPOISON is special and it can be helpful to make it visible in /prock/kpageflag even on compound tail pages. After this patch, `page-types -r -b slab` command shows the following simpl= er output (without any invalid flags). 0x0000000000000080 5659 22 _______S____________________= _________________ slab 0x0000000000008080 1644 6 _______S_______H____________= _________________ slab,compound_head 0x0000000000010080 6196 24 _______S________T___________= _________________ slab,compound_tail Signed-off-by: Naoya Horiguchi --- fs/proc/page.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 9b6ded8a2c90..899b96a26fbd 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -122,18 +122,18 @@ u64 stable_page_flags(struct page *page) k =3D page->flags; u =3D 0; =20 - /* - * pseudo flags for the well known (anonymous) memory mapped pages - * - * Note that page->_mapcount is overloaded in SLAB, so the - * simple test in page_mapped() is not enough. - */ - if (!PageSlab(page) && page_mapped(page)) - u |=3D 1 << KPF_MMAP; - if (PageAnon(page)) - u |=3D 1 << KPF_ANON; - if (PageKsm(page)) - u |=3D 1 << KPF_KSM; +#ifdef CONFIG_MEMORY_FAILURE + u |=3D kpf_copy_bit(k, KPF_HWPOISON, PG_hwpoison); +#endif + + if (PageSlab(page)) { + u |=3D 1 << KPF_SLAB; + if (PageHead(page)) + u |=3D 1 << KPF_COMPOUND_HEAD; + if (PageTail(page)) + u |=3D 1 << KPF_COMPOUND_TAIL; + return u; + } =20 if (PageHuge(page)) { u |=3D 1 << KPF_HUGE; @@ -173,9 +173,18 @@ u64 stable_page_flags(struct page *page) } else if (is_zero_pfn(page_to_pfn(page))) u |=3D 1 << KPF_ZERO_PAGE; =20 + /* + * pseudo flags for the well known (anonymous) memory mapped pages + */ + if (page_mapped(page)) + u |=3D 1 << KPF_MMAP; + if (PageAnon(page)) + u |=3D 1 << KPF_ANON; + if (PageKsm(page)) + u |=3D 1 << KPF_KSM; =20 /* - * Caveats on high order pages: PG_buddy and PG_slab will only be set + * Caveats on high order pages: PG_buddy will only be set * on the head page. */ if (PageBuddy(page)) @@ -192,11 +201,6 @@ u64 stable_page_flags(struct page *page) u |=3D 1 << KPF_IDLE; =20 u |=3D kpf_copy_bit(k, KPF_LOCKED, PG_locked); - - 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); @@ -214,10 +218,6 @@ u64 stable_page_flags(struct page *page) u |=3D kpf_copy_bit(k, KPF_UNEVICTABLE, PG_unevictable); 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); -#endif - #ifdef CONFIG_ARCH_USES_PG_UNCACHED u |=3D kpf_copy_bit(k, KPF_UNCACHED, PG_uncached); #endif --=20 2.25.1 From nobody Fri Jan 2 15:11:31 2026 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 8C74DCD8C8F for ; Tue, 10 Oct 2023 14:29:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232828AbjJJO3M (ORCPT ); Tue, 10 Oct 2023 10:29:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233684AbjJJO3I (ORCPT ); Tue, 10 Oct 2023 10:29:08 -0400 Received: from out-195.mta0.migadu.com (out-195.mta0.migadu.com [IPv6:2001:41d0:1004:224b::c3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70888A9 for ; Tue, 10 Oct 2023 07:29:06 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1696948144; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R/QG0Z2F3QpUoVuiwm1cdKUqeM2tUh0VmscjJ0F6F+U=; b=MWezG50+O7UF+lm6gT/NNY5RH7a9ZopHj6n/EIkn62Z4LPC8w5SNIXi0a8Rgj52GVjSvYo 3EvJzzjr7YfdBb0crTZGG+Hndwx69pJFC8xJobtbDgC16FB0JY6EgocjAcpWMzR122rcVV 9pbMUMojnK8Du56fogifM1zDVCrzEt8= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Matthew Wilcox , David Hildenbrand , "Kirill A. Shutemov" , Mike Kravetz , Miaohe Lin , Vlastimil Babka , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 5/5] tools/mm/page-types.c: hide compound pages in non-raw mode Date: Tue, 10 Oct 2023 23:28:01 +0900 Message-Id: <20231010142801.3780917-6-naoya.horiguchi@linux.dev> In-Reply-To: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> References: <20231010142801.3780917-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Naoya Horiguchi In non-raw mode (i.e. calling page-types without -r flag), any flags for compound pages except for hugetlb are supposed to be hidden. But currently KPF_THP is shown and the newly added flag KPF_FOLIO is also shown, which is unexpected. So hide them. Signed-off-by: Naoya Horiguchi --- tools/mm/page-types.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c index b78448d19e88..c37e1e79bc61 100644 --- a/tools/mm/page-types.c +++ b/tools/mm/page-types.c @@ -508,7 +508,7 @@ static uint64_t well_known_flags(uint64_t flags) =20 /* hide non-hugeTLB compound pages */ if ((flags & BITS_COMPOUND) && !(flags & BIT(HUGE))) - flags &=3D ~BITS_COMPOUND; + flags &=3D ~(BITS_COMPOUND|BIT(THP)|BIT(FOLIO)); =20 return flags; } --=20 2.25.1