include/linux/huge_mm.h:274:16: error: fields must have a constant size: 'variable length array in structure' extension will never be supported
Subsystems (2)
kernel test robot
build bottree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable head: f43b3aae94511d62174c3b29239da0dd22d0eeb3 commit: d4358ee0a075e232114dfec0cd162860cfa2771b [313/322] mm: add per-order mTHP anon_alloc and anon_alloc_fallback counters config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20240406/[email protected]/config) compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 546dc2245ffc4cccd0b05b58b7a5955e355a3b27) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240406/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
In file included from arch/powerpc/kernel/asm-offsets.c:19:
In file included from include/linux/mman.h:5:
In file included from include/linux/mm.h:1115:
>> include/linux/huge_mm.h:274:22: warning: variable length array used [-Wvla]
274 | unsigned long stats[PMD_ORDER + 1][__MTHP_STAT_COUNT];
| ^~~~~~~~~~~~~
include/linux/pgtable.h:8:20: note: expanded from macro 'PMD_ORDER'
8 | #define PMD_ORDER (PMD_SHIFT - PAGE_SHIFT)
| ^
arch/powerpc/include/asm/book3s/64/pgtable.h:207:33: note: expanded from macro 'PMD_SHIFT'
207 | #define PMD_SHIFT (PAGE_SHIFT + PTE_INDEX_SIZE)
| ^
arch/powerpc/include/asm/book3s/64/pgtable.h:156:25: note: expanded from macro 'PTE_INDEX_SIZE'
156 | #define PTE_INDEX_SIZE __pte_index_size
| ^
In file included from arch/powerpc/kernel/asm-offsets.c:19:
In file included from include/linux/mman.h:5:
In file included from include/linux/mm.h:1115:
>> include/linux/huge_mm.h:274:16: error: fields must have a constant size: 'variable length array in structure' extension will never be supported
274 | unsigned long stats[PMD_ORDER + 1][__MTHP_STAT_COUNT];
| ^
>> include/linux/huge_mm.h:283:2: error: indirection requires pointer operand ('void' invalid)
283 | this_cpu_inc(mthp_stats.stats[order][item]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:501:28: note: expanded from macro 'this_cpu_inc'
501 | #define this_cpu_inc(pcp) this_cpu_add(pcp, 1)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:491:33: note: expanded from macro 'this_cpu_add'
491 | #define this_cpu_add(pcp, val) __pcpu_size_call(this_cpu_add_, pcp, val)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:365:11: note: expanded from macro '__pcpu_size_call'
365 | case 1: stem##1(variable, __VA_ARGS__);break; \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/asm-generic/percpu.h:401:34: note: expanded from macro 'this_cpu_add_1'
401 | #define this_cpu_add_1(pcp, val) this_cpu_generic_to_op(pcp, val, +=)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/percpu.h:156:2: note: expanded from macro 'this_cpu_generic_to_op'
156 | raw_cpu_generic_to_op(pcp, val, op); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/percpu.h:72:2: note: expanded from macro 'raw_cpu_generic_to_op'
72 | *raw_cpu_ptr(&(pcp)) op val; \
| ^~~~~~~~~~~~~~~~~~~~
In file included from arch/powerpc/kernel/asm-offsets.c:19:
In file included from include/linux/mman.h:5:
In file included from include/linux/mm.h:1115:
>> include/linux/huge_mm.h:283:2: error: indirection requires pointer operand ('void' invalid)
283 | this_cpu_inc(mthp_stats.stats[order][item]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:501:28: note: expanded from macro 'this_cpu_inc'
501 | #define this_cpu_inc(pcp) this_cpu_add(pcp, 1)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:491:33: note: expanded from macro 'this_cpu_add'
491 | #define this_cpu_add(pcp, val) __pcpu_size_call(this_cpu_add_, pcp, val)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:366:11: note: expanded from macro '__pcpu_size_call'
366 | case 2: stem##2(variable, __VA_ARGS__);break; \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/asm-generic/percpu.h:404:34: note: expanded from macro 'this_cpu_add_2'
404 | #define this_cpu_add_2(pcp, val) this_cpu_generic_to_op(pcp, val, +=)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/percpu.h:156:2: note: expanded from macro 'this_cpu_generic_to_op'
156 | raw_cpu_generic_to_op(pcp, val, op); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/percpu.h:72:2: note: expanded from macro 'raw_cpu_generic_to_op'
72 | *raw_cpu_ptr(&(pcp)) op val; \
| ^~~~~~~~~~~~~~~~~~~~
In file included from arch/powerpc/kernel/asm-offsets.c:19:
In file included from include/linux/mman.h:5:
In file included from include/linux/mm.h:1115:
>> include/linux/huge_mm.h:283:2: error: indirection requires pointer operand ('void' invalid)
283 | this_cpu_inc(mthp_stats.stats[order][item]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:501:28: note: expanded from macro 'this_cpu_inc'
501 | #define this_cpu_inc(pcp) this_cpu_add(pcp, 1)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:491:33: note: expanded from macro 'this_cpu_add'
491 | #define this_cpu_add(pcp, val) __pcpu_size_call(this_cpu_add_, pcp, val)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:367:11: note: expanded from macro '__pcpu_size_call'
367 | case 4: stem##4(variable, __VA_ARGS__);break; \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/asm-generic/percpu.h:407:34: note: expanded from macro 'this_cpu_add_4'
407 | #define this_cpu_add_4(pcp, val) this_cpu_generic_to_op(pcp, val, +=)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/percpu.h:156:2: note: expanded from macro 'this_cpu_generic_to_op'
156 | raw_cpu_generic_to_op(pcp, val, op); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/percpu.h:72:2: note: expanded from macro 'raw_cpu_generic_to_op'
72 | *raw_cpu_ptr(&(pcp)) op val; \
| ^~~~~~~~~~~~~~~~~~~~
In file included from arch/powerpc/kernel/asm-offsets.c:19:
In file included from include/linux/mman.h:5:
In file included from include/linux/mm.h:1115:
>> include/linux/huge_mm.h:283:2: error: indirection requires pointer operand ('void' invalid)
283 | this_cpu_inc(mthp_stats.stats[order][item]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:501:28: note: expanded from macro 'this_cpu_inc'
501 | #define this_cpu_inc(pcp) this_cpu_add(pcp, 1)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:491:33: note: expanded from macro 'this_cpu_add'
491 | #define this_cpu_add(pcp, val) __pcpu_size_call(this_cpu_add_, pcp, val)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:368:11: note: expanded from macro '__pcpu_size_call'
368 | case 8: stem##8(variable, __VA_ARGS__);break; \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/asm-generic/percpu.h:410:34: note: expanded from macro 'this_cpu_add_8'
410 | #define this_cpu_add_8(pcp, val) this_cpu_generic_to_op(pcp, val, +=)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/percpu.h:156:2: note: expanded from macro 'this_cpu_generic_to_op'
156 | raw_cpu_generic_to_op(pcp, val, op); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/asm-generic/percpu.h:72:2: note: expanded from macro 'raw_cpu_generic_to_op'
72 | *raw_cpu_ptr(&(pcp)) op val; \
| ^~~~~~~~~~~~~~~~~~~~
In file included from arch/powerpc/kernel/asm-offsets.c:19:
In file included from include/linux/mman.h:5:
In file included from include/linux/mm.h:2237:
include/linux/vmstat.h:500:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
500 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
501 | item];
| ~~~~
include/linux/vmstat.h:507:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
507 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
508 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:514:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
514 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:519:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
519 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
520 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:528:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
528 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
529 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
In file included from arch/powerpc/kernel/asm-offsets.c:19:
include/linux/mman.h:157:9: warning: division by zero is undefined [-Wdivision-by-zero]
157 | _calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED ) |
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
include/linux/mman.h:158:9: warning: division by zero is undefined [-Wdivision-by-zero]
158 | _calc_vm_trans(flags, MAP_SYNC, VM_SYNC ) |
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~
include/linux/mman.h:159:9: warning: division by zero is undefined [-Wdivision-by-zero]
159 | _calc_vm_trans(flags, MAP_STACK, VM_NOHUGEPAGE) |
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
| ^ ~~~~~~~~~~~~~~~~~ 9 warnings and 5 errors generated.
make[3]: *** [scripts/Makefile.build:117: arch/powerpc/kernel/asm-offsets.s] Error 1 make[3]: Target 'prepare' not remade because of errors.
make[2]: *** [Makefile:1197: prepare0] Error 2
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:240: __sub-make] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:240: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
vim +274 include/linux/huge_mm.h
272
273 struct mthp_stat {
> 274 unsigned long stats[PMD_ORDER + 1][__MTHP_STAT_COUNT];
275 };
276
277 DECLARE_PER_CPU(struct mthp_stat, mthp_stats);
278
279 static inline void count_mthp_stat(int order, enum mthp_stat_item item)
280 {
281 if (unlikely(order > PMD_ORDER))
282 return;
> 283 this_cpu_inc(mthp_stats.stats[order][item]); 284 }
285
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH 313/322 include/linux/huge_mm.h:274:16: error: fields must have a constant size: 'variable length array in structure' extension will never be supported
Quoted 12 lines
tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable head: f43b3aae94511d62174c3b29239da0dd22d0eeb3 commit: d4358ee0a075e232114dfec0cd162860cfa2771b [313/322] mm: add per-order mTHP anon_alloc and anon_alloc_fallback counters config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20240406/[email protected]/config) compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 546dc2245ffc4cccd0b05b58b7a5955e355a3b27) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240406/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Quoted 8 lines
All error/warnings (new ones prefixed by >>):
In file included from
arch/powerpc/kernel/asm-offsets.c:19:
In file included frominclude/linux/mman.h:5:
In file included frominclude/linux/mm.h:1115:Quoted 1 line
Quoted 1 line
include/linux/huge_mm.h:274:22: warning: variable length array used [-Wvla]274 | unsigned long stats[PMD_ORDER + 1][__MTHP_STAT_COUNT]; | ^~~~~~~~~~~~~
This is amazing. powerpc's PMD_ORDER isn't const. I will move to alloc_percpu instead of using a static array.
Thanks
Barry
Quoted 17 lines
Quoted 17 lines
tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable head: f43b3aae94511d62174c3b29239da0dd22d0eeb3 commit: d4358ee0a075e232114dfec0cd162860cfa2771b [313/322] mm: add per-order mTHP anon_alloc and anon_alloc_fallback counters config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20240406/[email protected]/config) compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 546dc2245ffc4cccd0b05b58b7a5955e355a3b27) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240406/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All error/warnings (new ones prefixed by >>):
In file included from
arch/powerpc/kernel/asm-offsets.c:19:
In file included frominclude/linux/mman.h:5:
In file included frominclude/linux/mm.h:1115:
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
include/linux/huge_mm.h:274:22: warning: variable length array used [-Wvla]274 | unsigned long stats[PMD_ORDER + 1][__MTHP_STAT_COUNT];| ^~~~~~~~~~~~~This is amazing. powerpc's
PMD_ORDERisn't const. I will move toalloc_percpuinstead of using a static array.
As replied in another thread, can you please test the below patch? this is v2 combining the fix and the fix of the fix.
From 6f8604a51ff3333be467e2a681a1f1e8a5d41c48 Mon Sep 17 00:00:00 2001
From: Barry Song <[email protected]>
Date: Sun, 7 Apr 2024 12:23:35 +1200
Subject: [PATCH v2] mm: fix powerpc build issue
On powerpc, PMD_ORDER is not a constant variable. We should transition to using alloc_percpu instead of a static percpu array.
--- include/linux/huge_mm.h | 9 ++++----- mm/huge_memory.c | 12 ++++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-)
include/linux/huge_mm.h +4 -5
@@ -271,16 +271,15 @@ enum mthp_stat_item { };struct mthp_stat { -unsigned long stats[PMD_ORDER +1 ][__MTHP_STAT_COUNT]; +unsigned long stats[0 ][__MTHP_STAT_COUNT]; }; -DECLARE_PER_CPU(struct mthp_stat, mthp_stats); +extern struct mthp_stat __percpu *mthp_stats;static inline void count_mthp_stat (int order,enum mthp_stat_item item) { -if (unlikely (order >PMD_ORDER )) -return ; -this_cpu_inc (mthp_stats.stats[order][item]); +if (likely (order <=PMD_ORDER )) +raw_cpu_ptr (mthp_stats)->stats[order][item]++; }#define transparent_hugepage_use_zero_page () \
mm/huge_memory.c +10 -2
@@ -526,7 +526,7 @@ static const struct kobj_type thpsize_ktype = { .sysfs_ops = &kobj_sysfs_ops, }; -DEFINE_PER_CPU(struct mthp_stat, mthp_stats) = {{{0}}}; +struct mthp_stat __percpu *mthp_stats;static unsigned long sum_mthp_stat (int order,enum mthp_stat_item item) {
@@ -534,7 +534,7 @@ static unsigned long sum_mthp_stat(int order, enum mthp_stat_item item)int cpu;for_each_online_cpu (cpu) { -struct mthp_stat *this = &per_cpu (mthp_stats, cpu); +struct mthp_stat *this =per_cpu_ptr (mthp_stats, cpu); sum += this->stats[order][item]; }
@@ -636,6 +636,13 @@ static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj) goto remove_hp_group; } + mthp_stats =__alloc_percpu ((PMD_ORDER +1 ) *sizeof (mthp_stats->stats[0 ]), +sizeof (unsigned long )); +if (!mthp_stats) { + err = -ENOMEM ; + goto remove_hp_group; + } + orders =THP_ORDERS_ALL_ANON ; order =highest_order (orders);while (orders) {
@@ -673,6 +680,7 @@ static void __init hugepage_exit_sysfs(struct kobject *hugepage_kobj)sysfs_remove_group (hugepage_kobj, &khugepaged_attr_group);sysfs_remove_group (hugepage_kobj, &hugepage_attr_group);kobject_put (hugepage_kobj); + free_percpu(mthp_stats); }#else static inline int hugepage_init_sysfs (struct kobject **hugepage_kobj)
Signature · 1 line
2.34.1
Yujie Liu
Tested-byHi Barry,
Quoted 18 lines · Barry Song
Quoted 18 lines
Quoted 18 lines
tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-unstable head: f43b3aae94511d62174c3b29239da0dd22d0eeb3 commit: d4358ee0a075e232114dfec0cd162860cfa2771b [313/322] mm: add per-order mTHP anon_alloc and anon_alloc_fallback counters config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20240406/[email protected]/config) compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 546dc2245ffc4cccd0b05b58b7a5955e355a3b27) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240406/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All error/warnings (new ones prefixed by >>):
In file included from
arch/powerpc/kernel/asm-offsets.c:19:
In file included frominclude/linux/mman.h:5:
In file included frominclude/linux/mm.h:1115:Quoted 1 line
Quoted 1 line
include/linux/huge_mm.h:274:22: warning: variable length array used [-Wvla]
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
274 | unsigned long stats[PMD_ORDER + 1][__MTHP_STAT_COUNT];| ^~~~~~~~~~~~~This is amazing. powerpc's
PMD_ORDERisn't const. I will move toalloc_percpuinstead of using a static array.As replied in another thread, can you please test the below patch? this is v2 combining the fix and the fix of the fix.
This v2 patch fixes the errors/warnings reported in both this thread and thread [1].
[1] https://lore.kernel.org/all/[email protected]/
Quoted 88 lines
From
6f8604a51ff3333be467e2a681a1f1e8a5d41c48Mon Sep 17 00:00:00 2001
From: Barry Song <[email protected]>
Date: Sun, 7 Apr 2024 12:23:35 +1200
Subject: [PATCH v2] mm: fix powerpc build issueOn powerpc,
PMD_ORDERis not a constant variable. We should transition to usingalloc_percpuinstead of a static percpu array.Signed-off-by Barry Song <[email protected]>--- include/linux/huge_mm.h | 9 ++++----- mm/huge_memory.c | 12 ++++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-)include/linux/huge_mm.h +4
-5@@ -271,16 +271,15 @@ enum mthp_stat_item { };struct mthp_stat { -unsigned long stats[PMD_ORDER +1 ][__MTHP_STAT_COUNT]; +unsigned long stats[0 ][__MTHP_STAT_COUNT]; }; -DECLARE_PER_CPU(struct mthp_stat, mthp_stats); +extern struct mthp_stat __percpu *mthp_stats;static inline void count_mthp_stat (int order,enum mthp_stat_item item) { -if (unlikely (order >PMD_ORDER )) -return ; -this_cpu_inc (mthp_stats.stats[order][item]); +if (likely (order <=PMD_ORDER )) +raw_cpu_ptr (mthp_stats)->stats[order][item]++; }#define transparent_hugepage_use_zero_page () \mm/huge_memory.c +10
-2@@ -526,7 +526,7 @@ static const struct kobj_type thpsize_ktype = { .sysfs_ops = &kobj_sysfs_ops, }; -DEFINE_PER_CPU(struct mthp_stat, mthp_stats) = {{{0}}}; +struct mthp_stat __percpu *mthp_stats;static unsigned long sum_mthp_stat (int order,enum mthp_stat_item item) {@@ -534,7 +534,7 @@ static unsigned long sum_mthp_stat(int order, enum mthp_stat_item item)int cpu;for_each_online_cpu (cpu) { -struct mthp_stat *this = &per_cpu (mthp_stats, cpu); +struct mthp_stat *this =per_cpu_ptr (mthp_stats, cpu); sum += this->stats[order][item]; }@@ -636,6 +636,13 @@ static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj) goto remove_hp_group; } + mthp_stats =__alloc_percpu ((PMD_ORDER +1 ) *sizeof (mthp_stats->stats[0 ]), +sizeof (unsigned long )); +if (!mthp_stats) { + err = -ENOMEM ; + goto remove_hp_group; + } + orders =THP_ORDERS_ALL_ANON ; order =highest_order (orders);while (orders) {@@ -673,6 +680,7 @@ static void __init hugepage_exit_sysfs(struct kobject *hugepage_kobj)sysfs_remove_group (hugepage_kobj, &khugepaged_attr_group);sysfs_remove_group (hugepage_kobj, &hugepage_attr_group);kobject_put (hugepage_kobj); + free_percpu(mthp_stats); }#else static inline int hugepage_init_sysfs (struct kobject **hugepage_kobj)Signature · 1 line
2.34.1