include/linux/mm.h | 142 ++++++++++++++++++++++---------- rust/bindings/bindings_helper.h | 1 - 2 files changed, 98 insertions(+), 45 deletions(-)
redefine VM_* flag constants with BIT()
Make VM_* flag constant definitions consistent - unify all to use BIT()
macro and define them within an enum.
The bindgen tool is better able to handle BIT(_) declarations when used
in an enum.
Also add enum definitions for tracepoints.
We have previously changed VM_MERGEABLE in a separate bugfix. This is a
follow-up to make all the VM_* flag constant definitions consistent, as
suggested by David in [1].
[1]: https://lore.kernel.org/all/85f852f9-8577-4230-adc7-c52e7f479454@redhat.com/
Signed-off-by: Jakub Acs <acsjakub@amazon.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Xu Xin <xu.xin16@zte.com.cn>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Peter Xu <peterx@redhat.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
---
Hi Alice,
thanks for the patch, I squashed it in (should I add your signed-off-by
too?) and added the TRACE_DEFINE_ENUM calls pointed out by Derrick.
I have the following points to still address, though:
- can the fact that we're not controlling the type of the values if
using enum be a problem? (likely the indirect control we have through
the highest value is good enough, but I'm not sure)
- where do TRACE_DEFINE_ENUM calls belong?
I see them placed e.g. in include/trace/misc/nfs.h for nfs or
arch/x86/kvm/mmu/mmutrace.h, but I don't see a corresponding file for
mm.h - does this warrant creating a separate file for these
definitions?
- with the need for TRACE_DEFINE_ENUM calls, do we still deem this
to be a good trade-off? - isn't fixing all of these in
rust/bindings/bindings_helper.h better?
@Derrick, can you point me to how to test for the issue you pointed out?
Thanks,
Jakub
include/linux/mm.h | 142 ++++++++++++++++++++++----------
rust/bindings/bindings_helper.h | 1 -
2 files changed, 98 insertions(+), 45 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 70a2a76007d4..8b9e7a9e7042 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -36,6 +36,7 @@
#include <linux/rcuwait.h>
#include <linux/bitmap.h>
#include <linux/bitops.h>
+#include <linux/tracepoint.h>
struct mempolicy;
struct anon_vma;
@@ -273,57 +274,58 @@ extern unsigned int kobjsize(const void *objp);
* vm_flags in vm_area_struct, see mm_types.h.
* When changing, update also include/trace/events/mmflags.h
*/
-#define VM_NONE 0x00000000
+enum {
+ VM_NONE = 0,
-#define VM_READ 0x00000001 /* currently active flags */
-#define VM_WRITE 0x00000002
-#define VM_EXEC 0x00000004
-#define VM_SHARED 0x00000008
+ VM_READ = BIT(0), /* currently active flags */
+ VM_WRITE = BIT(1),
+ VM_EXEC = BIT(2),
+ VM_SHARED = BIT(3),
/* mprotect() hardcodes VM_MAYREAD >> 4 == VM_READ, and so for r/w/x bits. */
-#define VM_MAYREAD 0x00000010 /* limits for mprotect() etc */
-#define VM_MAYWRITE 0x00000020
-#define VM_MAYEXEC 0x00000040
-#define VM_MAYSHARE 0x00000080
+ VM_MAYREAD = BIT(4), /* limits for mprotect() etc */
+ VM_MAYWRITE = BIT(5),
+ VM_MAYEXEC = BIT(6),
+ VM_MAYSHARE = BIT(7),
-#define VM_GROWSDOWN 0x00000100 /* general info on the segment */
+ VM_GROWSDOWN = BIT(8), /* general info on the segment */
#ifdef CONFIG_MMU
-#define VM_UFFD_MISSING 0x00000200 /* missing pages tracking */
+ VM_UFFD_MISSING = BIT(9), /* missing pages tracking */
#else /* CONFIG_MMU */
-#define VM_MAYOVERLAY 0x00000200 /* nommu: R/O MAP_PRIVATE mapping that might overlay a file mapping */
+ VM_MAYOVERLAY = BIT(9), /* nommu: R/O MAP_PRIVATE mapping that might overlay a file mapping */
#define VM_UFFD_MISSING 0
#endif /* CONFIG_MMU */
-#define VM_PFNMAP 0x00000400 /* Page-ranges managed without "struct page", just pure PFN */
-#define VM_UFFD_WP 0x00001000 /* wrprotect pages tracking */
-
-#define VM_LOCKED 0x00002000
-#define VM_IO 0x00004000 /* Memory mapped I/O or similar */
-
- /* Used by sys_madvise() */
-#define VM_SEQ_READ 0x00008000 /* App will access data sequentially */
-#define VM_RAND_READ 0x00010000 /* App will not benefit from clustered reads */
-
-#define VM_DONTCOPY 0x00020000 /* Do not copy this vma on fork */
-#define VM_DONTEXPAND 0x00040000 /* Cannot expand with mremap() */
-#define VM_LOCKONFAULT 0x00080000 /* Lock the pages covered when they are faulted in */
-#define VM_ACCOUNT 0x00100000 /* Is a VM accounted object */
-#define VM_NORESERVE 0x00200000 /* should the VM suppress accounting */
-#define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
-#define VM_SYNC 0x00800000 /* Synchronous page faults */
-#define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
-#define VM_WIPEONFORK 0x02000000 /* Wipe VMA contents in child. */
-#define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
+ VM_PFNMAP = BIT(10), /* Page-ranges managed without "struct page", just pure PFN */
+ VM_UFFD_WP = BIT(12), /* wrprotect pages tracking */
+
+ VM_LOCKED = BIT(13),
+ VM_IO = BIT(14), /* Memory mapped I/O or similar */
+
+ /* Used by sys_madvise() */
+ VM_SEQ_READ = BIT(15), /* App will access data sequentially */
+ VM_RAND_READ = BIT(16), /* App will not benefit from clustered reads */
+
+ VM_DONTCOPY = BIT(17), /* Do not copy this vma on fork */
+ VM_DONTEXPAND = BIT(18), /* Cannot expand with mremap() */
+ VM_LOCKONFAULT = BIT(19), /* Lock the pages covered when they are faulted in */
+ VM_ACCOUNT = BIT(20), /* Is a VM accounted object */
+ VM_NORESERVE = BIT(21), /* should the VM suppress accounting */
+ VM_HUGETLB = BIT(22), /* Huge TLB Page VM */
+ VM_SYNC = BIT(23), /* Synchronous page faults */
+ VM_ARCH_1 = BIT(24), /* Architecture-specific flag */
+ VM_WIPEONFORK = BIT(25), /* Wipe VMA contents in child. */
+ VM_DONTDUMP = BIT(26), /* Do not include in the core dump */
#ifdef CONFIG_MEM_SOFT_DIRTY
-# define VM_SOFTDIRTY 0x08000000 /* Not soft dirty clean area */
+ VM_SOFTDIRTY = BIT(27), /* Not soft dirty clean area */
#else
# define VM_SOFTDIRTY 0
#endif
-#define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
-#define VM_HUGEPAGE 0x20000000 /* MADV_HUGEPAGE marked this vma */
-#define VM_NOHUGEPAGE 0x40000000 /* MADV_NOHUGEPAGE marked this vma */
-#define VM_MERGEABLE BIT(31) /* KSM may merge identical pages */
+ VM_MIXEDMAP = BIT(28), /* Can contain "struct page" and pure PFN pages */
+ VM_HUGEPAGE = BIT(29), /* MADV_HUGEPAGE marked this vma */
+ VM_NOHUGEPAGE = BIT(30), /* MADV_NOHUGEPAGE marked this vma */
+ VM_MERGEABLE = BIT(31), /* KSM may merge identical pages */
#ifdef CONFIG_ARCH_USES_HIGH_VMA_FLAGS
#define VM_HIGH_ARCH_BIT_0 32 /* bit only usable on 64-bit architectures */
@@ -333,14 +335,66 @@ extern unsigned int kobjsize(const void *objp);
#define VM_HIGH_ARCH_BIT_4 36 /* bit only usable on 64-bit architectures */
#define VM_HIGH_ARCH_BIT_5 37 /* bit only usable on 64-bit architectures */
#define VM_HIGH_ARCH_BIT_6 38 /* bit only usable on 64-bit architectures */
-#define VM_HIGH_ARCH_0 BIT(VM_HIGH_ARCH_BIT_0)
-#define VM_HIGH_ARCH_1 BIT(VM_HIGH_ARCH_BIT_1)
-#define VM_HIGH_ARCH_2 BIT(VM_HIGH_ARCH_BIT_2)
-#define VM_HIGH_ARCH_3 BIT(VM_HIGH_ARCH_BIT_3)
-#define VM_HIGH_ARCH_4 BIT(VM_HIGH_ARCH_BIT_4)
-#define VM_HIGH_ARCH_5 BIT(VM_HIGH_ARCH_BIT_5)
-#define VM_HIGH_ARCH_6 BIT(VM_HIGH_ARCH_BIT_6)
+ VM_HIGH_ARCH_0 = BIT(VM_HIGH_ARCH_BIT_0),
+ VM_HIGH_ARCH_1 = BIT(VM_HIGH_ARCH_BIT_1),
+ VM_HIGH_ARCH_2 = BIT(VM_HIGH_ARCH_BIT_2),
+ VM_HIGH_ARCH_3 = BIT(VM_HIGH_ARCH_BIT_3),
+ VM_HIGH_ARCH_4 = BIT(VM_HIGH_ARCH_BIT_4),
+ VM_HIGH_ARCH_5 = BIT(VM_HIGH_ARCH_BIT_5),
+ VM_HIGH_ARCH_6 = BIT(VM_HIGH_ARCH_BIT_6),
#endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */
+};
+
+TRACE_DEFINE_ENUM(VM_NONE);
+TRACE_DEFINE_ENUM(VM_READ);
+TRACE_DEFINE_ENUM(VM_WRITE);
+TRACE_DEFINE_ENUM(VM_EXEC);
+TRACE_DEFINE_ENUM(VM_SHARED);
+TRACE_DEFINE_ENUM(VM_MAYREAD);
+TRACE_DEFINE_ENUM(VM_MAYWRITE);
+TRACE_DEFINE_ENUM(VM_MAYEXEC);
+TRACE_DEFINE_ENUM(VM_MAYSHARE);
+TRACE_DEFINE_ENUM(VM_GROWSDOWN);
+TRACE_DEFINE_ENUM(VM_UFFD_MISSING);
+
+#ifndef CONFIG_MMU
+TRACE_DEFINE_ENUM(VM_MAYOVERLAY);
+#endif /* CONFIG_MMU */
+
+TRACE_DEFINE_ENUM(VM_PFNMAP);
+TRACE_DEFINE_ENUM(VM_UFFD_WP);
+TRACE_DEFINE_ENUM(VM_LOCKED);
+TRACE_DEFINE_ENUM(VM_IO);
+TRACE_DEFINE_ENUM(VM_SEQ_READ);
+TRACE_DEFINE_ENUM(VM_RAND_READ);
+TRACE_DEFINE_ENUM(VM_DONTCOPY);
+TRACE_DEFINE_ENUM(VM_DONTEXPAND);
+TRACE_DEFINE_ENUM(VM_LOCKONFAULT);
+TRACE_DEFINE_ENUM(VM_ACCOUNT);
+TRACE_DEFINE_ENUM(VM_NORESERVE);
+TRACE_DEFINE_ENUM(VM_HUGETLB);
+TRACE_DEFINE_ENUM(VM_SYNC);
+TRACE_DEFINE_ENUM(VM_ARCH_1);
+TRACE_DEFINE_ENUM(VM_WIPEONFORK);
+TRACE_DEFINE_ENUM(VM_DONTDUMP);
+
+TRACE_DEFINE_ENUM(VM_SOFTDIRTY);
+
+TRACE_DEFINE_ENUM(VM_MIXEDMAP);
+TRACE_DEFINE_ENUM(VM_HUGEPAGE);
+TRACE_DEFINE_ENUM(VM_NOHUGEPAGE);
+TRACE_DEFINE_ENUM(VM_MERGEABLE);
+
+#ifdef CONFIG_ARCH_USES_HIGH_VMA_FLAGS
+TRACE_DEFINE_ENUM(VM_HIGH_ARCH_0);
+TRACE_DEFINE_ENUM(VM_HIGH_ARCH_1);
+TRACE_DEFINE_ENUM(VM_HIGH_ARCH_2);
+TRACE_DEFINE_ENUM(VM_HIGH_ARCH_3);
+TRACE_DEFINE_ENUM(VM_HIGH_ARCH_4);
+TRACE_DEFINE_ENUM(VM_HIGH_ARCH_5);
+TRACE_DEFINE_ENUM(VM_HIGH_ARCH_6);
+#endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */
+
#ifdef CONFIG_ARCH_HAS_PKEYS
# define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0
diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
index 2e43c66635a2..04b75d4d01c3 100644
--- a/rust/bindings/bindings_helper.h
+++ b/rust/bindings/bindings_helper.h
@@ -108,7 +108,6 @@ const xa_mark_t RUST_CONST_HELPER_XA_PRESENT = XA_PRESENT;
const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC = XA_FLAGS_ALLOC;
const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC1 = XA_FLAGS_ALLOC1;
-const vm_flags_t RUST_CONST_HELPER_VM_MERGEABLE = VM_MERGEABLE;
#if IS_ENABLED(CONFIG_ANDROID_BINDER_IPC_RUST)
#include "../../drivers/android/binder/rust_binder.h"
--
2.47.3
Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christian Schlaeger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
Hi Jakub,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-everything]
url: https://github.com/intel-lab-lkp/linux/commits/Jakub-Acs/mm-use-enum-for-vm_flags/20251010-124738
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20251008125427.68735-1-acsjakub%40amazon.de
patch subject: [PATCH] mm: use enum for vm_flags
config: parisc-randconfig-r072-20251011 (https://download.01.org/0day-ci/archive/20251011/202510110802.EXLvwqhL-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251011/202510110802.EXLvwqhL-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510110802.EXLvwqhL-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/linux/elf.h:6,
from include/linux/module.h:20,
from include/linux/device/driver.h:21,
from include/linux/device.h:32,
from include/linux/node.h:18,
from include/linux/cpu.h:17,
from include/linux/static_call.h:135,
from include/linux/tracepoint.h:22,
from include/linux/mm.h:39,
from include/linux/pid_namespace.h:7,
from include/linux/nsfs.h:9,
from include/linux/proc_ns.h:8,
from init/version.c:18:
>> arch/parisc/include/asm/elf.h:320: warning: "ELF_OSABI" redefined
#define ELF_OSABI ELFOSABI_LINUX
In file included from include/linux/elfnote.h:62,
from include/linux/build-salt.h:4,
from init/version.c:11:
include/uapi/linux/elf.h:386: note: this is the location of the previous definition
#define ELF_OSABI ELFOSABI_NONE
vim +/ELF_OSABI +320 arch/parisc/include/asm/elf.h
^1da177e4c3f41 include/asm-parisc/elf.h Linus Torvalds 2005-04-16 308
^1da177e4c3f41 include/asm-parisc/elf.h Linus Torvalds 2005-04-16 309
71d577db01a517 arch/parisc/include/asm/elf.h Helge Deller 2018-04-11 310 #define elf_check_arch(x) \
71d577db01a517 arch/parisc/include/asm/elf.h Helge Deller 2018-04-11 311 ((x)->e_machine == EM_PARISC && (x)->e_ident[EI_CLASS] == ELF_CLASS)
71d577db01a517 arch/parisc/include/asm/elf.h Helge Deller 2018-04-11 312 #define compat_elf_check_arch(x) \
71d577db01a517 arch/parisc/include/asm/elf.h Helge Deller 2018-04-11 313 ((x)->e_machine == EM_PARISC && (x)->e_ident[EI_CLASS] == ELFCLASS32)
^1da177e4c3f41 include/asm-parisc/elf.h Linus Torvalds 2005-04-16 314
^1da177e4c3f41 include/asm-parisc/elf.h Linus Torvalds 2005-04-16 315 /*
^1da177e4c3f41 include/asm-parisc/elf.h Linus Torvalds 2005-04-16 316 * These are used to set parameters in the core dumps.
^1da177e4c3f41 include/asm-parisc/elf.h Linus Torvalds 2005-04-16 317 */
^1da177e4c3f41 include/asm-parisc/elf.h Linus Torvalds 2005-04-16 318 #define ELF_DATA ELFDATA2MSB
^1da177e4c3f41 include/asm-parisc/elf.h Linus Torvalds 2005-04-16 319 #define ELF_ARCH EM_PARISC
^1da177e4c3f41 include/asm-parisc/elf.h Linus Torvalds 2005-04-16 @320 #define ELF_OSABI ELFOSABI_LINUX
^1da177e4c3f41 include/asm-parisc/elf.h Linus Torvalds 2005-04-16 321
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Jakub,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
url: https://github.com/intel-lab-lkp/linux/commits/Jakub-Acs/mm-use-enum-for-vm_flags/20251010-124738
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20251008125427.68735-1-acsjakub%40amazon.de
patch subject: [PATCH] mm: use enum for vm_flags
config: s390-randconfig-001-20251011 (https://download.01.org/0day-ci/archive/20251011/202510110743.9G4osLTr-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 9.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251011/202510110743.9G4osLTr-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202510110743.9G4osLTr-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
In file included from arch/s390/include/asm/mmu_context.h:11,
from arch/s390/include/asm/elf.h:178,
from include/linux/elf.h:6,
from include/linux/module.h:20,
from include/linux/device/driver.h:21,
from include/linux/device.h:32,
from include/linux/node.h:18,
from include/linux/cpu.h:17,
from include/linux/static_call.h:135,
from include/linux/tracepoint.h:22,
from include/linux/mm.h:39,
from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10,
from arch/s390/include/asm/stacktrace.h:7,
from arch/s390/kernel/asm-offsets.c:15:
arch/s390/include/asm/pgalloc.h: In function 'p4d_alloc_one_noprof':
>> arch/s390/include/asm/pgalloc.h:62:2: error: implicit declaration of function 'pagetable_p4d_ctor' [-Werror=implicit-function-declaration]
62 | pagetable_p4d_ctor(virt_to_ptdesc(table));
| ^~~~~~~~~~~~~~~~~~
>> arch/s390/include/asm/pgalloc.h:62:21: error: implicit declaration of function 'virt_to_ptdesc'; did you mean 'virt_to_kpte'? [-Werror=implicit-function-declaration]
62 | pagetable_p4d_ctor(virt_to_ptdesc(table));
| ^~~~~~~~~~~~~~
| virt_to_kpte
arch/s390/include/asm/pgalloc.h: In function 'p4d_free':
>> arch/s390/include/asm/pgalloc.h:73:2: error: implicit declaration of function 'pagetable_dtor'; did you mean 'page_table_free'? [-Werror=implicit-function-declaration]
73 | pagetable_dtor(virt_to_ptdesc(p4d));
| ^~~~~~~~~~~~~~
| page_table_free
arch/s390/include/asm/pgalloc.h: In function 'pud_alloc_one_noprof':
>> arch/s390/include/asm/pgalloc.h:84:2: error: implicit declaration of function 'pagetable_pud_ctor' [-Werror=implicit-function-declaration]
84 | pagetable_pud_ctor(virt_to_ptdesc(table));
| ^~~~~~~~~~~~~~~~~~
arch/s390/include/asm/pgalloc.h: In function 'pmd_alloc_one_noprof':
>> arch/s390/include/asm/pgalloc.h:106:7: error: implicit declaration of function 'pagetable_pmd_ctor' [-Werror=implicit-function-declaration]
106 | if (!pagetable_pmd_ctor(mm, virt_to_ptdesc(table))) {
| ^~~~~~~~~~~~~~~~~~
arch/s390/include/asm/pgalloc.h: In function 'pgd_alloc_noprof':
>> arch/s390/include/asm/pgalloc.h:143:2: error: implicit declaration of function 'pagetable_pgd_ctor' [-Werror=implicit-function-declaration]
143 | pagetable_pgd_ctor(virt_to_ptdesc(table));
| ^~~~~~~~~~~~~~~~~~
In file included from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10,
from arch/s390/include/asm/stacktrace.h:7,
from arch/s390/kernel/asm-offsets.c:15:
include/linux/mm.h: At top level:
>> include/linux/mm.h:3011:30: error: conflicting types for 'virt_to_ptdesc'
3011 | static inline struct ptdesc *virt_to_ptdesc(const void *x)
| ^~~~~~~~~~~~~~
In file included from arch/s390/include/asm/mmu_context.h:11,
from arch/s390/include/asm/elf.h:178,
from include/linux/elf.h:6,
from include/linux/module.h:20,
from include/linux/device/driver.h:21,
from include/linux/device.h:32,
from include/linux/node.h:18,
from include/linux/cpu.h:17,
from include/linux/static_call.h:135,
from include/linux/tracepoint.h:22,
from include/linux/mm.h:39,
from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10,
from arch/s390/include/asm/stacktrace.h:7,
from arch/s390/kernel/asm-offsets.c:15:
arch/s390/include/asm/pgalloc.h:62:21: note: previous implicit declaration of 'virt_to_ptdesc' was here
62 | pagetable_p4d_ctor(virt_to_ptdesc(table));
| ^~~~~~~~~~~~~~
In file included from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10,
from arch/s390/include/asm/stacktrace.h:7,
from arch/s390/kernel/asm-offsets.c:15:
>> include/linux/mm.h:3152:20: warning: conflicting types for 'pagetable_dtor'
3152 | static inline void pagetable_dtor(struct ptdesc *ptdesc)
| ^~~~~~~~~~~~~~
>> include/linux/mm.h:3152:20: error: static declaration of 'pagetable_dtor' follows non-static declaration
In file included from arch/s390/include/asm/mmu_context.h:11,
from arch/s390/include/asm/elf.h:178,
from include/linux/elf.h:6,
from include/linux/module.h:20,
from include/linux/device/driver.h:21,
from include/linux/device.h:32,
from include/linux/node.h:18,
from include/linux/cpu.h:17,
from include/linux/static_call.h:135,
from include/linux/tracepoint.h:22,
from include/linux/mm.h:39,
from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10,
from arch/s390/include/asm/stacktrace.h:7,
from arch/s390/kernel/asm-offsets.c:15:
arch/s390/include/asm/pgalloc.h:73:2: note: previous implicit declaration of 'pagetable_dtor' was here
73 | pagetable_dtor(virt_to_ptdesc(p4d));
| ^~~~~~~~~~~~~~
In file included from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10,
from arch/s390/include/asm/stacktrace.h:7,
from arch/s390/kernel/asm-offsets.c:15:
>> include/linux/mm.h:3274:20: error: conflicting types for 'pagetable_pmd_ctor'
3274 | static inline bool pagetable_pmd_ctor(struct mm_struct *mm,
| ^~~~~~~~~~~~~~~~~~
In file included from arch/s390/include/asm/mmu_context.h:11,
from arch/s390/include/asm/elf.h:178,
from include/linux/elf.h:6,
from include/linux/module.h:20,
from include/linux/device/driver.h:21,
from include/linux/device.h:32,
from include/linux/node.h:18,
from include/linux/cpu.h:17,
from include/linux/static_call.h:135,
from include/linux/tracepoint.h:22,
from include/linux/mm.h:39,
from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10,
from arch/s390/include/asm/stacktrace.h:7,
from arch/s390/kernel/asm-offsets.c:15:
arch/s390/include/asm/pgalloc.h:106:7: note: previous implicit declaration of 'pagetable_pmd_ctor' was here
106 | if (!pagetable_pmd_ctor(mm, virt_to_ptdesc(table))) {
| ^~~~~~~~~~~~~~~~~~
In file included from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10,
from arch/s390/include/asm/stacktrace.h:7,
from arch/s390/kernel/asm-offsets.c:15:
>> include/linux/mm.h:3303:20: warning: conflicting types for 'pagetable_pud_ctor'
3303 | static inline void pagetable_pud_ctor(struct ptdesc *ptdesc)
| ^~~~~~~~~~~~~~~~~~
>> include/linux/mm.h:3303:20: error: static declaration of 'pagetable_pud_ctor' follows non-static declaration
In file included from arch/s390/include/asm/mmu_context.h:11,
from arch/s390/include/asm/elf.h:178,
from include/linux/elf.h:6,
from include/linux/module.h:20,
from include/linux/device/driver.h:21,
from include/linux/device.h:32,
from include/linux/node.h:18,
from include/linux/cpu.h:17,
from include/linux/static_call.h:135,
from include/linux/tracepoint.h:22,
from include/linux/mm.h:39,
from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10,
from arch/s390/include/asm/stacktrace.h:7,
from arch/s390/kernel/asm-offsets.c:15:
arch/s390/include/asm/pgalloc.h:84:2: note: previous implicit declaration of 'pagetable_pud_ctor' was here
84 | pagetable_pud_ctor(virt_to_ptdesc(table));
| ^~~~~~~~~~~~~~~~~~
In file included from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10,
from arch/s390/include/asm/stacktrace.h:7,
from arch/s390/kernel/asm-offsets.c:15:
>> include/linux/mm.h:3308:20: warning: conflicting types for 'pagetable_p4d_ctor'
3308 | static inline void pagetable_p4d_ctor(struct ptdesc *ptdesc)
| ^~~~~~~~~~~~~~~~~~
>> include/linux/mm.h:3308:20: error: static declaration of 'pagetable_p4d_ctor' follows non-static declaration
In file included from arch/s390/include/asm/mmu_context.h:11,
from arch/s390/include/asm/elf.h:178,
from include/linux/elf.h:6,
from include/linux/module.h:20,
from include/linux/device/driver.h:21,
from include/linux/device.h:32,
from include/linux/node.h:18,
from include/linux/cpu.h:17,
from include/linux/static_call.h:135,
from include/linux/tracepoint.h:22,
from include/linux/mm.h:39,
from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10,
from arch/s390/include/asm/stacktrace.h:7,
from arch/s390/kernel/asm-offsets.c:15:
arch/s390/include/asm/pgalloc.h:62:2: note: previous implicit declaration of 'pagetable_p4d_ctor' was here
62 | pagetable_p4d_ctor(virt_to_ptdesc(table));
| ^~~~~~~~~~~~~~~~~~
In file included from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10,
from arch/s390/include/asm/stacktrace.h:7,
from arch/s390/kernel/asm-offsets.c:15:
>> include/linux/mm.h:3313:20: warning: conflicting types for 'pagetable_pgd_ctor'
3313 | static inline void pagetable_pgd_ctor(struct ptdesc *ptdesc)
| ^~~~~~~~~~~~~~~~~~
>> include/linux/mm.h:3313:20: error: static declaration of 'pagetable_pgd_ctor' follows non-static declaration
In file included from arch/s390/include/asm/mmu_context.h:11,
from arch/s390/include/asm/elf.h:178,
from include/linux/elf.h:6,
from include/linux/module.h:20,
from include/linux/device/driver.h:21,
from include/linux/device.h:32,
from include/linux/node.h:18,
from include/linux/cpu.h:17,
from include/linux/static_call.h:135,
from include/linux/tracepoint.h:22,
from include/linux/mm.h:39,
from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10,
from arch/s390/include/asm/stacktrace.h:7,
from arch/s390/kernel/asm-offsets.c:15:
arch/s390/include/asm/pgalloc.h:143:2: note: previous implicit declaration of 'pagetable_pgd_ctor' was here
143 | pagetable_pgd_ctor(virt_to_ptdesc(table));
| ^~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:182: arch/s390/kernel/asm-offsets.s] Error 1 shuffle=2098624972
make[3]: Target 'prepare' not remade because of errors.
make[2]: *** [Makefile:1280: prepare0] Error 2 shuffle=2098624972
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:248: __sub-make] Error 2 shuffle=2098624972
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:248: __sub-make] Error 2 shuffle=2098624972
make: Target 'prepare' not remade because of errors.
vim +/virt_to_ptdesc +3011 include/linux/mm.h
522abd92279a8e Matthew Wilcox (Oracle 2025-09-08 3010)
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 @3011) static inline struct ptdesc *virt_to_ptdesc(const void *x)
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3012) {
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3013) return page_ptdesc(virt_to_page(x));
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3014) }
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3015)
90ec2df9dd3165 Matthew Wilcox (Oracle 2025-09-08 3016) /**
90ec2df9dd3165 Matthew Wilcox (Oracle 2025-09-08 3017) * ptdesc_address - Virtual address of page table.
90ec2df9dd3165 Matthew Wilcox (Oracle 2025-09-08 3018) * @pt: Page table descriptor.
90ec2df9dd3165 Matthew Wilcox (Oracle 2025-09-08 3019) *
90ec2df9dd3165 Matthew Wilcox (Oracle 2025-09-08 3020) * Return: The first byte of the page table described by @pt.
90ec2df9dd3165 Matthew Wilcox (Oracle 2025-09-08 3021) */
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3022) static inline void *ptdesc_address(const struct ptdesc *pt)
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3023) {
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3024) return folio_address(ptdesc_folio(pt));
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3025) }
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3026)
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3027) static inline bool pagetable_is_reserved(struct ptdesc *pt)
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3028) {
522abd92279a8e Matthew Wilcox (Oracle 2025-09-08 3029) return test_bit(PT_reserved, &pt->pt_flags.f);
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3030) }
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3031)
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3032) /**
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3033) * pagetable_alloc - Allocate pagetables
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3034) * @gfp: GFP flags
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3035) * @order: desired pagetable order
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3036) *
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3037) * pagetable_alloc allocates memory for page tables as well as a page table
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3038) * descriptor to describe that memory.
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3039) *
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3040) * Return: The ptdesc describing the allocated page tables.
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3041) */
2c321f3f70bc28 Suren Baghdasaryan 2024-04-14 3042 static inline struct ptdesc *pagetable_alloc_noprof(gfp_t gfp, unsigned int order)
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3043) {
2c321f3f70bc28 Suren Baghdasaryan 2024-04-14 3044 struct page *page = alloc_pages_noprof(gfp | __GFP_COMP, order);
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3045)
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3046) return page_ptdesc(page);
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3047) }
2c321f3f70bc28 Suren Baghdasaryan 2024-04-14 3048 #define pagetable_alloc(...) alloc_hooks(pagetable_alloc_noprof(__VA_ARGS__))
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3049)
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3050) /**
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3051) * pagetable_free - Free pagetables
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3052) * @pt: The page table descriptor
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3053) *
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3054) * pagetable_free frees the memory of all page tables described by a page
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3055) * table descriptor and the memory for the descriptor itself.
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3056) */
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3057) static inline void pagetable_free(struct ptdesc *pt)
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3058) {
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3059) struct page *page = ptdesc_page(pt);
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3060)
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3061) __free_pages(page, compound_order(page));
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3062) }
bf2d4334f72e4e Vishal Moola (Oracle 2023-08-07 3063)
394290cba9664e David Hildenbrand 2024-07-26 3064 #if defined(CONFIG_SPLIT_PTE_PTLOCKS)
597d795a2a786d Kirill A. Shutemov 2013-12-20 3065 #if ALLOC_SPLIT_PTLOCKS
b35f1819acd924 Kirill A. Shutemov 2014-01-21 3066 void __init ptlock_cache_init(void);
f5ecca06b3a5d0 Vishal Moola (Oracle 2023-08-07 3067) bool ptlock_alloc(struct ptdesc *ptdesc);
6ed1b8a09deb0b Vishal Moola (Oracle 2023-08-07 3068) void ptlock_free(struct ptdesc *ptdesc);
539edb5846c740 Peter Zijlstra 2013-11-14 3069
1865484af6b2ce Vishal Moola (Oracle 2023-08-07 3070) static inline spinlock_t *ptlock_ptr(struct ptdesc *ptdesc)
539edb5846c740 Peter Zijlstra 2013-11-14 3071 {
1865484af6b2ce Vishal Moola (Oracle 2023-08-07 3072) return ptdesc->ptl;
539edb5846c740 Peter Zijlstra 2013-11-14 3073 }
597d795a2a786d Kirill A. Shutemov 2013-12-20 3074 #else /* ALLOC_SPLIT_PTLOCKS */
b35f1819acd924 Kirill A. Shutemov 2014-01-21 3075 static inline void ptlock_cache_init(void)
b35f1819acd924 Kirill A. Shutemov 2014-01-21 3076 {
b35f1819acd924 Kirill A. Shutemov 2014-01-21 3077 }
b35f1819acd924 Kirill A. Shutemov 2014-01-21 3078
f5ecca06b3a5d0 Vishal Moola (Oracle 2023-08-07 3079) static inline bool ptlock_alloc(struct ptdesc *ptdesc)
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3080 {
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3081 return true;
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3082 }
539edb5846c740 Peter Zijlstra 2013-11-14 3083
6ed1b8a09deb0b Vishal Moola (Oracle 2023-08-07 3084) static inline void ptlock_free(struct ptdesc *ptdesc)
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3085 {
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3086 }
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3087
1865484af6b2ce Vishal Moola (Oracle 2023-08-07 3088) static inline spinlock_t *ptlock_ptr(struct ptdesc *ptdesc)
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3089 {
1865484af6b2ce Vishal Moola (Oracle 2023-08-07 3090) return &ptdesc->ptl;
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3091 }
597d795a2a786d Kirill A. Shutemov 2013-12-20 3092 #endif /* ALLOC_SPLIT_PTLOCKS */
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3093
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3094 static inline spinlock_t *pte_lockptr(struct mm_struct *mm, pmd_t *pmd)
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3095 {
1865484af6b2ce Vishal Moola (Oracle 2023-08-07 3096) return ptlock_ptr(page_ptdesc(pmd_page(*pmd)));
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3097 }
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3098
5f75cfbd6bb022 David Hildenbrand 2024-08-01 3099 static inline spinlock_t *ptep_lockptr(struct mm_struct *mm, pte_t *pte)
5f75cfbd6bb022 David Hildenbrand 2024-08-01 3100 {
5f75cfbd6bb022 David Hildenbrand 2024-08-01 3101 BUILD_BUG_ON(IS_ENABLED(CONFIG_HIGHPTE));
5f75cfbd6bb022 David Hildenbrand 2024-08-01 3102 BUILD_BUG_ON(MAX_PTRS_PER_PTE * sizeof(pte_t) > PAGE_SIZE);
5f75cfbd6bb022 David Hildenbrand 2024-08-01 3103 return ptlock_ptr(virt_to_ptdesc(pte));
5f75cfbd6bb022 David Hildenbrand 2024-08-01 3104 }
5f75cfbd6bb022 David Hildenbrand 2024-08-01 3105
75b25d49ca6638 Vishal Moola (Oracle 2023-08-07 3106) static inline bool ptlock_init(struct ptdesc *ptdesc)
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3107 {
4c21e2f2441dc5 Hugh Dickins 2005-10-29 3108 /*
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3109 * prep_new_page() initialize page->private (and therefore page->ptl)
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3110 * with 0. Make sure nobody took it in use in between.
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3111 *
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3112 * It can happen if arch try to use slab for page table allocation:
1d798ca3f16437 Kirill A. Shutemov 2015-11-06 3113 * slab code uses page->slab_cache, which share storage with page->ptl.
4c21e2f2441dc5 Hugh Dickins 2005-10-29 3114 */
75b25d49ca6638 Vishal Moola (Oracle 2023-08-07 3115) VM_BUG_ON_PAGE(*(unsigned long *)&ptdesc->ptl, ptdesc_page(ptdesc));
75b25d49ca6638 Vishal Moola (Oracle 2023-08-07 3116) if (!ptlock_alloc(ptdesc))
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3117 return false;
75b25d49ca6638 Vishal Moola (Oracle 2023-08-07 3118) spin_lock_init(ptlock_ptr(ptdesc));
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3119 return true;
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3120 }
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3121
394290cba9664e David Hildenbrand 2024-07-26 3122 #else /* !defined(CONFIG_SPLIT_PTE_PTLOCKS) */
4c21e2f2441dc5 Hugh Dickins 2005-10-29 3123 /*
4c21e2f2441dc5 Hugh Dickins 2005-10-29 3124 * We use mm->page_table_lock to guard all pagetable pages of the mm.
4c21e2f2441dc5 Hugh Dickins 2005-10-29 3125 */
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3126 static inline spinlock_t *pte_lockptr(struct mm_struct *mm, pmd_t *pmd)
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3127 {
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3128 return &mm->page_table_lock;
49076ec2ccaf68 Kirill A. Shutemov 2013-11-14 3129 }
5f75cfbd6bb022 David Hildenbrand 2024-08-01 3130 static inline spinlock_t *ptep_lockptr(struct mm_struct *mm, pte_t *pte)
5f75cfbd6bb022 David Hildenbrand 2024-08-01 3131 {
5f75cfbd6bb022 David Hildenbrand 2024-08-01 3132 return &mm->page_table_lock;
5f75cfbd6bb022 David Hildenbrand 2024-08-01 3133 }
b35f1819acd924 Kirill A. Shutemov 2014-01-21 3134 static inline void ptlock_cache_init(void) {}
75b25d49ca6638 Vishal Moola (Oracle 2023-08-07 3135) static inline bool ptlock_init(struct ptdesc *ptdesc) { return true; }
6ed1b8a09deb0b Vishal Moola (Oracle 2023-08-07 3136) static inline void ptlock_free(struct ptdesc *ptdesc) {}
394290cba9664e David Hildenbrand 2024-07-26 3137 #endif /* defined(CONFIG_SPLIT_PTE_PTLOCKS) */
4c21e2f2441dc5 Hugh Dickins 2005-10-29 3138
f0c92726e89f5c Matthew Wilcox (Oracle 2025-09-08 3139) static inline unsigned long ptdesc_nr_pages(const struct ptdesc *ptdesc)
f0c92726e89f5c Matthew Wilcox (Oracle 2025-09-08 3140) {
f0c92726e89f5c Matthew Wilcox (Oracle 2025-09-08 3141) return compound_nr(ptdesc_page(ptdesc));
f0c92726e89f5c Matthew Wilcox (Oracle 2025-09-08 3142) }
f0c92726e89f5c Matthew Wilcox (Oracle 2025-09-08 3143)
11e2400b21a3e2 Kevin Brodsky 2025-01-03 3144 static inline void __pagetable_ctor(struct ptdesc *ptdesc)
2f569afd9ced9e Martin Schwidefsky 2008-02-08 3145 {
f0c92726e89f5c Matthew Wilcox (Oracle 2025-09-08 3146) pg_data_t *pgdat = NODE_DATA(memdesc_nid(ptdesc->pt_flags));
7e11dca14b27e1 Vishal Moola (Oracle 2023-08-07 3147)
f0c92726e89f5c Matthew Wilcox (Oracle 2025-09-08 3148) __SetPageTable(ptdesc_page(ptdesc));
f0c92726e89f5c Matthew Wilcox (Oracle 2025-09-08 3149) mod_node_page_state(pgdat, NR_PAGETABLE, ptdesc_nr_pages(ptdesc));
2f569afd9ced9e Martin Schwidefsky 2008-02-08 3150 }
2f569afd9ced9e Martin Schwidefsky 2008-02-08 3151
db6b435d731a8d Qi Zheng 2025-01-08 @3152 static inline void pagetable_dtor(struct ptdesc *ptdesc)
7e11dca14b27e1 Vishal Moola (Oracle 2023-08-07 3153) {
f0c92726e89f5c Matthew Wilcox (Oracle 2025-09-08 3154) pg_data_t *pgdat = NODE_DATA(memdesc_nid(ptdesc->pt_flags));
7e11dca14b27e1 Vishal Moola (Oracle 2023-08-07 3155)
7e11dca14b27e1 Vishal Moola (Oracle 2023-08-07 3156) ptlock_free(ptdesc);
f0c92726e89f5c Matthew Wilcox (Oracle 2025-09-08 3157) __ClearPageTable(ptdesc_page(ptdesc));
f0c92726e89f5c Matthew Wilcox (Oracle 2025-09-08 3158) mod_node_page_state(pgdat, NR_PAGETABLE, -ptdesc_nr_pages(ptdesc));
7e11dca14b27e1 Vishal Moola (Oracle 2023-08-07 3159) }
7e11dca14b27e1 Vishal Moola (Oracle 2023-08-07 3160)
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On 10/8/25 5:54 AM, Jakub Acs wrote:
> redefine VM_* flag constants with BIT()
>
> Make VM_* flag constant definitions consistent - unify all to use BIT()
> macro and define them within an enum.
>
> The bindgen tool is better able to handle BIT(_) declarations when used
> in an enum.
>
> Also add enum definitions for tracepoints.
>
> We have previously changed VM_MERGEABLE in a separate bugfix. This is a
> follow-up to make all the VM_* flag constant definitions consistent, as
> suggested by David in [1].
>
> [1]: https://lore.kernel.org/all/85f852f9-8577-4230-adc7-c52e7f479454@redhat.com/
>
> Signed-off-by: Jakub Acs <acsjakub@amazon.de>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Xu Xin <xu.xin16@zte.com.cn>
> Cc: Chengming Zhou <chengming.zhou@linux.dev>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: Axel Rasmussen <axelrasmussen@google.com>
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> ---
>
> Hi Alice,
>
> thanks for the patch, I squashed it in (should I add your signed-off-by
> too?) and added the TRACE_DEFINE_ENUM calls pointed out by Derrick.
>
> I have the following points to still address, though:
>
> - can the fact that we're not controlling the type of the values if
> using enum be a problem? (likely the indirect control we have through
> the highest value is good enough, but I'm not sure)
>
> - where do TRACE_DEFINE_ENUM calls belong?
> I see them placed e.g. in include/trace/misc/nfs.h for nfs or
> arch/x86/kvm/mmu/mmutrace.h, but I don't see a corresponding file for
> mm.h - does this warrant creating a separate file for these
> definitions?
>
> - with the need for TRACE_DEFINE_ENUM calls, do we still deem this
> to be a good trade-off? - isn't fixing all of these in
> rust/bindings/bindings_helper.h better?
>
> @Derrick, can you point me to how to test for the issue you pointed out?
>
> Thanks,
> Jakub
>
>
> include/linux/mm.h | 142 ++++++++++++++++++++++----------
> rust/bindings/bindings_helper.h | 1 -
> 2 files changed, 98 insertions(+), 45 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 70a2a76007d4..8b9e7a9e7042 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -36,6 +36,7 @@
> #include <linux/rcuwait.h>
> #include <linux/bitmap.h>
> #include <linux/bitops.h>
> +#include <linux/tracepoint.h>
>
> struct mempolicy;
> struct anon_vma;
> @@ -273,57 +274,58 @@ extern unsigned int kobjsize(const void *objp);
> * vm_flags in vm_area_struct, see mm_types.h.
> * When changing, update also include/trace/events/mmflags.h
> */
> -#define VM_NONE 0x00000000
> +enum {
> + VM_NONE = 0,
>
> -#define VM_READ 0x00000001 /* currently active flags */
> -#define VM_WRITE 0x00000002
> -#define VM_EXEC 0x00000004
> -#define VM_SHARED 0x00000008
> + VM_READ = BIT(0), /* currently active flags */
> + VM_WRITE = BIT(1),
> + VM_EXEC = BIT(2),
> + VM_SHARED = BIT(3),
>
> /* mprotect() hardcodes VM_MAYREAD >> 4 == VM_READ, and so for r/w/x bits. */
> -#define VM_MAYREAD 0x00000010 /* limits for mprotect() etc */
> -#define VM_MAYWRITE 0x00000020
> -#define VM_MAYEXEC 0x00000040
> -#define VM_MAYSHARE 0x00000080
> + VM_MAYREAD = BIT(4), /* limits for mprotect() etc */
> + VM_MAYWRITE = BIT(5),
> + VM_MAYEXEC = BIT(6),
> + VM_MAYSHARE = BIT(7),
>
> -#define VM_GROWSDOWN 0x00000100 /* general info on the segment */
> + VM_GROWSDOWN = BIT(8), /* general info on the segment */
> #ifdef CONFIG_MMU
> -#define VM_UFFD_MISSING 0x00000200 /* missing pages tracking */
> + VM_UFFD_MISSING = BIT(9), /* missing pages tracking */
> #else /* CONFIG_MMU */
> -#define VM_MAYOVERLAY 0x00000200 /* nommu: R/O MAP_PRIVATE mapping that might overlay a file mapping */
> + VM_MAYOVERLAY = BIT(9), /* nommu: R/O MAP_PRIVATE mapping that might overlay a file mapping */
> #define VM_UFFD_MISSING 0
> #endif /* CONFIG_MMU */
> -#define VM_PFNMAP 0x00000400 /* Page-ranges managed without "struct page", just pure PFN */
> -#define VM_UFFD_WP 0x00001000 /* wrprotect pages tracking */
> -
> -#define VM_LOCKED 0x00002000
> -#define VM_IO 0x00004000 /* Memory mapped I/O or similar */
> -
> - /* Used by sys_madvise() */
> -#define VM_SEQ_READ 0x00008000 /* App will access data sequentially */
> -#define VM_RAND_READ 0x00010000 /* App will not benefit from clustered reads */
> -
> -#define VM_DONTCOPY 0x00020000 /* Do not copy this vma on fork */
> -#define VM_DONTEXPAND 0x00040000 /* Cannot expand with mremap() */
> -#define VM_LOCKONFAULT 0x00080000 /* Lock the pages covered when they are faulted in */
> -#define VM_ACCOUNT 0x00100000 /* Is a VM accounted object */
> -#define VM_NORESERVE 0x00200000 /* should the VM suppress accounting */
> -#define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
> -#define VM_SYNC 0x00800000 /* Synchronous page faults */
> -#define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
> -#define VM_WIPEONFORK 0x02000000 /* Wipe VMA contents in child. */
> -#define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
> + VM_PFNMAP = BIT(10), /* Page-ranges managed without "struct page", just pure PFN */
> + VM_UFFD_WP = BIT(12), /* wrprotect pages tracking */
> +
> + VM_LOCKED = BIT(13),
> + VM_IO = BIT(14), /* Memory mapped I/O or similar */
> +
> + /* Used by sys_madvise() */
> + VM_SEQ_READ = BIT(15), /* App will access data sequentially */
> + VM_RAND_READ = BIT(16), /* App will not benefit from clustered reads */
> +
> + VM_DONTCOPY = BIT(17), /* Do not copy this vma on fork */
> + VM_DONTEXPAND = BIT(18), /* Cannot expand with mremap() */
> + VM_LOCKONFAULT = BIT(19), /* Lock the pages covered when they are faulted in */
> + VM_ACCOUNT = BIT(20), /* Is a VM accounted object */
> + VM_NORESERVE = BIT(21), /* should the VM suppress accounting */
> + VM_HUGETLB = BIT(22), /* Huge TLB Page VM */
> + VM_SYNC = BIT(23), /* Synchronous page faults */
> + VM_ARCH_1 = BIT(24), /* Architecture-specific flag */
> + VM_WIPEONFORK = BIT(25), /* Wipe VMA contents in child. */
> + VM_DONTDUMP = BIT(26), /* Do not include in the core dump */
>
> #ifdef CONFIG_MEM_SOFT_DIRTY
> -# define VM_SOFTDIRTY 0x08000000 /* Not soft dirty clean area */
> + VM_SOFTDIRTY = BIT(27), /* Not soft dirty clean area */
> #else
> # define VM_SOFTDIRTY 0
> #endif
>
> -#define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
> -#define VM_HUGEPAGE 0x20000000 /* MADV_HUGEPAGE marked this vma */
> -#define VM_NOHUGEPAGE 0x40000000 /* MADV_NOHUGEPAGE marked this vma */
> -#define VM_MERGEABLE BIT(31) /* KSM may merge identical pages */
> + VM_MIXEDMAP = BIT(28), /* Can contain "struct page" and pure PFN pages */
> + VM_HUGEPAGE = BIT(29), /* MADV_HUGEPAGE marked this vma */
> + VM_NOHUGEPAGE = BIT(30), /* MADV_NOHUGEPAGE marked this vma */
> + VM_MERGEABLE = BIT(31), /* KSM may merge identical pages */
>
> #ifdef CONFIG_ARCH_USES_HIGH_VMA_FLAGS
> #define VM_HIGH_ARCH_BIT_0 32 /* bit only usable on 64-bit architectures */
> @@ -333,14 +335,66 @@ extern unsigned int kobjsize(const void *objp);
> #define VM_HIGH_ARCH_BIT_4 36 /* bit only usable on 64-bit architectures */
> #define VM_HIGH_ARCH_BIT_5 37 /* bit only usable on 64-bit architectures */
> #define VM_HIGH_ARCH_BIT_6 38 /* bit only usable on 64-bit architectures */
Is there really any value in having these defines, at this point?
See below...
> -#define VM_HIGH_ARCH_0 BIT(VM_HIGH_ARCH_BIT_0)
> -#define VM_HIGH_ARCH_1 BIT(VM_HIGH_ARCH_BIT_1)
> -#define VM_HIGH_ARCH_2 BIT(VM_HIGH_ARCH_BIT_2)
> -#define VM_HIGH_ARCH_3 BIT(VM_HIGH_ARCH_BIT_3)
> -#define VM_HIGH_ARCH_4 BIT(VM_HIGH_ARCH_BIT_4)
> -#define VM_HIGH_ARCH_5 BIT(VM_HIGH_ARCH_BIT_5)
> -#define VM_HIGH_ARCH_6 BIT(VM_HIGH_ARCH_BIT_6)
> + VM_HIGH_ARCH_0 = BIT(VM_HIGH_ARCH_BIT_0),
Or just omit those bit 0 to bit 7 defines, and write:
VM_HIGH_ARCH_0 = BIT(32),
...etc
> + VM_HIGH_ARCH_1 = BIT(VM_HIGH_ARCH_BIT_1),
> + VM_HIGH_ARCH_2 = BIT(VM_HIGH_ARCH_BIT_2),
> + VM_HIGH_ARCH_3 = BIT(VM_HIGH_ARCH_BIT_3),
> + VM_HIGH_ARCH_4 = BIT(VM_HIGH_ARCH_BIT_4),
> + VM_HIGH_ARCH_5 = BIT(VM_HIGH_ARCH_BIT_5),
> + VM_HIGH_ARCH_6 = BIT(VM_HIGH_ARCH_BIT_6),
> #endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */
> +};
> +
> +TRACE_DEFINE_ENUM(VM_NONE);
> +TRACE_DEFINE_ENUM(VM_READ);
> +TRACE_DEFINE_ENUM(VM_WRITE);
> +TRACE_DEFINE_ENUM(VM_EXEC);
> +TRACE_DEFINE_ENUM(VM_SHARED);
> +TRACE_DEFINE_ENUM(VM_MAYREAD);
> +TRACE_DEFINE_ENUM(VM_MAYWRITE);
> +TRACE_DEFINE_ENUM(VM_MAYEXEC);
> +TRACE_DEFINE_ENUM(VM_MAYSHARE);
> +TRACE_DEFINE_ENUM(VM_GROWSDOWN);
> +TRACE_DEFINE_ENUM(VM_UFFD_MISSING);
> +
> +#ifndef CONFIG_MMU
> +TRACE_DEFINE_ENUM(VM_MAYOVERLAY);
The ifdef handling here for these two items, VM_UFFD_MISSING
and VM_MAYOVERLAY, does not seem to match the way they are handled
above in the enum.
> +#endif /* CONFIG_MMU */
> +
> +TRACE_DEFINE_ENUM(VM_PFNMAP);
> +TRACE_DEFINE_ENUM(VM_UFFD_WP);
> +TRACE_DEFINE_ENUM(VM_LOCKED);
> +TRACE_DEFINE_ENUM(VM_IO);
> +TRACE_DEFINE_ENUM(VM_SEQ_READ);
> +TRACE_DEFINE_ENUM(VM_RAND_READ);
> +TRACE_DEFINE_ENUM(VM_DONTCOPY);
> +TRACE_DEFINE_ENUM(VM_DONTEXPAND);
> +TRACE_DEFINE_ENUM(VM_LOCKONFAULT);
> +TRACE_DEFINE_ENUM(VM_ACCOUNT);
> +TRACE_DEFINE_ENUM(VM_NORESERVE);
> +TRACE_DEFINE_ENUM(VM_HUGETLB);
> +TRACE_DEFINE_ENUM(VM_SYNC);
> +TRACE_DEFINE_ENUM(VM_ARCH_1);
> +TRACE_DEFINE_ENUM(VM_WIPEONFORK);
> +TRACE_DEFINE_ENUM(VM_DONTDUMP);
> +
> +TRACE_DEFINE_ENUM(VM_SOFTDIRTY);
> +
> +TRACE_DEFINE_ENUM(VM_MIXEDMAP);
> +TRACE_DEFINE_ENUM(VM_HUGEPAGE);
> +TRACE_DEFINE_ENUM(VM_NOHUGEPAGE);
> +TRACE_DEFINE_ENUM(VM_MERGEABLE);
> +
> +#ifdef CONFIG_ARCH_USES_HIGH_VMA_FLAGS
> +TRACE_DEFINE_ENUM(VM_HIGH_ARCH_0);
> +TRACE_DEFINE_ENUM(VM_HIGH_ARCH_1);
> +TRACE_DEFINE_ENUM(VM_HIGH_ARCH_2);
> +TRACE_DEFINE_ENUM(VM_HIGH_ARCH_3);
> +TRACE_DEFINE_ENUM(VM_HIGH_ARCH_4);
> +TRACE_DEFINE_ENUM(VM_HIGH_ARCH_5);
> +TRACE_DEFINE_ENUM(VM_HIGH_ARCH_6);
> +#endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */
> +
>
> #ifdef CONFIG_ARCH_HAS_PKEYS
> # define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0
> diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
> index 2e43c66635a2..04b75d4d01c3 100644
> --- a/rust/bindings/bindings_helper.h
> +++ b/rust/bindings/bindings_helper.h
> @@ -108,7 +108,6 @@ const xa_mark_t RUST_CONST_HELPER_XA_PRESENT = XA_PRESENT;
>
> const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC = XA_FLAGS_ALLOC;
> const gfp_t RUST_CONST_HELPER_XA_FLAGS_ALLOC1 = XA_FLAGS_ALLOC1;
> -const vm_flags_t RUST_CONST_HELPER_VM_MERGEABLE = VM_MERGEABLE;
>
> #if IS_ENABLED(CONFIG_ANDROID_BINDER_IPC_RUST)
> #include "../../drivers/android/binder/rust_binder.h"
thanks,
--
John Hubbard
On Wed, 8 Oct 2025 12:54:27 +0000 Jakub Acs <acsjakub@amazon.de> wrote: > Hi Alice, > > thanks for the patch, I squashed it in (should I add your signed-off-by > too?) and added the TRACE_DEFINE_ENUM calls pointed out by Derrick. > > I have the following points to still address, though: > > - can the fact that we're not controlling the type of the values if > using enum be a problem? (likely the indirect control we have through > the highest value is good enough, but I'm not sure) > > - where do TRACE_DEFINE_ENUM calls belong? It's probably best to put them in include/trace/events/mmflags.h > I see them placed e.g. in include/trace/misc/nfs.h for nfs or > arch/x86/kvm/mmu/mmutrace.h, but I don't see a corresponding file for > mm.h - does this warrant creating a separate file for these > definitions? > > - with the need for TRACE_DEFINE_ENUM calls, do we still deem this > to be a good trade-off? - isn't fixing all of these in > rust/bindings/bindings_helper.h better? There's tricks to add a bunch of TRACE_DEFINE_ENUM()s at once. In fact, look at how the macro TRACE_GFP_FLAGS_GENERAL is used in that mmflags.h file. The reason macros work but enums do not is because the pre-processor converts macros to their original values but not enums. The TRACE_EVENT() converts the "printf" part into a string. The macros are changes to their values, but enums do not get changed. The TRACE_DEFINE_ENUM() macro adds magic to map the name of the enum to its value, and on boot up, the printf formats have the enums convert to the values. Note, I'm working on having this performed at build time. -- Steve
On Wed, Oct 08, 2025 at 12:54:27PM +0000, Jakub Acs wrote: > redefine VM_* flag constants with BIT() > > Make VM_* flag constant definitions consistent - unify all to use BIT() > macro and define them within an enum. > > The bindgen tool is better able to handle BIT(_) declarations when used > in an enum. > > Also add enum definitions for tracepoints. > > We have previously changed VM_MERGEABLE in a separate bugfix. This is a > follow-up to make all the VM_* flag constant definitions consistent, as > suggested by David in [1]. > > [1]: https://lore.kernel.org/all/85f852f9-8577-4230-adc7-c52e7f479454@redhat.com/ > > Signed-off-by: Jakub Acs <acsjakub@amazon.de> > Cc: Andrew Morton <akpm@linux-foundation.org> > Cc: David Hildenbrand <david@redhat.com> > Cc: Xu Xin <xu.xin16@zte.com.cn> > Cc: Chengming Zhou <chengming.zhou@linux.dev> > Cc: Peter Xu <peterx@redhat.com> > Cc: Axel Rasmussen <axelrasmussen@google.com> > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org > --- > > Hi Alice, > > thanks for the patch, I squashed it in (should I add your signed-off-by > too?) and added the TRACE_DEFINE_ENUM calls pointed out by Derrick. You could add this if you go with the enum approach: Co-Developed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Alice Ryhl <aliceryhl@google.com> > I have the following points to still address, though: > > - can the fact that we're not controlling the type of the values if > using enum be a problem? (likely the indirect control we have through > the highest value is good enough, but I'm not sure) The compiler should pick the right integer type in this case. > - where do TRACE_DEFINE_ENUM calls belong? > I see them placed e.g. in include/trace/misc/nfs.h for nfs or > arch/x86/kvm/mmu/mmutrace.h, but I don't see a corresponding file for > mm.h - does this warrant creating a separate file for these > definitions? > > - with the need for TRACE_DEFINE_ENUM calls, do we still deem this > to be a good trade-off? - isn't fixing all of these in > rust/bindings/bindings_helper.h better? > > @Derrick, can you point me to how to test for the issue you pointed out? I'm not familiar with the TRACE_DEFINE_ENUM unfortunately. > +#ifndef CONFIG_MMU > +TRACE_DEFINE_ENUM(VM_MAYOVERLAY); > +#endif /* CONFIG_MMU */ Here I think you want: #ifdef CONFIG_MMU TRACE_DEFINE_ENUM(VM_UFFD_MISSING); #else TRACE_DEFINE_ENUM(VM_MAYOVERLAY); #endif /* CONFIG_MMU */ > +TRACE_DEFINE_ENUM(VM_SOFTDIRTY); Here I think you want: #ifdef CONFIG_MEM_SOFT_DIRTY TRACE_DEFINE_ENUM(VM_SOFTDIRTY); #endif Alice
On Wed, Oct 08, 2025 at 01:15:12PM +0000, Alice Ryhl wrote:
> On Wed, Oct 08, 2025 at 12:54:27PM +0000, Jakub Acs wrote:
> > redefine VM_* flag constants with BIT()
> >
> > Make VM_* flag constant definitions consistent - unify all to use BIT()
> > macro and define them within an enum.
> >
> > The bindgen tool is better able to handle BIT(_) declarations when used
> > in an enum.
> >
> > Also add enum definitions for tracepoints.
> >
> > We have previously changed VM_MERGEABLE in a separate bugfix. This is a
> > follow-up to make all the VM_* flag constant definitions consistent, as
> > suggested by David in [1].
> >
> > [1]: https://lore.kernel.org/all/85f852f9-8577-4230-adc7-c52e7f479454@redhat.com/
> >
> > Signed-off-by: Jakub Acs <acsjakub@amazon.de>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Xu Xin <xu.xin16@zte.com.cn>
> > Cc: Chengming Zhou <chengming.zhou@linux.dev>
> > Cc: Peter Xu <peterx@redhat.com>
> > Cc: Axel Rasmussen <axelrasmussen@google.com>
> > Cc: linux-mm@kvack.org
> > Cc: linux-kernel@vger.kernel.org
> > ---
> >
> > Hi Alice,
> >
> > thanks for the patch, I squashed it in (should I add your signed-off-by
> > too?) and added the TRACE_DEFINE_ENUM calls pointed out by Derrick.
>
> You could add this if you go with the enum approach:
>
> Co-Developed-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
>
> > I have the following points to still address, though:
> >
> > - can the fact that we're not controlling the type of the values if
> > using enum be a problem? (likely the indirect control we have through
> > the highest value is good enough, but I'm not sure)
>
> The compiler should pick the right integer type in this case.
>
> > - where do TRACE_DEFINE_ENUM calls belong?
> > I see them placed e.g. in include/trace/misc/nfs.h for nfs or
> > arch/x86/kvm/mmu/mmutrace.h, but I don't see a corresponding file for
> > mm.h - does this warrant creating a separate file for these
> > definitions?
> >
> > - with the need for TRACE_DEFINE_ENUM calls, do we still deem this
> > to be a good trade-off? - isn't fixing all of these in
> > rust/bindings/bindings_helper.h better?
> >
> > @Derrick, can you point me to how to test for the issue you pointed out?
>
> I'm not familiar with the TRACE_DEFINE_ENUM unfortunately.
rostedt already filled in the technical details, so I can supply an
example from code in XFS:
$ git grep -E '(XFS_REFC_DOMAIN_COW|XFS_REFC_DOMAIN_STRINGS)' fs/xfs/
fs/xfs/libxfs/xfs_refcount.c:118: irec->rc_domain = XFS_REFC_DOMAIN_COW;
<snip>
fs/xfs/libxfs/xfs_types.h:164: XFS_REFC_DOMAIN_COW,
fs/xfs/libxfs/xfs_types.h:167:#define XFS_REFC_DOMAIN_STRINGS \
fs/xfs/libxfs/xfs_types.h:169: { XFS_REFC_DOMAIN_COW, "cow" }
<snip>
fs/xfs/xfs_trace.h:1117:TRACE_DEFINE_ENUM(XFS_REFC_DOMAIN_COW);
fs/xfs/xfs_trace.h:3635: __print_symbolic(__entry->domain, XFS_REFC_DOMAIN_STRINGS),
XFS_REFC_DOMAIN_COW is part of an enumeration:
enum xfs_refc_domain {
XFS_REFC_DOMAIN_SHARED = 0,
XFS_REFC_DOMAIN_COW,
};
Which then has a string decoder macro defined for use in
__print_symbolic:
#define XFS_REFC_DOMAIN_STRINGS \
{ XFS_REFC_DOMAIN_SHARED, "shared" }, \
{ XFS_REFC_DOMAIN_COW, "cow" }
Note the TRACE_DEFINE_ENUM usage in the grep output.
Let's look at one of the tracepoints that uses XFS_REFC_DOMAIN_STRINGS.
The class is xfs_refcount_extent_class, so a relevant tracepoint is
xfs_refcount_get:
# cat /sys/kernel/tracing/events/xfs/xfs_refcount_get/format
name: xfs_refcount_get
ID: 1839
format:
field:unsigned short common_type; offset:0; size:2; signed:0;
field:unsigned char common_flags; offset:2; size:1; signed:0;
field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
field:int common_pid; offset:4; size:4; signed:1;
field:dev_t dev; offset:8; size:4; signed:0;
field:enum xfs_group_type type; offset:12; size:1; signed:0;
field:xfs_agnumber_t agno; offset:16; size:4; signed:0;
field:enum xfs_refc_domain domain; offset:20; size:4; signed:0;
field:xfs_agblock_t startblock; offset:24; size:4; signed:0;
field:xfs_extlen_t blockcount; offset:28; size:4; signed:0;
field:xfs_nlink_t refcount; offset:32; size:4; signed:0;
print fmt: "dev %d:%d %sno 0x%x dom %s gbno 0x%x fsbcount 0x%x refcount %u", ((unsigned int) ((REC->dev) >> 20)), ((unsigned int) ((REC->dev) & ((1U << 20) - 1))), __print_symbolic(REC->type, { 0, "ag" }, { 1, "rtg" }), REC->agno, __print_symbolic(REC->domain, { 0, "shared" }, { 1, "cow" }), REC->startblock, REC->blockcount, REC->refcount
Notice that the XFS_REFC_DOMAIN_* enumeration values have been
converted into their raw numeric form inside the __print_symbolic
construction so that they're ready for trace-cmd-report.
It's really helpful to have ftrace render bitfield and enumeration
"integers" into something human-readable, especially in filesystems
where there are a lot of those.
--D
> > +#ifndef CONFIG_MMU
> > +TRACE_DEFINE_ENUM(VM_MAYOVERLAY);
> > +#endif /* CONFIG_MMU */
>
> Here I think you want:
>
> #ifdef CONFIG_MMU
> TRACE_DEFINE_ENUM(VM_UFFD_MISSING);
> #else
> TRACE_DEFINE_ENUM(VM_MAYOVERLAY);
> #endif /* CONFIG_MMU */
>
> > +TRACE_DEFINE_ENUM(VM_SOFTDIRTY);
>
> Here I think you want:
>
> #ifdef CONFIG_MEM_SOFT_DIRTY
> TRACE_DEFINE_ENUM(VM_SOFTDIRTY);
> #endif
>
> Alice
>
© 2016 - 2026 Red Hat, Inc.