Skip to contentSkip to conversation

proc: export page young and skip_kasan_poison flag via kpageflags

PATCH In review Xin Hao 3 participants 7 messages Jun 2, 2022 – Jun 5, 2022

Subsystems (2)
lore
Share & tools
lore

Xin Hao

author
#0 lore raw

PATCH 1/1 proc: export page young and skip_kasan_poison flag via kpageflags

Now the young and skip_kasan_poison flag are supported in show_page_flags(), but we can not get them from /proc/kpageflags, So there add them.

---
 fs/proc/page.c                    | 6 ++++++
 include/linux/kernel-page-flags.h | 2 ++
 tools/vm/page-types.c             | 4 ++++
 3 files changed, 12 insertions(+)
fs/proc/page.c +6 -0
index 9f1077d94cde..fd28e1d92c5c 100644
@@ -220,6 +220,12 @@ u64 stable_page_flags(struct page *page)
 #ifdef CONFIG_64BIT
 	u |= kpf_copy_bit(k, KPF_ARCH_2,	PG_arch_2);
 #endif
+#if defined(CONFIG_PAGE_IDLE_FLAG) && defined(CONFIG_64BIT)
+	u |= kpf_copy_bit(k, KPF_YOUNG, PG_young);
+#endif
+#ifdef CONFIG_KASAN_HW_TAGS
+	u |= kpf_copy_bit(k, KPF_SKIP_KASAN_POSION, PG_skip_kasan_poison);
+#endif
 
 	return u;
 };
include/linux/kernel-page-flags.h +2 -0
index eee1877a354e..30aaa0ee4ca9 100644
@@ -18,5 +18,7 @@
 #define KPF_UNCACHED		39
 #define KPF_SOFTDIRTY		40
 #define KPF_ARCH_2		41
+#define KPF_YOUNG		42
+#define KPF_SKIP_KASAN_POSION	43
 
 #endif /* LINUX_KERNEL_PAGE_FLAGS_H */
tools/vm/page-types.c +4 -0
index b1ed76d9a979..2671b746d11f 100644
@@ -79,6 +79,8 @@
 #define KPF_UNCACHED		39
 #define KPF_SOFTDIRTY		40
 #define KPF_ARCH_2		41
+#define KPF_YOUNG		42
+#define KPF_SKIP_KASAN_POSION	43
 
 /* [48-] take some arbitrary free slots for expanding overloaded flags
  * not part of kernel API
@@ -137,6 +139,8 @@ static const char * const page_flag_names[] = {
 	[KPF_UNCACHED]		= "c:uncached",
 	[KPF_SOFTDIRTY]		= "f:softdirty",
 	[KPF_ARCH_2]		= "H:arch_2",
+	[KPF_YOUNG]		= "y:young",
+	[KPF_SKIP_KASAN_POSION]	= "K:skip_kasan_posion",
 
 	[KPF_READAHEAD]		= "I:readahead",
 	[KPF_SLOB_FREE]		= "P:slob_free",
Signature · 1 line
2.31.0
#1 lore raw
Quoted 3 lines · On Thu, 2 Jun 2022 23:43:02 +0800 Xin Hao <[email protected]> wrote:

Now the young and skip_kasan_poison flag are supported in show_page_flags(), but we can not get them from /proc/kpageflags, So there add them.

Can we have a documentation update please?

hp2:/usr/src/25> grep -rl kpageflags Documentation Documentation/admin-guide/mm/idle_page_tracking.rst Documentation/admin-guide/mm/pagemap.rst Documentation/filesystems/proc.rst Documentation/translations/zh_CN/vm/hwpoison.rst Documentation/vm/hwpoison.rst

author
#2 lore raw
Quoted 5 lines · Andrew Morton
Quoted 3 lines · On Thu, 2 Jun 2022 23:43:02 +0800 Xin Hao <[email protected]> wrote:

Now the young and skip_kasan_poison flag are supported in show_page_flags(), but we can not get them from /proc/kpageflags, So there add them.

Quoted 8 lines

Can we have a documentation update please?

hp2:/usr/src/25> grep -rl kpageflags Documentation Documentation/admin-guide/mm/idle_page_tracking.rst Documentation/admin-guide/mm/pagemap.rst Documentation/filesystems/proc.rst Documentation/translations/zh_CN/vm/hwpoison.rst Documentation/vm/hwpoison.rst

OK, will do in the next version, thanks

Signature · 2 lines
Best Regards!
Xin Hao
#3 lore raw
In reply to Xin Hao
Quoted 1 line · Xin Hao

Now the young and skip_kasan_poison flag are supported in

Why do we want userspace to know about whether skip_kasan_poison is set? That seems like a kernel-internal detail to me.

author
#4 lore raw
Quoted 4 lines · Matthew Wilcox
Quoted 1 line · Xin Hao

Now the young and skip_kasan_poison flag are supported in

Why do we want userspace to know about whether skip_kasan_poison is set? That seems like a kernel-internal detail to me.

the  skip_kasan_poison also a page flags, we use page_types tool to display them not only include user-internal,

but also  kernel-internal, add them, the page-types tool can more detail display the kernel-internal page flags,

just in case we don't miss some page flags when check the whole memory.

-
Best Regards!
Xin Hao

#5 lore raw
Quoted 7 lines · Xin Hao
Quoted 4 lines · Matthew Wilcox
Quoted 1 line · Xin Hao

Now the young and skip_kasan_poison flag are supported in

Why do we want userspace to know about whether skip_kasan_poison is set? That seems like a kernel-internal detail to me.

Quoted 7 lines

the  skip_kasan_poison also a page flags, we use page_types tool to display them not only include user-internal,

but also  kernel-internal, add them, the page-types tool can more detail display the kernel-internal page flags,

just in case we don't miss some page flags when check the whole memory.

So you're just being completist? You don't have a reason to expose this information?

author
#6 lore raw

Hi, Matthew:

Quoted 9 lines · Matthew Wilcox
Quoted 8 lines · Xin Hao
Quoted 4 lines · Matthew Wilcox
Quoted 1 line · Xin Hao

Now the young and skip_kasan_poison flag are supported in

Why do we want userspace to know about whether skip_kasan_poison is set? That seems like a kernel-internal detail to me.

the  skip_kasan_poison also a page flags, we use page_types tool to display them not only include user-internal,

Quoted 6 lines
Quoted 4 lines

but also  kernel-internal, add them, the page-types tool can more detail display the kernel-internal page flags,

just in case we don't miss some page flags when check the whole memory.

So you're just being completist? You don't have a reason to expose this information?

Yes, about the skip_kasan_poison, i just want the kpageflags to support it,  i think it should be included,

the mainly  region is i want get the page node info from the kpageflags in my next patch,  when i check these

codes,  i see there lost some info about the skip_kasan_poison and young flags,  the page_types tool also check

the kasan pages, so i think it should be included.

Thanks.

Signature · 2 lines
Best Regards!
Xin Hao