Enable strict percpu address space checks
Subsystems (11)
cover Enable strict percpu address space checks
This patchset enables strict percpu address space checks via x86 named address space qualifiers. Percpu variables are declared in __seg_gs/__seg_fs named AS and kept named AS qualified until they are dereferenced via percpu accessor. This approach enables various compiler checks for cross-namespace variable assignments.
Please note that sparse doesn't know anything about __typeof_unqual__() operator, so the usage of __typeof_unqual__() breaks sparse checking.
Also, the last patch hijacks __percpu tag and repurposes it as a named address space qualifier. While this works surprisingly well in this RFC patchset, I would really appreciate some help on how to rewrite this hack into some "production ready" code.
Uros Bizjak (3):
percpu: Define __pcpu_typeof()
percpu: Assorted fixes found by strict percpu address space checks percpu/x86: [RFH] Enable strict percpu checks via named AS qualifiers
arch/x86/include/asm/percpu.h | 53 ++++++++++++++++++++++++---------- arch/x86/kernel/head64.c | 3 +- drivers/base/devres.c | 2 +- fs/aio.c | 2 +- include/linux/cleanup.h | 4 +-- include/linux/compiler_types.h | 2 +- include/linux/part_stat.h | 2 +- include/linux/percpu-defs.h | 39 ++++++++++++++++++++----- include/linux/prandom.h | 1 + init/Kconfig | 3 ++ kernel/events/hw_breakpoint.c | 4 +-- kernel/locking/percpu-rwsem.c | 2 +- kernel/workqueue.c | 2 +- lib/percpu_counter.c | 2 +- net/core/dev.c | 2 +- 15 files changed, 87 insertions(+), 36 deletions(-)
Signature · 1 line
2.45.2
RFC PATCH 1/3 percpu: Define __pcpu_typeof()
Define __pcpu_typeof() to use __typeof_unqual__() as typeof operator when available, to return unqualified type of the expression.
If an arch defines __percpu variables in their own named address space, then __pcpu_typeof() returns unqualified type of the expression without named address space quialifier when CONFIG_CC_HAS_TYPEOF_UNQUAL is defined.
--- arch/x86/include/asm/percpu.h | 38 ++++++++++++++++++++++------------ include/linux/part_stat.h | 2 +- include/linux/percpu-defs.h | 39 ++++++++++++++++++++++++++++------- init/Kconfig | 3 +++ kernel/locking/percpu-rwsem.c | 2 +- 5 files changed, 62 insertions(+), 22 deletions(-)
arch/x86/include/asm/percpu.h +25 -13
@@ -73,10 +73,14 @@unsigned long tcp_ptr__ =raw_cpu_read_long (this_cpu_off); \ \ tcp_ptr__ += (__force unsigned long )(_ptr); \ - (typeof(*(_ptr)) __kernel __force *)tcp_ptr__; \ + (__pcpu_typeof(*(_ptr)) __kernel __force *)tcp_ptr__; \ })#else -#define arch_raw_cpu_ptr (_ptr) ({ BUILD_BUG(); (typeof(_ptr))0; }) +#define arch_raw_cpu_ptr (_ptr) \ +({ \ + BUILD_BUG(); \ + (__pcpu_typeof(*(_ptr)) __kernel __force *)0; \ +})#endif #define PER_CPU_VAR (var) %__percpu_seg:(var)__percpu_rel
@@ -172,7 +176,7 @@ do { \ : [val] __pcpu_reg_##size("=", pfo_val__) \ : [var] "m" (__my_cpu_var(_var))); \ \ - (typeof(_var))(unsigned long) pfo_val__; \ + (__pcpu_typeof(_var))(unsigned long) pfo_val__; \ })#define __raw_cpu_write (size, qual, _var, _val) \
@@ -180,7 +184,7 @@ do { \ __pcpu_type_##size pto_val__ = __pcpu_cast_##size(_val); \ \ if (0) { \ - typeof(_var) pto_tmp__; \ + __pcpu_typeof(_var) pto_tmp__; \ pto_tmp__ = (_val); \ (void)pto_tmp__; \ } \
@@ -193,7 +197,11 @@ do { \* The generic per-CPU infrastrucutre is not suitable for * reading const-qualified variables. */ -#define __raw_cpu_read_const (pcp) ({ BUILD_BUG(); (typeof(pcp))0; }) +#define __raw_cpu_read_const (pcp) \ +({ \ + BUILD_BUG(); \ + (__pcpu_typeof(pcp))0; \ +})#endif /* CONFIG_USE_X86_SEG_SUPPORT */
@@ -205,7 +213,7 @@ do { \ : [val] __pcpu_reg_##size("=", pfo_val__) \ : [var] "i" (&(_var))); \ \ - (typeof(_var))(unsigned long) pfo_val__; \ + (__pcpu_typeof(_var))(unsigned long) pfo_val__; \ })#define percpu_unary_op (size, qual, op, _var) \
@@ -219,7 +227,7 @@ do { \ __pcpu_type_##size pto_val__ = __pcpu_cast_##size(_val); \ \ if (0) { \ - typeof(_var) pto_tmp__; \ + __pcpu_typeof(_var) pto_tmp__; \ pto_tmp__ = (_val); \ (void)pto_tmp__; \ } \
@@ -239,7 +247,7 @@ do { \ (int)(val) : 0; \ \if (0 ) { \ -typeof (var) pao_tmp__; \ +__pcpu_typeof (var) pao_tmp__; \ pao_tmp__ = (val); \ (void )pao_tmp__; \ } \
@@ -263,7 +271,7 @@ do { \ : [tmp] __pcpu_reg_##size("+", paro_tmp__), \ [var] "+m" (__my_cpu_var(_var)) \ : : "memory"); \ - (typeof(_var))(unsigned long) (paro_tmp__ + _val); \ + (__pcpu_typeof(_var))(unsigned long) (paro_tmp__ + _val); \ })/*
@@ -272,7 +280,7 @@ do { \*/ #define raw_percpu_xchg_op (_var, _nval) \ ({ \ - typeof(_var) pxo_old__ = raw_cpu_read(_var); \ + __pcpu_typeof(_var) pxo_old__ = raw_cpu_read(_var); \ \ raw_cpu_write(_var, _nval); \ \
@@ -286,7 +294,7 @@ do { \*/ #define this_percpu_xchg_op (_var, _nval) \ ({ \ - typeof(_var) pxo_old__ = this_cpu_read(_var); \ + __pcpu_typeof(_var) pxo_old__ = this_cpu_read(_var); \ \ do { } while (!this_cpu_try_cmpxchg(_var, &pxo_old__, _nval)); \ \
@@ -309,7 +317,7 @@ do { \ : [nval] __pcpu_reg_##size(, pco_new__) \ : "memory"); \ \ - (typeof(_var))(unsigned long) pco_old__; \ + (__pcpu_typeof(_var))(unsigned long) pco_old__; \ })#define percpu_try_cmpxchg_op (size, qual, _var, _ovalp, _nval) \
@@ -568,7 +576,11 @@ do { \#else /* !CONFIG_X86_64: */ /* There is no generic 64-bit read stable operation for 32-bit targets. */ -#define this_cpu_read_stable_8 (pcp) ({ BUILD_BUG(); (typeof(pcp))0; }) +#define this_cpu_read_stable_8 (pcp) \ +({ \ + BUILD_BUG(); \ + (__pcpu_typeof(pcp))0; \ +})#define raw_cpu_read_long (pcp) raw_cpu_read_4(pcp)
include/linux/part_stat.h +1 -1
@@ -33,7 +33,7 @@ struct disk_stats {#define part_stat_read (part, field) \ ({ \ - typeof((part)->bd_stats->field) res = 0; \ + __pcpu_typeof((part)->bd_stats->field) res = 0; \ unsigned int _cpu; \ for_each_possible_cpu(_cpu) \ res += per_cpu_ptr((part)->bd_stats, _cpu)->field; \
include/linux/percpu-defs.h +32 -7
@@ -220,6 +220,21 @@ do { \ (void )__vpp_verify; \ }while (0 ) +/* +* Define __percpu_typeof() to use __typeof_unqual__() as typeof +* operator when available, to return unqualified type of the exp. +* +* If an arch defines __percpu variables in their own named address +* space, then __pcpu_typeof() returns unqualified type of the +* expression without named address space qualifier when +* CONFIG_CC_HAS_TYPEOF_UNQUAL is defined. + */ +#ifdef CONFIG_CC_HAS_TYPEOF_UNQUAL +#define __pcpu_typeof (exp) __typeof_unqual__(exp) +#else +#define __pcpu_typeof (exp) __typeof__(exp) +#endif +#ifdef CONFIG_SMP /*
@@ -228,7 +243,10 @@ do { \* pointer value. The weird cast keeps both GCC and sparse happy. */ #define SHIFT_PERCPU_PTR (__p, __offset) \ - RELOC_HIDE((typeof(*(__p)) __kernel __force *)(__p), (__offset)) + uintptr_t ptr__ = (__force uintptr_t)(__p); \ + \ + RELOC_HIDE((__pcpu_typeof(*(__p)) __kernel __force *)(ptr__), \ + (__offset))#define per_cpu_ptr (ptr, cpu) \ ({ \
@@ -254,13 +272,20 @@ do { \#else /* CONFIG_SMP */ -#define VERIFY_PERCPU_PTR (__p) \ +#define PERCPU_PTR (__p) \ ({ \ - __verify_pcpu_ptr(__p); \ - (typeof(*(__p)) __kernel __force *)(__p); \ + uintptr_t ptr__ = (__force uintptr_t)(__p); \ + \ + (__pcpu_typeof(*(__p)) __kernel __force *)(ptr__); \ +}) + +#define per_cpu_ptr (ptr, cpu) \ +({ \ + __verify_pcpu_ptr(ptr); \ + (void)(cpu); \ + PERCPU_PTR(ptr); \ }) -#define per_cpu_ptr (ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); })#define raw_cpu_ptr (ptr) per_cpu_ptr(ptr, 0)#define this_cpu_ptr (ptr) raw_cpu_ptr(ptr)
@@ -315,7 +340,7 @@ static __always_inline void __this_cpu_preempt_check(const char *op) { }#define __pcpu_size_call_return (stem, variable) \ ({ \ - typeof(variable) pscr_ret__; \ + __pcpu_typeof(variable) pscr_ret__; \ __verify_pcpu_ptr(&(variable)); \ switch(sizeof(variable)) { \ case 1: pscr_ret__ = stem##1(variable); break; \
@@ -330,7 +355,7 @@ static __always_inline void __this_cpu_preempt_check(const char *op) { }#define __pcpu_size_call_return2 (stem, variable, ...) \ ({ \ - typeof(variable) pscr2_ret__; \ + __pcpu_typeof(variable) pscr2_ret__; \ __verify_pcpu_ptr(&(variable)); \ switch(sizeof(variable)) { \ case 1: pscr2_ret__ = stem##1(variable, __VA_ARGS__); break; \
init/Kconfig +3 -0
@@ -873,6 +873,9 @@ config ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH config CC_HAS_INT128 def_bool !$(cc-option,$(m64-flag) -D__SIZEOF_INT128__=0) && 64BIT +config CC_HAS_TYPEOF_UNQUAL + def_bool $(success,echo 'int foo (int a) { __typeof_unqual__(a) b = a; return b; }' | $(CC) -x c - -S -o /dev/null) + config CC_IMPLICIT_FALLTHROUGH string default "-Wimplicit-fallthrough=5" if CC_IS_GCC && $(cc-option,-Wimplicit-fallthrough=5)
kernel/locking/percpu-rwsem.c +1 -1
@@ -184,7 +184,7 @@ EXPORT_SYMBOL_GPL(__percpu_down_read);#define per_cpu_sum (var) \ ({ \ - typeof(var) __sum = 0; \ + __pcpu_typeof(var) __sum = 0; \ int cpu; \ compiletime_assert_atomic_type(__sum); \ for_each_possible_cpu(cpu) \
Signature · 1 line
2.45.2
RFC PATCH 2/3 percpu: Assorted fixes found by strict percpu address space checks
In reply to Uros BizjakAssorted fixes to prevent defconfig build failures when strict percpu address space checks will be enabled.
These show effeciveness of strict percpu address space checks.
--- arch/x86/kernel/head64.c | 3 ++- drivers/base/devres.c | 2 +- fs/aio.c | 2 +- include/linux/cleanup.h | 4 ++-- include/linux/prandom.h | 1 + kernel/events/hw_breakpoint.c | 4 ++-- kernel/workqueue.c | 2 +- lib/percpu_counter.c | 2 +- net/core/dev.c | 2 +- 9 files changed, 12 insertions(+), 10 deletions(-)
arch/x86/kernel/head64.c +2 -1
@@ -560,9 +560,10 @@ void early_setup_idt(void) void __head startup_64_setup_gdt_idt(void) {void *handler =NULL ; +struct desc_struct *gdt = (struct desc_struct *)(uintptr_t )init_per_cpu_var (gdt_page.gdt);struct desc_ptr startup_gdt_descr = { - .address = (unsigned long )&RIP_REL_REF (init_per_cpu_var (gdt_page.gdt)), + .address = (unsigned long )&RIP_REL_REF (*gdt), .size =GDT_SIZE -1 , };
drivers/base/devres.c +1 -1
@@ -1231,6 +1231,6 @@ void devm_free_percpu(struct device *dev, void __percpu *pdata)* devm_free_pages() does. */ WARN_ON (devres_release (dev, devm_percpu_release, devm_percpu_match, - (__force void *)pdata)); + (__force void *)(uintptr_t )pdata)); }EXPORT_SYMBOL_GPL (devm_free_percpu);
fs/aio.c +1 -1
@@ -100,7 +100,7 @@ struct kioctx {unsigned long user_id; -struct __percpu kioctx_cpu *cpu; +struct kioctx_cpu __percpu *cpu;/* * For percpu reqs_available, number of slots we move to/from global
include/linux/cleanup.h +2 -2
@@ -154,7 +154,7 @@ static inline class_##_name##_t class_##_name##ext##_constructor(_init_args) \#define DEFINE_GUARD (_name, _type, _lock, _unlock) \ DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \ static inline void * class_##_name##_lock_ptr(class_##_name##_t *_T) \ - { return *_T; } + { return (void *)(uintptr_t)*_T; }#define DEFINE_GUARD_COND (_name, _ext, _condlock) \ EXTEND_CLASS(_name, _ext, \
@@ -211,7 +211,7 @@ static inline void class_##_name##_destructor(class_##_name##_t *_T) \ \ static inline void *class_##_name##_lock_ptr(class_##_name##_t *_T) \ { \ -return _T->lock; \ +return (void *)(uintptr_t )_T->lock; \ }
include/linux/prandom.h +1 -0
@@ -10,6 +10,7 @@#include <linux/types.h> #include <linux/once.h> +#include <linux/percpu.h> #include <linux/random.h> struct rnd_state {
kernel/events/hw_breakpoint.c +2 -2
@@ -849,7 +849,7 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr, cpu_events =alloc_percpu (typeof (*cpu_events));if (!cpu_events) -return (void __percpu __force *)ERR_PTR (-ENOMEM ); +return (void __percpu __force *)(uintptr_t )ERR_PTR (-ENOMEM );cpus_read_lock ();for_each_online_cpu (cpu) {
@@ -868,7 +868,7 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr,return cpu_events;unregister_wide_hw_breakpoint (cpu_events); -return (void __percpu __force *)ERR_PTR (err); +return (void __percpu __force *)(uintptr_t )ERR_PTR (err); }EXPORT_SYMBOL_GPL (register_wide_hw_breakpoint);
kernel/workqueue.c +1 -1
@@ -377,7 +377,7 @@ struct workqueue_struct {/* hot fields used during command issue, aligned to cacheline */ unsigned int flags____cacheline_aligned ;/* WQ: WQ_* flags */ -struct pool_workqueue __percpu __rcu **cpu_pwq;/* I: per-cpu pwqs */ +struct pool_workqueue __rcu *__percpu *cpu_pwq;/* I: per-cpu pwqs */ struct wq_node_nr_active *node_nr_active[];/* I: per-node nr_active */ };
lib/percpu_counter.c +1 -1
@@ -209,7 +209,7 @@ int __percpu_counter_init_many(struct percpu_counter *fbc, s64 amount,INIT_LIST_HEAD (&fbc[i].list);#endif fbc[i].count = amount; - fbc[i].counters = (void *)counters + (i * counter_size); + fbc[i].counters = (void __percpu *)counters + (i * counter_size);debug_percpu_counter_activate (&fbc[i]); }
net/core/dev.c +1 -1
@@ -10860,7 +10860,7 @@ noinline void netdev_core_stats_inc(struct net_device *dev, u32 offset)return ; } - field = (__force unsigned long __percpu *)((__force void *)p + offset); + field = (unsigned long __percpu *)(void __percpu *)(p + offset);this_cpu_inc (*field); }EXPORT_SYMBOL_GPL (netdev_core_stats_inc);
Signature · 1 line
2.45.2
RFC PATCH 3/3 percpu/x86: [RFH] Enable strict percpu checks via named AS qualifiers
In reply to Uros BizjakThis patch declares percpu variables in __seg_gs/__seg_fs named AS and keeps them named AS qualified until they are dereferenced with percpu accessor. This approach enables various compiler check for corss-namespace variable assignments.
RFH: The patch hijacks __percpu tag and repurposes it as a named address space qualifier. While this works surprisingly well in this RFC patchset, I would really appreciate some help on how to rewrite this hack into some "production ready" code.
--- arch/x86/include/asm/percpu.h | 15 ++++++++++++--- include/linux/compiler_types.h | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-)
arch/x86/include/asm/percpu.h +12 -3
@@ -95,9 +95,18 @@#endif /* CONFIG_SMP */ -#define __my_cpu_type (var) typeof(var) __percpu_seg_override -#define __my_cpu_ptr (ptr) (__my_cpu_type(*(ptr))*)(__force uintptr_t)(ptr) -#define __my_cpu_var (var) (*__my_cpu_ptr(&(var))) +#if defined(CONFIG_USE_X86_SEG_SUPPORT ) && defined(CONFIG_CC_HAS_TYPEOF_UNQUAL ) +# define __my_cpu_type (var) typeof(var) +# define __my_cpu_ptr (ptr) (ptr) +# define __my_cpu_var (var) (var) +# define __percpu_qual __percpu_seg_override +#else +# define __my_cpu_type (var) typeof(var) __percpu_seg_override +# define __my_cpu_ptr (ptr) (__my_cpu_type(*(ptr))*)(__force uintptr_t)(ptr) +# define __my_cpu_var (var) (*__my_cpu_ptr(&(var))) +# define __percpu_qual +#endif +#define __percpu_arg (x) __percpu_prefix "%" #x#define __force_percpu_arg (x) __force_percpu_prefix "%" #x
include/linux/compiler_types.h +1 -1
@@ -57,7 +57,7 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }# define __user BTF_TYPE_TAG(user)# endif # define __iomem -# define __percpu BTF_TYPE_TAG(percpu) +# define __percpu __percpu_qual BTF_TYPE_TAG(percpu)# define __rcu BTF_TYPE_TAG(rcu)# define __chk_user_ptr (x) (void)0
Signature · 1 line
2.45.2
kernel test robot
build botRe: [RFC PATCH 3/3] percpu/x86: [RFH] Enable strict percpu checks via named AS qualifiers
kernel test robot noticed the following build errors:
Hi Uros,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on driver-core/driver-core-next driver-core/driver-core-linus perf-tools-next/perf-tools-next tip/perf/core perf-tools/perf-tools tj-wq/for-next linus/master v6.11-rc2 next-20240806] [cannot apply to tip/locking/core tip/x86/core dennis-percpu/for-next acme/perf/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Uros-Bizjak/percpu-Define-__pcpu_typeof/20240806-024253 base: driver-core/driver-core-testing patch link: https://lore.kernel.org/r/20240805184012.358023-4-ubizjak%40gmail.com patch subject: [RFC PATCH 3/3] percpu/x86: [RFH] Enable strict percpu checks via named AS qualifiers config: openrisc-allnoconfig (https://download.01.org/0day-ci/archive/20240807/[email protected]/config) compiler: or1k-linux-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240807/[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 include/linux/percpu.h:5,
from include/linux/percpu_counter.h:14, from include/linux/sched/user.h:7, from include/linux/cred.h:18, from include/linux/sched/signal.h:10, from include/linux/ptrace.h:7, from arch/openrisc/kernel/asm-offsets.c:28:
>> include/linux/alloc_tag.h:30:49: error: expected ':', ',', ';', '}' or '__attribute__' before '*' token
30 | struct alloc_tag_counters __percpu *counters;
| ^
>> include/linux/percpu.h:136:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
136 | extern void __percpu *pcpu_alloc_noprof(size_t size, size_t align, bool reserved,
| ^
>> include/linux/percpu.h:138:45: error: expected ';', ',' or ')' before '*' token
138 | extern size_t pcpu_alloc_size(void __percpu *__pdata);
| ^
include/linux/percpu.h:157:39: error: expected ';', ',' or ')' before '*' token
157 | extern void free_percpu(void __percpu *__pdata);
| ^
In file included from include/linux/irqflags.h:17,
from arch/openrisc/include/asm/bitops.h:24,
from include/linux/bitops.h:68,
from include/linux/signal.h:61,
from arch/openrisc/kernel/asm-offsets.c:22:
include/linux/percpu.h: In function '__free_free_percpu':
include/linux/percpu.h:159:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T))
| ^
include/linux/cleanup.h:62:54: note: in definition of macro 'DEFINE_FREE'
62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; }
| ^~~~~
>> include/linux/cleanup.h:62:60: error: '_T' undeclared (first use in this function)
62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; }
| ^~
include/linux/percpu.h:159:1: note: in expansion of macro 'DEFINE_FREE'
159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T))
| ^~~~~~~~~~~
include/linux/cleanup.h:62:60: note: each undeclared identifier is reported only once for each function it appears in
62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; }
| ^~
include/linux/percpu.h:159:1: note: in expansion of macro 'DEFINE_FREE'
159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T))
| ^~~~~~~~~~~
>> include/linux/compiler_types.h:60:25: error: expected ')' before '__percpu_qual'
60 | # define __percpu __percpu_qual BTF_TYPE_TAG(percpu)
| ^~~~~~~~~~~~~
include/linux/cleanup.h:62:67: note: in definition of macro 'DEFINE_FREE'
62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; }
| ^~~~~
include/linux/percpu.h:159:31: note: in expansion of macro '__percpu'
159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T))
| ^~~~~~~~
include/linux/cleanup.h:62:66: note: to match this '('
62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; }
| ^
include/linux/percpu.h:159:1: note: in expansion of macro 'DEFINE_FREE'
159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T))
| ^~~~~~~~~~~
>> include/linux/cleanup.h:62:66: error: void value not ignored as it ought to be
62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; }
| ^~~~~~~~~~
include/linux/percpu.h:159:1: note: in expansion of macro 'DEFINE_FREE'
159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T))
| ^~~~~~~~~~~
>> include/linux/percpu.h:159:43: error: implicit declaration of function 'free_percpu'; did you mean 'kfree_rcu'? [-Wimplicit-function-declaration]
159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T))
| ^~~~~~~~~~~
include/linux/cleanup.h:62:78: note: in definition of macro 'DEFINE_FREE'
62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; }
| ^~~~~
In file included from <command-line>:
include/linux/hrtimer.h: At top level:
>> include/linux/compiler_types.h:60:25: error: type defaults to 'int' in declaration of '__percpu_qual' [-Wimplicit-int]
60 | # define __percpu __percpu_qual BTF_TYPE_TAG(percpu)
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:50:9: note: in expansion of macro '__percpu'
50 | __percpu __attribute__((section(PER_CPU_BASE_SECTION sec))) \
| ^~~~~~~~
include/linux/percpu-defs.h:101:16: note: in expansion of macro '__PCPU_ATTRS'
101 | extern __PCPU_ATTRS(sec) __typeof__(type) name
| ^~~~~~~~~~~~
include/linux/percpu-defs.h:112:9: note: in expansion of macro 'DECLARE_PER_CPU_SECTION'
112 | DECLARE_PER_CPU_SECTION(type, name, "")
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/hrtimer.h:215:1: note: in expansion of macro 'DECLARE_PER_CPU'
215 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
| ^~~~~~~~~~~~~~~
In file included from include/asm-generic/percpu.h:7,
from ./arch/openrisc/include/generated/asm/percpu.h:1,
from include/linux/irqflags.h:19:
>> include/linux/percpu-defs.h:101:34: error: expected ',' or ';' before '__typeof__'
101 | extern __PCPU_ATTRS(sec) __typeof__(type) name
| ^~~~~~~~~~
include/linux/percpu-defs.h:112:9: note: in expansion of macro 'DECLARE_PER_CPU_SECTION'
112 | DECLARE_PER_CPU_SECTION(type, name, "")
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/hrtimer.h:215:1: note: in expansion of macro 'DECLARE_PER_CPU'
215 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
| ^~~~~~~~~~~~~~~
In file included from include/linux/random.h:153,
from include/linux/nodemask.h:98,
from include/linux/mmzone.h:18,
from include/linux/gfp.h:7,
from include/linux/mm.h:7,
from include/linux/pid_namespace.h:7,
from include/linux/ptrace.h:10:
>> include/linux/prandom.h:22:56: error: expected ';', ',' or ')' before '*' token
22 | void prandom_seed_full_state(struct rnd_state __percpu *pcpu_state);
| ^
>> include/linux/local_lock.h:54:47: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
54 | DEFINE_GUARD(local_lock, local_lock_t __percpu*,
| ^
include/linux/cleanup.h:108:9: note: in definition of macro 'DEFINE_CLASS'
108 | typedef _type class_##_name##_t; \
| ^~~~~
include/linux/local_lock.h:54:1: note: in expansion of macro 'DEFINE_GUARD'
54 | DEFINE_GUARD(local_lock, local_lock_t __percpu*,
| ^~~~~~~~~~~~
>> include/linux/local_lock.h:54:47: error: expected ';', ',' or ')' before '*' token
54 | DEFINE_GUARD(local_lock, local_lock_t __percpu*,
| ^
include/linux/cleanup.h:109:47: note: in definition of macro 'DEFINE_CLASS'
109 | static inline void class_##_name##_destructor(_type *p) \
| ^~~~~
include/linux/local_lock.h:54:1: note: in expansion of macro 'DEFINE_GUARD'
54 | DEFINE_GUARD(local_lock, local_lock_t __percpu*,
| ^~~~~~~~~~~~
>> include/linux/local_lock.h:54:47: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
54 | DEFINE_GUARD(local_lock, local_lock_t __percpu*,
| ^
include/linux/cleanup.h:111:15: note: in definition of macro 'DEFINE_CLASS'
111 | static inline _type class_##_name##_constructor(_init_args) \
| ^~~~~
include/linux/local_lock.h:54:1: note: in expansion of macro 'DEFINE_GUARD'
54 | DEFINE_GUARD(local_lock, local_lock_t __percpu*,
| ^~~~~~~~~~~~
>> include/linux/cleanup.h:156:55: error: unknown type name 'class_local_lock_t'; did you mean 'class_read_lock_t'?
156 | static inline void * class_##_name##_lock_ptr(class_##_name##_t *_T) \
| ^~~~~~
include/linux/local_lock.h:54:1: note: in expansion of macro 'DEFINE_GUARD'
54 | DEFINE_GUARD(local_lock, local_lock_t __percpu*,
| ^~~~~~~~~~~~
include/linux/local_lock.h:57:51: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
57 | DEFINE_GUARD(local_lock_irq, local_lock_t __percpu*,
| ^
include/linux/cleanup.h:108:9: note: in definition of macro 'DEFINE_CLASS'
108 | typedef _type class_##_name##_t; \
| ^~~~~
include/linux/local_lock.h:57:1: note: in expansion of macro 'DEFINE_GUARD'
57 | DEFINE_GUARD(local_lock_irq, local_lock_t __percpu*,
| ^~~~~~~~~~~~
include/linux/local_lock.h:57:51: error: expected ';', ',' or ')' before '*' token
57 | DEFINE_GUARD(local_lock_irq, local_lock_t __percpu*,
| ^
include/linux/cleanup.h:109:47: note: in definition of macro 'DEFINE_CLASS'
109 | static inline void class_##_name##_destructor(_type *p) \
| ^~~~~
include/linux/local_lock.h:57:1: note: in expansion of macro 'DEFINE_GUARD'
57 | DEFINE_GUARD(local_lock_irq, local_lock_t __percpu*,
| ^~~~~~~~~~~~
include/linux/local_lock.h:57:51: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
57 | DEFINE_GUARD(local_lock_irq, local_lock_t __percpu*,
| ^
include/linux/cleanup.h:111:15: note: in definition of macro 'DEFINE_CLASS'
111 | static inline _type class_##_name##_constructor(_init_args) \
| ^~~~~
include/linux/local_lock.h:57:1: note: in expansion of macro 'DEFINE_GUARD'
57 | DEFINE_GUARD(local_lock_irq, local_lock_t __percpu*,
| ^~~~~~~~~~~~
>> include/linux/cleanup.h:156:55: error: unknown type name 'class_local_lock_irq_t'; did you mean 'class_read_lock_irq_t'?
156 | static inline void * class_##_name##_lock_ptr(class_##_name##_t *_T) \
| ^~~~~~
include/linux/local_lock.h:57:1: note: in expansion of macro 'DEFINE_GUARD'
57 | DEFINE_GUARD(local_lock_irq, local_lock_t __percpu*,
| ^~~~~~~~~~~~
>> include/linux/cleanup.h:203:15: error: expected ':', ',', ';', '}' or '__attribute__' before '*' token
203 | _type *lock; \
| ^
include/linux/cleanup.h:236:1: note: in expansion of macro '__DEFINE_UNLOCK_GUARD'
236 | __DEFINE_UNLOCK_GUARD(_name, _type, _unlock, __VA_ARGS__) \
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1'
60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu,
| ^~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h: In function 'class_local_lock_irqsave_destructor':
>> include/linux/cleanup.h:209:15: error: 'class_local_lock_irqsave_t' has no member named 'lock'
209 | if (_T->lock) { _unlock; } \
| ^~
include/linux/cleanup.h:236:1: note: in expansion of macro '__DEFINE_UNLOCK_GUARD'
236 | __DEFINE_UNLOCK_GUARD(_name, _type, _unlock, __VA_ARGS__) \
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1'
60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu,
| ^~~~~~~~~~~~~~~~~~~
>> include/linux/percpu-defs.h:219:29: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
219 | const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \
| ^
include/linux/cleanup.h:209:25: note: in definition of macro '__DEFINE_UNLOCK_GUARD'
209 | if (_T->lock) { _unlock; } \
| ^~~~~~~
include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1'
60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu,
| ^~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:284:9: note: in expansion of macro '__verify_pcpu_ptr'
284 | __verify_pcpu_ptr(ptr); \
| ^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:289:33: note: in expansion of macro 'per_cpu_ptr'
289 | #define raw_cpu_ptr(ptr) per_cpu_ptr(ptr, 0)
| ^~~~~~~~~~~
include/linux/percpu-defs.h:290:33: note: in expansion of macro 'raw_cpu_ptr'
290 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
| ^~~~~~~~~~~
include/linux/local_lock_internal.h:108:36: note: in expansion of macro 'this_cpu_ptr'
108 | local_lock_release(this_cpu_ptr(lock)); \
| ^~~~~~~~~~~~
include/linux/local_lock.h:52:9: note: in expansion of macro '__local_unlock_irqrestore'
52 | __local_unlock_irqrestore(lock, flags)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h:62:21: note: in expansion of macro 'local_unlock_irqrestore'
62 | local_unlock_irqrestore(_T->lock, _T->flags),
| ^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/percpu-defs.h:219:30: error: '__vpp_verify' undeclared (first use in this function)
219 | const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \
| ^~~~~~~~~~~~
include/linux/cleanup.h:209:25: note: in definition of macro '__DEFINE_UNLOCK_GUARD'
209 | if (_T->lock) { _unlock; } \
| ^~~~~~~
include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1'
60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu,
| ^~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:284:9: note: in expansion of macro '__verify_pcpu_ptr'
284 | __verify_pcpu_ptr(ptr); \
| ^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:289:33: note: in expansion of macro 'per_cpu_ptr'
289 | #define raw_cpu_ptr(ptr) per_cpu_ptr(ptr, 0)
| ^~~~~~~~~~~
include/linux/percpu-defs.h:290:33: note: in expansion of macro 'raw_cpu_ptr'
290 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
| ^~~~~~~~~~~
include/linux/local_lock_internal.h:108:36: note: in expansion of macro 'this_cpu_ptr'
108 | local_lock_release(this_cpu_ptr(lock)); \
| ^~~~~~~~~~~~
include/linux/local_lock.h:52:9: note: in expansion of macro '__local_unlock_irqrestore'
52 | __local_unlock_irqrestore(lock, flags)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h:62:21: note: in expansion of macro 'local_unlock_irqrestore'
62 | local_unlock_irqrestore(_T->lock, _T->flags),
| ^~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/local_lock.h:62:47: error: 'class_local_lock_irqsave_t' has no member named 'lock'
62 | local_unlock_irqrestore(_T->lock, _T->flags),
| ^~
include/linux/cleanup.h:209:25: note: in definition of macro '__DEFINE_UNLOCK_GUARD'
209 | if (_T->lock) { _unlock; } \
| ^~~~~~~
include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1'
60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu,
| ^~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:284:9: note: in expansion of macro '__verify_pcpu_ptr'
284 | __verify_pcpu_ptr(ptr); \
| ^~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:289:33: note: in expansion of macro 'per_cpu_ptr'
289 | #define raw_cpu_ptr(ptr) per_cpu_ptr(ptr, 0)
| ^~~~~~~~~~~
include/linux/percpu-defs.h:290:33: note: in expansion of macro 'raw_cpu_ptr'
290 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
| ^~~~~~~~~~~
include/linux/local_lock_internal.h:108:36: note: in expansion of macro 'this_cpu_ptr'
108 | local_lock_release(this_cpu_ptr(lock)); \
| ^~~~~~~~~~~~
include/linux/local_lock.h:52:9: note: in expansion of macro '__local_unlock_irqrestore'
52 | __local_unlock_irqrestore(lock, flags)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h:62:21: note: in expansion of macro 'local_unlock_irqrestore'
62 | local_unlock_irqrestore(_T->lock, _T->flags),
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h:62:47: error: 'class_local_lock_irqsave_t' has no member named 'lock'
62 | local_unlock_irqrestore(_T->lock, _T->flags),
| ^~
include/linux/cleanup.h:209:25: note: in definition of macro '__DEFINE_UNLOCK_GUARD'
209 | if (_T->lock) { _unlock; } \
| ^~~~~~~
include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1'
60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu,
| ^~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:286:9: note: in expansion of macro 'PERCPU_PTR'
286 | PERCPU_PTR(ptr); \
| ^~~~~~~~~~
include/linux/percpu-defs.h:289:33: note: in expansion of macro 'per_cpu_ptr'
289 | #define raw_cpu_ptr(ptr) per_cpu_ptr(ptr, 0)
| ^~~~~~~~~~~
include/linux/percpu-defs.h:290:33: note: in expansion of macro 'raw_cpu_ptr'
290 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
| ^~~~~~~~~~~
include/linux/local_lock_internal.h:108:36: note: in expansion of macro 'this_cpu_ptr'
108 | local_lock_release(this_cpu_ptr(lock)); \
| ^~~~~~~~~~~~
include/linux/local_lock.h:52:9: note: in expansion of macro '__local_unlock_irqrestore'
52 | __local_unlock_irqrestore(lock, flags)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h:62:21: note: in expansion of macro 'local_unlock_irqrestore'
62 | local_unlock_irqrestore(_T->lock, _T->flags),
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h:62:47: error: 'class_local_lock_irqsave_t' has no member named 'lock'
62 | local_unlock_irqrestore(_T->lock, _T->flags),
| ^~
include/linux/cleanup.h:209:25: note: in definition of macro '__DEFINE_UNLOCK_GUARD'
209 | if (_T->lock) { _unlock; } \
| ^~~~~~~
include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1'
60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu,
| ^~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:279:10: note: in expansion of macro '__pcpu_typeof'
279 | (__pcpu_typeof(*(__p)) __kernel __force *)(ptr__); \
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:286:9: note: in expansion of macro 'PERCPU_PTR'
286 | PERCPU_PTR(ptr); \
| ^~~~~~~~~~
include/linux/percpu-defs.h:289:33: note: in expansion of macro 'per_cpu_ptr'
289 | #define raw_cpu_ptr(ptr) per_cpu_ptr(ptr, 0)
| ^~~~~~~~~~~
include/linux/percpu-defs.h:290:33: note: in expansion of macro 'raw_cpu_ptr'
290 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
| ^~~~~~~~~~~
include/linux/local_lock_internal.h:108:36: note: in expansion of macro 'this_cpu_ptr'
108 | local_lock_release(this_cpu_ptr(lock)); \
| ^~~~~~~~~~~~
include/linux/local_lock.h:52:9: note: in expansion of macro '__local_unlock_irqrestore'
52 | __local_unlock_irqrestore(lock, flags)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h:62:21: note: in expansion of macro 'local_unlock_irqrestore'
62 | local_unlock_irqrestore(_T->lock, _T->flags),
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h:62:57: error: 'class_local_lock_irqsave_t' has no member named 'flags'
62 | local_unlock_irqrestore(_T->lock, _T->flags),
| ^~
include/linux/cleanup.h:209:25: note: in definition of macro '__DEFINE_UNLOCK_GUARD'
209 | if (_T->lock) { _unlock; } \
| ^~~~~~~
include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1'
60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu,
| ^~~~~~~~~~~~~~~~~~~
include/linux/irqflags.h:171:17: note: in expansion of macro 'typecheck'
171 | typecheck(unsigned long, flags); \
| ^~~~~~~~~
include/linux/irqflags.h:234:39: note: in expansion of macro 'raw_local_irq_restore'
234 | #define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0)
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/local_lock_internal.h:109:17: note: in expansion of macro 'local_irq_restore'
109 | local_irq_restore(flags); \vim +136 include/linux/percpu.h
e74e396204bfcb Tejun Heo 2009-03-30 135
24e44cc22aa311 Suren Baghdasaryan 2024-03-21 @136 extern void __percpu *pcpu_alloc_noprof(size_t size, size_t align, bool reserved, 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 137 gfp_t gfp) __alloc_size(1); b460bc8302f222 Hou Tao 2023-10-20 @138 extern size_t pcpu_alloc_size(void __percpu *__pdata); 54da6a0924311c Peter Zijlstra 2023-05-26 139 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 140 #define __alloc_percpu_gfp(_size, _align, _gfp) \ 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 141 alloc_hooks(pcpu_alloc_noprof(_size, _align, false, _gfp)) 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 142 #define __alloc_percpu(_size, _align) \ 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 143 alloc_hooks(pcpu_alloc_noprof(_size, _align, false, GFP_KERNEL)) 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 144 #define __alloc_reserved_percpu(_size, _align) \ 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 145 alloc_hooks(pcpu_alloc_noprof(_size, _align, true, GFP_KERNEL)) de380b55f92986 Tejun Heo 2010-03-24 146 5835d96e9ce4ef Tejun Heo 2014-09-02 147 #define alloc_percpu_gfp(type, gfp) \ 5835d96e9ce4ef Tejun Heo 2014-09-02 148 (typeof(type) __percpu *)__alloc_percpu_gfp(sizeof(type), \ 5835d96e9ce4ef Tejun Heo 2014-09-02 149 __alignof__(type), gfp) 64ef291f46d795 Tejun Heo 2009-10-29 150 #define alloc_percpu(type) \ 5835d96e9ce4ef Tejun Heo 2014-09-02 151 (typeof(type) __percpu *)__alloc_percpu(sizeof(type), \ 5835d96e9ce4ef Tejun Heo 2014-09-02 152 __alignof__(type)) 2c321f3f70bc28 Suren Baghdasaryan 2024-04-14 153 #define alloc_percpu_noprof(type) \ 2c321f3f70bc28 Suren Baghdasaryan 2024-04-14 154 ((typeof(type) __percpu *)pcpu_alloc_noprof(sizeof(type), \ 2c321f3f70bc28 Suren Baghdasaryan 2024-04-14 155 __alignof__(type), false, GFP_KERNEL)) ^1da177e4c3f41 Linus Torvalds 2005-04-16 156 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 157 extern void free_percpu(void __percpu *__pdata); 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 158
24e44cc22aa311 Suren Baghdasaryan 2024-03-21 @159 DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T)) 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 160
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [RFC PATCH 3/3] percpu/x86: [RFH] Enable strict percpu checks via named AS qualifiers
Quoted 21 lines · kernel test robot
Hi Uros,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on driver-core/driver-core-testing]
[also build test ERROR on driver-core/driver-core-next driver-core/driver-core-linus perf-tools-next/perf-tools-next tip/perf/core perf-tools/perf-tools tj-wq/for-next linus/master v6.11-rc2 next-20240806] [cannot apply to tip/locking/core tip/x86/core dennis-percpu/for-next acme/perf/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Uros-Bizjak/percpu-Define-__pcpu_typeof/20240806-024253 base: driver-core/driver-core-testing patch link: https://lore.kernel.org/r/20240805184012.358023-4-ubizjak%40gmail.com patch subject: [RFC PATCH 3/3] percpu/x86: [RFH] Enable strict percpu checks via named AS qualifiers config: openrisc-allnoconfig (https://download.01.org/0day-ci/archive/20240807/[email protected]/config) compiler: or1k-linux-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240807/[email protected]/reproduce)
Quoted 6 lines
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 >>):
Dear LKP team,
yes, the patch in this state of RFC will fail for non-x86 arches due to undefined __percpu_qual macro. Also, please note that the preceding [2/3] patch only fixes issues for defconfig x86_64 build, mainly to not clutter the [2/3] patch with even mode "assorted percpu fixes". OTOH, I have fixed a bunch of existing issues with x86_64 allyesconfig, uncovered by the patch (and posted relevant patches), to lower the number of build errors that are now triggered by the patch.
Please also note that a single missing cast can result in dozens of lines of errors/warnings. Just try to compile bcachefs that needs __percpu_typeof in its util.h ;) .
Thanks,
Uros.
Quoted 384 lines
In file included from
include/linux/percpu.h:5,
frominclude/linux/percpu_counter.h:14, frominclude/linux/sched/user.h:7, frominclude/linux/cred.h:18, frominclude/linux/sched/signal.h:10, frominclude/linux/ptrace.h:7, fromarch/openrisc/kernel/asm-offsets.c:28:Quoted 1 line
Quoted 1 line
include/linux/alloc_tag.h:30:49: error: expected ':', ',', ';', '}' or '__attribute__' before '*' token30 | struct alloc_tag_counters __percpu *counters; | ^Quoted 1 line
Quoted 1 line
include/linux/percpu.h:136:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token136 | extern void
__percpu*pcpu_alloc_noprof(size_t size,size_talign, bool reserved,
| ^Quoted 1 line
Quoted 1 line
include/linux/percpu.h:138:45: error: expected ';', ',' or ')' before '*' token138 | extern size_t pcpu_alloc_size(void __percpu *__pdata); | ^ include/linux/percpu.h:157:39: error: expected ';', ',' or ')' before '*' token 157 | extern void free_percpu(void __percpu *__pdata); | ^ In file included from include/linux/irqflags.h:17, from arch/openrisc/include/asm/bitops.h:24, from include/linux/bitops.h:68, from include/linux/signal.h:61, from arch/openrisc/kernel/asm-offsets.c:22: include/linux/percpu.h: In function '__free_free_percpu': include/linux/percpu.h:159:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token 159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T)) | ^ include/linux/cleanup.h:62:54: note: in definition of macro 'DEFINE_FREE' 62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; } | ^~~~~Quoted 1 line
Quoted 1 line
include/linux/cleanup.h:62:60: error: '_T' undeclared (first use in this function)62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; } | ^~ include/linux/percpu.h:159:1: note: in expansion of macro 'DEFINE_FREE' 159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T)) | ^~~~~~~~~~~ include/linux/cleanup.h:62:60: note: each undeclared identifier is reported only once for each function it appears in 62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; } | ^~ include/linux/percpu.h:159:1: note: in expansion of macro 'DEFINE_FREE' 159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T)) | ^~~~~~~~~~~Quoted 1 line
Quoted 1 line
include/linux/compiler_types.h:60:25: error: expected ')' before '__percpu_qual'60 | # define __percpu __percpu_qual BTF_TYPE_TAG(percpu) | ^~~~~~~~~~~~~ include/linux/cleanup.h:62:67: note: in definition of macro 'DEFINE_FREE' 62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; } | ^~~~~ include/linux/percpu.h:159:31: note: in expansion of macro '__percpu' 159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T)) | ^~~~~~~~ include/linux/cleanup.h:62:66: note: to match this '(' 62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; } | ^ include/linux/percpu.h:159:1: note: in expansion of macro 'DEFINE_FREE' 159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T)) | ^~~~~~~~~~~Quoted 1 line
Quoted 1 line
include/linux/cleanup.h:62:66: error: void value not ignored as it ought to be62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; } | ^~~~~~~~~~ include/linux/percpu.h:159:1: note: in expansion of macro 'DEFINE_FREE' 159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T)) | ^~~~~~~~~~~Quoted 1 line
Quoted 1 line
include/linux/percpu.h:159:43: error: implicit declaration of function 'free_percpu'; did you mean 'kfree_rcu'? [-Wimplicit-function-declaration]159 | DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T)) | ^~~~~~~~~~~ include/linux/cleanup.h:62:78: note: in definition of macro 'DEFINE_FREE' 62 | static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; } | ^~~~~In file included from <command-line>:
include/linux/hrtimer.h: At top level:Quoted 1 line
Quoted 1 line
include/linux/compiler_types.h:60:25: error: type defaults to 'int' in declaration of '__percpu_qual' [-Wimplicit-int]60 | # define __percpu __percpu_qual BTF_TYPE_TAG(percpu) | ^~~~~~~~~~~~~ include/linux/percpu-defs.h:50:9: note: in expansion of macro '__percpu' 50 | __percpu __attribute__((section(PER_CPU_BASE_SECTION sec))) \ | ^~~~~~~~ include/linux/percpu-defs.h:101:16: note: in expansion of macro '__PCPU_ATTRS' 101 | extern __PCPU_ATTRS(sec) __typeof__(type) name | ^~~~~~~~~~~~ include/linux/percpu-defs.h:112:9: note: in expansion of macro 'DECLARE_PER_CPU_SECTION' 112 | DECLARE_PER_CPU_SECTION(type, name, "") | ^~~~~~~~~~~~~~~~~~~~~~~ include/linux/hrtimer.h:215:1: note: in expansion of macro 'DECLARE_PER_CPU' 215 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device); | ^~~~~~~~~~~~~~~In file included from
include/asm-generic/percpu.h:7,
from./arch/openrisc/include/generated/asm/percpu.h:1, frominclude/linux/irqflags.h:19:Quoted 1 line
Quoted 1 line
include/linux/percpu-defs.h:101:34: error: expected ',' or ';' before '__typeof__'101 | extern
__PCPU_ATTRS(sec)__typeof__(type)name
| ^~~~~~~~~~
include/linux/percpu-defs.h:112:9: note: in expansion of macro 'DECLARE_PER_CPU_SECTION'112 | DECLARE_PER_CPU_SECTION(type, name, "") | ^~~~~~~~~~~~~~~~~~~~~~~ include/linux/hrtimer.h:215:1: note: in expansion of macro 'DECLARE_PER_CPU' 215 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device); | ^~~~~~~~~~~~~~~In file included from
include/linux/random.h:153,
frominclude/linux/nodemask.h:98, frominclude/linux/mmzone.h:18, frominclude/linux/gfp.h:7, frominclude/linux/mm.h:7, frominclude/linux/pid_namespace.h:7, frominclude/linux/ptrace.h:10:Quoted 1 line
Quoted 1 line
include/linux/prandom.h:22:56: error: expected ';', ',' or ')' before '*' token22 | void prandom_seed_full_state(struct rnd_state __percpu *pcpu_state); | ^Quoted 1 line
Quoted 1 line
include/linux/local_lock.h:54:47: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token54 | DEFINE_GUARD(local_lock,
local_lock_t__percpu*,
| ^
include/linux/cleanup.h:108:9: note: in definition of macro 'DEFINE_CLASS'108 | typedef _type class_##_name##_t; \ | ^~~~~
include/linux/local_lock.h:54:1: note: in expansion of macro 'DEFINE_GUARD'
54 | DEFINE_GUARD(local_lock,local_lock_t__percpu*,
| ^~~~~~~~~~~~Quoted 1 line
Quoted 1 line
include/linux/local_lock.h:54:47: error: expected ';', ',' or ')' before '*' token54 | DEFINE_GUARD(local_lock,
local_lock_t__percpu*,
| ^
include/linux/cleanup.h:109:47: note: in definition of macro 'DEFINE_CLASS'109 | static inline void class_##_name##_destructor(_type *p) \ | ^~~~~
include/linux/local_lock.h:54:1: note: in expansion of macro 'DEFINE_GUARD'
54 | DEFINE_GUARD(local_lock,local_lock_t__percpu*,
| ^~~~~~~~~~~~Quoted 1 line
Quoted 1 line
include/linux/local_lock.h:54:47: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token54 | DEFINE_GUARD(local_lock,
local_lock_t__percpu*,
| ^
include/linux/cleanup.h:111:15: note: in definition of macro 'DEFINE_CLASS'111 | static inline _type class_##_name##_constructor(_init_args) \ | ^~~~~
include/linux/local_lock.h:54:1: note: in expansion of macro 'DEFINE_GUARD'
54 | DEFINE_GUARD(local_lock,local_lock_t__percpu*,
| ^~~~~~~~~~~~Quoted 1 line
Quoted 1 line
include/linux/cleanup.h:156:55: error: unknown type name 'class_local_lock_t'; did you mean 'class_read_lock_t'?156 | static inline void * class_##_name##_lock_ptr(class_##_name##_t *_T) \ | ^~~~~~ include/linux/local_lock.h:54:1: note: in expansion of macro 'DEFINE_GUARD' 54 | DEFINE_GUARD(local_lock, local_lock_t __percpu*, | ^~~~~~~~~~~~ include/linux/local_lock.h:57:51: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token 57 | DEFINE_GUARD(local_lock_irq, local_lock_t __percpu*, | ^ include/linux/cleanup.h:108:9: note: in definition of macro 'DEFINE_CLASS' 108 | typedef _type class_##_name##_t; \ | ^~~~~ include/linux/local_lock.h:57:1: note: in expansion of macro 'DEFINE_GUARD' 57 | DEFINE_GUARD(local_lock_irq, local_lock_t __percpu*, | ^~~~~~~~~~~~ include/linux/local_lock.h:57:51: error: expected ';', ',' or ')' before '*' token 57 | DEFINE_GUARD(local_lock_irq, local_lock_t __percpu*, | ^ include/linux/cleanup.h:109:47: note: in definition of macro 'DEFINE_CLASS' 109 | static inline void class_##_name##_destructor(_type *p) \ | ^~~~~ include/linux/local_lock.h:57:1: note: in expansion of macro 'DEFINE_GUARD' 57 | DEFINE_GUARD(local_lock_irq, local_lock_t __percpu*, | ^~~~~~~~~~~~ include/linux/local_lock.h:57:51: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token 57 | DEFINE_GUARD(local_lock_irq, local_lock_t __percpu*, | ^ include/linux/cleanup.h:111:15: note: in definition of macro 'DEFINE_CLASS' 111 | static inline _type class_##_name##_constructor(_init_args) \ | ^~~~~
include/linux/local_lock.h:57:1: note: in expansion of macro 'DEFINE_GUARD'
57 | DEFINE_GUARD(local_lock_irq,local_lock_t__percpu*,
| ^~~~~~~~~~~~Quoted 1 line
Quoted 1 line
include/linux/cleanup.h:156:55: error: unknown type name 'class_local_lock_irq_t'; did you mean 'class_read_lock_irq_t'?156 | static inline void * class_##_name##_lock_ptr(class_##_name##_t *_T) \ | ^~~~~~
include/linux/local_lock.h:57:1: note: in expansion of macro 'DEFINE_GUARD'
57 | DEFINE_GUARD(local_lock_irq,local_lock_t__percpu*,
| ^~~~~~~~~~~~Quoted 1 line
Quoted 1 line
include/linux/cleanup.h:203:15: error: expected ':', ',', ';', '}' or '__attribute__' before '*' token203 | _type *lock; \ | ^ include/linux/cleanup.h:236:1: note: in expansion of macro '__DEFINE_UNLOCK_GUARD' 236 | __DEFINE_UNLOCK_GUARD(_name, _type, _unlock, __VA_ARGS__) \ | ^~~~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1'
60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave,local_lock_t__percpu,
| ^~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h: In function 'class_local_lock_irqsave_destructor':Quoted 1 line
Quoted 1 line
include/linux/cleanup.h:209:15: error: 'class_local_lock_irqsave_t' has no member named 'lock'209 | if (_T->lock) { _unlock; } \ | ^~ include/linux/cleanup.h:236:1: note: in expansion of macro '__DEFINE_UNLOCK_GUARD' 236 | __DEFINE_UNLOCK_GUARD(_name, _type, _unlock, __VA_ARGS__) \ | ^~~~~~~~~~~~~~~~~~~~~
include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1'
60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave,local_lock_t__percpu,
| ^~~~~~~~~~~~~~~~~~~Quoted 1 line
Quoted 1 line
include/linux/percpu-defs.h:219:29: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token219 | const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \ | ^ include/linux/cleanup.h:209:25: note: in definition of macro '__DEFINE_UNLOCK_GUARD' 209 | if (_T->lock) { _unlock; } \ | ^~~~~~~ include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1' 60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu, | ^~~~~~~~~~~~~~~~~~~ include/linux/percpu-defs.h:284:9: note: in expansion of macro '__verify_pcpu_ptr' 284 | __verify_pcpu_ptr(ptr); \ | ^~~~~~~~~~~~~~~~~ include/linux/percpu-defs.h:289:33: note: in expansion of macro 'per_cpu_ptr' 289 | #define raw_cpu_ptr(ptr) per_cpu_ptr(ptr, 0) | ^~~~~~~~~~~ include/linux/percpu-defs.h:290:33: note: in expansion of macro 'raw_cpu_ptr' 290 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr) | ^~~~~~~~~~~ include/linux/local_lock_internal.h:108:36: note: in expansion of macro 'this_cpu_ptr' 108 | local_lock_release(this_cpu_ptr(lock)); \ | ^~~~~~~~~~~~ include/linux/local_lock.h:52:9: note: in expansion of macro '__local_unlock_irqrestore' 52 | __local_unlock_irqrestore(lock, flags) | ^~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/local_lock.h:62:21: note: in expansion of macro 'local_unlock_irqrestore' 62 | local_unlock_irqrestore(_T->lock, _T->flags), | ^~~~~~~~~~~~~~~~~~~~~~~Quoted 1 line
Quoted 1 line
include/linux/percpu-defs.h:219:30: error: '__vpp_verify' undeclared (first use in this function)219 | const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL; \ | ^~~~~~~~~~~~ include/linux/cleanup.h:209:25: note: in definition of macro '__DEFINE_UNLOCK_GUARD' 209 | if (_T->lock) { _unlock; } \ | ^~~~~~~ include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1' 60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu, | ^~~~~~~~~~~~~~~~~~~ include/linux/percpu-defs.h:284:9: note: in expansion of macro '__verify_pcpu_ptr' 284 | __verify_pcpu_ptr(ptr); \ | ^~~~~~~~~~~~~~~~~ include/linux/percpu-defs.h:289:33: note: in expansion of macro 'per_cpu_ptr' 289 | #define raw_cpu_ptr(ptr) per_cpu_ptr(ptr, 0) | ^~~~~~~~~~~ include/linux/percpu-defs.h:290:33: note: in expansion of macro 'raw_cpu_ptr' 290 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr) | ^~~~~~~~~~~ include/linux/local_lock_internal.h:108:36: note: in expansion of macro 'this_cpu_ptr' 108 | local_lock_release(this_cpu_ptr(lock)); \ | ^~~~~~~~~~~~ include/linux/local_lock.h:52:9: note: in expansion of macro '__local_unlock_irqrestore' 52 | __local_unlock_irqrestore(lock, flags) | ^~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/local_lock.h:62:21: note: in expansion of macro 'local_unlock_irqrestore' 62 | local_unlock_irqrestore(_T->lock, _T->flags), | ^~~~~~~~~~~~~~~~~~~~~~~Quoted 1 line
Quoted 1 line
include/linux/local_lock.h:62:47: error: 'class_local_lock_irqsave_t' has no member named 'lock'62 | local_unlock_irqrestore(_T->lock, _T->flags), | ^~ include/linux/cleanup.h:209:25: note: in definition of macro '__DEFINE_UNLOCK_GUARD' 209 | if (_T->lock) { _unlock; } \ | ^~~~~~~ include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1' 60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu, | ^~~~~~~~~~~~~~~~~~~ include/linux/percpu-defs.h:284:9: note: in expansion of macro '__verify_pcpu_ptr' 284 | __verify_pcpu_ptr(ptr); \ | ^~~~~~~~~~~~~~~~~ include/linux/percpu-defs.h:289:33: note: in expansion of macro 'per_cpu_ptr' 289 | #define raw_cpu_ptr(ptr) per_cpu_ptr(ptr, 0) | ^~~~~~~~~~~ include/linux/percpu-defs.h:290:33: note: in expansion of macro 'raw_cpu_ptr' 290 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr) | ^~~~~~~~~~~ include/linux/local_lock_internal.h:108:36: note: in expansion of macro 'this_cpu_ptr' 108 | local_lock_release(this_cpu_ptr(lock)); \ | ^~~~~~~~~~~~ include/linux/local_lock.h:52:9: note: in expansion of macro '__local_unlock_irqrestore' 52 | __local_unlock_irqrestore(lock, flags) | ^~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/local_lock.h:62:21: note: in expansion of macro 'local_unlock_irqrestore' 62 | local_unlock_irqrestore(_T->lock, _T->flags), | ^~~~~~~~~~~~~~~~~~~~~~~ include/linux/local_lock.h:62:47: error: 'class_local_lock_irqsave_t' has no member named 'lock' 62 | local_unlock_irqrestore(_T->lock, _T->flags), | ^~ include/linux/cleanup.h:209:25: note: in definition of macro '__DEFINE_UNLOCK_GUARD' 209 | if (_T->lock) { _unlock; } \ | ^~~~~~~ include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1' 60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu, | ^~~~~~~~~~~~~~~~~~~ include/linux/percpu-defs.h:286:9: note: in expansion of macro 'PERCPU_PTR' 286 | PERCPU_PTR(ptr); \ | ^~~~~~~~~~ include/linux/percpu-defs.h:289:33: note: in expansion of macro 'per_cpu_ptr' 289 | #define raw_cpu_ptr(ptr) per_cpu_ptr(ptr, 0) | ^~~~~~~~~~~ include/linux/percpu-defs.h:290:33: note: in expansion of macro 'raw_cpu_ptr' 290 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr) | ^~~~~~~~~~~ include/linux/local_lock_internal.h:108:36: note: in expansion of macro 'this_cpu_ptr' 108 | local_lock_release(this_cpu_ptr(lock)); \ | ^~~~~~~~~~~~ include/linux/local_lock.h:52:9: note: in expansion of macro '__local_unlock_irqrestore' 52 | __local_unlock_irqrestore(lock, flags) | ^~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/local_lock.h:62:21: note: in expansion of macro 'local_unlock_irqrestore' 62 | local_unlock_irqrestore(_T->lock, _T->flags), | ^~~~~~~~~~~~~~~~~~~~~~~ include/linux/local_lock.h:62:47: error: 'class_local_lock_irqsave_t' has no member named 'lock' 62 | local_unlock_irqrestore(_T->lock, _T->flags), | ^~ include/linux/cleanup.h:209:25: note: in definition of macro '__DEFINE_UNLOCK_GUARD' 209 | if (_T->lock) { _unlock; } \ | ^~~~~~~ include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1' 60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu, | ^~~~~~~~~~~~~~~~~~~ include/linux/percpu-defs.h:279:10: note: in expansion of macro '__pcpu_typeof' 279 | (__pcpu_typeof(*(__p)) __kernel __force *)(ptr__); \ | ^~~~~~~~~~~~~ include/linux/percpu-defs.h:286:9: note: in expansion of macro 'PERCPU_PTR' 286 | PERCPU_PTR(ptr); \ | ^~~~~~~~~~ include/linux/percpu-defs.h:289:33: note: in expansion of macro 'per_cpu_ptr' 289 | #define raw_cpu_ptr(ptr) per_cpu_ptr(ptr, 0) | ^~~~~~~~~~~ include/linux/percpu-defs.h:290:33: note: in expansion of macro 'raw_cpu_ptr' 290 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr) | ^~~~~~~~~~~ include/linux/local_lock_internal.h:108:36: note: in expansion of macro 'this_cpu_ptr' 108 | local_lock_release(this_cpu_ptr(lock)); \ | ^~~~~~~~~~~~ include/linux/local_lock.h:52:9: note: in expansion of macro '__local_unlock_irqrestore' 52 | __local_unlock_irqrestore(lock, flags) | ^~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/local_lock.h:62:21: note: in expansion of macro 'local_unlock_irqrestore' 62 | local_unlock_irqrestore(_T->lock, _T->flags), | ^~~~~~~~~~~~~~~~~~~~~~~ include/linux/local_lock.h:62:57: error: 'class_local_lock_irqsave_t' has no member named 'flags' 62 | local_unlock_irqrestore(_T->lock, _T->flags), | ^~ include/linux/cleanup.h:209:25: note: in definition of macro '__DEFINE_UNLOCK_GUARD' 209 | if (_T->lock) { _unlock; } \ | ^~~~~~~ include/linux/local_lock.h:60:1: note: in expansion of macro 'DEFINE_LOCK_GUARD_1' 60 | DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu, | ^~~~~~~~~~~~~~~~~~~ include/linux/irqflags.h:171:17: note: in expansion of macro 'typecheck' 171 | typecheck(unsigned long, flags); \ | ^~~~~~~~~ include/linux/irqflags.h:234:39: note: in expansion of macro 'raw_local_irq_restore' 234 | #define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0) | ^~~~~~~~~~~~~~~~~~~~~ include/linux/local_lock_internal.h:109:17: note: in expansion of macro 'local_irq_restore' 109 | local_irq_restore(flags); \vim +136
include/linux/percpu.h
e74e396204bfcbTejun Heo 2009-03-30 13524e44cc22aa311Suren Baghdasaryan 2024-03-21 @136 extern void__percpu*pcpu_alloc_noprof(size_t size,size_talign, bool reserved,24e44cc22aa311Suren Baghdasaryan 2024-03-21 137gfp_tgfp)__alloc_size(1);b460bc8302f222Hou Tao 2023-10-20 @138 externsize_tpcpu_alloc_size(void __percpu *__pdata);54da6a0924311c Peter Zijlstra 2023-05-26 139 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 140 #define __alloc_percpu_gfp(_size, _align, _gfp) \ 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 141 alloc_hooks(pcpu_alloc_noprof(_size, _align, false, _gfp)) 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 142 #define __alloc_percpu(_size, _align) \ 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 143 alloc_hooks(pcpu_alloc_noprof(_size, _align, false, GFP_KERNEL)) 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 144 #define __alloc_reserved_percpu(_size, _align) \ 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 145 alloc_hooks(pcpu_alloc_noprof(_size, _align, true, GFP_KERNEL)) de380b55f92986 Tejun Heo 2010-03-24 146 5835d96e9ce4ef Tejun Heo 2014-09-02 147 #define alloc_percpu_gfp(type, gfp) \ 5835d96e9ce4ef Tejun Heo 2014-09-02 148 (typeof(type) __percpu *)__alloc_percpu_gfp(sizeof(type), \ 5835d96e9ce4ef Tejun Heo 2014-09-02 149 __alignof__(type), gfp) 64ef291f46d795 Tejun Heo 2009-10-29 150 #define alloc_percpu(type) \ 5835d96e9ce4ef Tejun Heo 2014-09-02 151 (typeof(type) __percpu *)__alloc_percpu(sizeof(type), \ 5835d96e9ce4ef Tejun Heo 2014-09-02 152 __alignof__(type)) 2c321f3f70bc28 Suren Baghdasaryan 2024-04-14 153 #define alloc_percpu_noprof(type) \ 2c321f3f70bc28 Suren Baghdasaryan 2024-04-14 154 ((typeof(type) __percpu *)pcpu_alloc_noprof(sizeof(type), \ 2c321f3f70bc28 Suren Baghdasaryan 2024-04-14 155 __alignof__(type), false, GFP_KERNEL)) ^1da177e4c3f41 Linus Torvalds 2005-04-16 156 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 157 extern void free_percpu(void __percpu *__pdata); 24e44cc22aa311 Suren Baghdasaryan 2024-03-21 158
24e44cc22aa311Suren Baghdasaryan 2024-03-21 @159DEFINE_FREE(free_percpu, void __percpu *, free_percpu(_T))24e44cc22aa311Suren Baghdasaryan 2024-03-21 160--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Christoph Lameter (Ampere)
maintainerQuoted 4 lines · Uros Bizjak
Also, the last patch hijacks
__percputag and repurposes it as a named address space qualifier. While this works surprisingly well in this RFC patchset, I would really appreciate some help on how to rewrite this hack into some "production ready" code.
This looks like good work to find issues with per cpu macro usage. Per cpu macros are a bit esoteric and it would be a good benefit if you can get this done.
Sadly I cannot help you much with the address space qualifier.
Quoted 11 lines · Christoph Lameter (Ampere)
Quoted 4 lines · Uros Bizjak
Also, the last patch hijacks
__percputag and repurposes it as a named address space qualifier. While this works surprisingly well in this RFC patchset, I would really appreciate some help on how to rewrite this hack into some "production ready" code.This looks like good work to find issues with per cpu macro usage. Per cpu macros are a bit esoteric and it would be a good benefit if you can get this done.
Thanks, I will do my best.
Quoted 1 line
Sadly I cannot help you much with the address space qualifier.
I have solved this in RFC v2, please see [1].
[1] https://lore.kernel.org/lkml/[email protected]/
Thanks and best regards,
Uros.