* [akpm-mm:mm-unstable 313/322] include/linux/huge_mm.h:274:23: error: variably modified 'stats' at file scope
@ 2024-04-06 8:07 kernel test robot
2024-04-07 0:52 ` Barry Song
0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2024-04-06 8:07 UTC (permalink / raw)
To: Barry Song; +Cc: oe-kbuild-all, Andrew Morton, Linux Memory Management List
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-allmodconfig (https://download.01.org/0day-ci/archive/20240406/202404061627.ungVloow-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240406/202404061627.ungVloow-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/202404061627.ungVloow-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from include/linux/mm.h:1115,
from include/linux/mman.h:5,
from arch/powerpc/kernel/asm-offsets.c:19:
>> include/linux/huge_mm.h:274:23: error: variably modified 'stats' at file scope
274 | unsigned long stats[PMD_ORDER + 1][__MTHP_STAT_COUNT];
| ^~~~~
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 +/stats +274 include/linux/huge_mm.h
272
273 struct mthp_stat {
> 274 unsigned long stats[PMD_ORDER + 1][__MTHP_STAT_COUNT];
275 };
276
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [akpm-mm:mm-unstable 313/322] include/linux/huge_mm.h:274:23: error: variably modified 'stats' at file scope
2024-04-06 8:07 [akpm-mm:mm-unstable 313/322] include/linux/huge_mm.h:274:23: error: variably modified 'stats' at file scope kernel test robot
@ 2024-04-07 0:52 ` Barry Song
2024-04-07 4:04 ` Barry Song
0 siblings, 1 reply; 3+ messages in thread
From: Barry Song @ 2024-04-07 0:52 UTC (permalink / raw)
To: lkp; +Cc: akpm, linux-mm, oe-kbuild-all, v-songbaohua
>
>
> 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-allmodconfig (https://download.01.org/0day-ci/archive/20240406/202404061627.ungVloow-lkp@intel.com/config)
> compiler: powerpc64-linux-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240406/202404061627.ungVloow-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/202404061627.ungVloow-lkp@intel.com/
> All errors (new ones prefixed by >>):
>
> In file included from include/linux/mm.h:1115,
> from include/linux/mman.h:5,
> from arch/powerpc/kernel/asm-offsets.c:19:
>>> include/linux/huge_mm.h:274:23: error: variably modified 'stats' at file scope
> 274 | unsigned long stats[PMD_ORDER + 1][__MTHP_STAT_COUNT];
> | ^~~~~
> make[3]: *** [scripts/Makefile.build:117: arch/powerpc/kernel/asm-offsets.s] Error 1
Should have been fixed by:
From 573aa50dbebcd4b2650d477374b28aa53c21b968 Mon Sep 17 00:00:00 2001
From: Barry Song <v-songbaohua@oppo.com>
Date: Sun, 7 Apr 2024 12:23:35 +1200
Subject: [PATCH] mm: fix powerpc build issue
Signed-off-by: Barry Song <v-songbaohua@oppo.com>
---
include/linux/huge_mm.h | 9 ++++-----
mm/huge_memory.c | 13 +++++++++++--
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index c5d33017a4dd..0717063dc5e7 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -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() \
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 5b875f0fc923..10bc3f54cb81 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -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];
}
@@ -602,6 +602,7 @@ static struct thpsize *thpsize_create(int order, struct kobject *parent)
static void thpsize_release(struct kobject *kobj)
{
kfree(to_thpsize(kobj));
+ free_percpu(mthp_stats);
}
static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj)
@@ -636,6 +637,13 @@ static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj)
goto remove_hp_group;
}
+ mthp_stats = (struct mthp_stat __percpu *)alloc_percpu((PMD_ORDER + 1) *
+ sizeof(sizeof(mthp_stats->stats[0])));
+ if (!mthp_stats) {
+ err = -ENOMEM;
+ goto remove_hp_group;
+ }
+
orders = THP_ORDERS_ALL_ANON;
order = highest_order(orders);
while (orders) {
@@ -673,6 +681,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)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [akpm-mm:mm-unstable 313/322] include/linux/huge_mm.h:274:23: error: variably modified 'stats' at file scope
2024-04-07 0:52 ` Barry Song
@ 2024-04-07 4:04 ` Barry Song
0 siblings, 0 replies; 3+ messages in thread
From: Barry Song @ 2024-04-07 4:04 UTC (permalink / raw)
To: lkp; +Cc: akpm, linux-mm, oe-kbuild-all, v-songbaohua
On Sun, Apr 7, 2024 at 12:52 PM Barry Song <21cnbao@gmail.com> wrote:
>
> >
> >
> > 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-allmodconfig (https://download.01.org/0day-ci/archive/20240406/202404061627.ungVloow-lkp@intel.com/config)
> > compiler: powerpc64-linux-gcc (GCC) 13.2.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240406/202404061627.ungVloow-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/202404061627.ungVloow-lkp@intel.com/
>
> > All errors (new ones prefixed by >>):
> >
> > In file included from include/linux/mm.h:1115,
> > from include/linux/mman.h:5,
> > from arch/powerpc/kernel/asm-offsets.c:19:
> >>> include/linux/huge_mm.h:274:23: error: variably modified 'stats' at file scope
> > 274 | unsigned long stats[PMD_ORDER + 1][__MTHP_STAT_COUNT];
> > | ^~~~~
> > make[3]: *** [scripts/Makefile.build:117: arch/powerpc/kernel/asm-offsets.s] Error 1
>
> Should have been fixed by:
>
> From 573aa50dbebcd4b2650d477374b28aa53c21b968 Mon Sep 17 00:00:00 2001
> From: Barry Song <v-songbaohua@oppo.com>
> Date: Sun, 7 Apr 2024 12:23:35 +1200
> Subject: [PATCH] mm: fix powerpc build issue
>
> Signed-off-by: Barry Song <v-songbaohua@oppo.com>
> ---
> include/linux/huge_mm.h | 9 ++++-----
> mm/huge_memory.c | 13 +++++++++++--
> 2 files changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> index c5d33017a4dd..0717063dc5e7 100644
> --- a/include/linux/huge_mm.h
> +++ b/include/linux/huge_mm.h
> @@ -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() \
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 5b875f0fc923..10bc3f54cb81 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -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];
> }
> @@ -602,6 +602,7 @@ static struct thpsize *thpsize_create(int order, struct kobject *parent)
> static void thpsize_release(struct kobject *kobj)
> {
> kfree(to_thpsize(kobj));
> + free_percpu(mthp_stats);
> }
>
> static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj)
> @@ -636,6 +637,13 @@ static int __init hugepage_init_sysfs(struct kobject **hugepage_kobj)
> goto remove_hp_group;
> }
>
> + mthp_stats = (struct mthp_stat __percpu *)alloc_percpu((PMD_ORDER + 1) *
> + sizeof(sizeof(mthp_stats->stats[0])));
sorry. I made the wrong allocation size. please change the above two
lines to the below when you
test the patch:
+ 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 +681,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)
> --
> 2.34.1
>
Thanks
Barry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-07 4:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-06 8:07 [akpm-mm:mm-unstable 313/322] include/linux/huge_mm.h:274:23: error: variably modified 'stats' at file scope kernel test robot
2024-04-07 0:52 ` Barry Song
2024-04-07 4:04 ` Barry Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox