arch/loongarch/include/asm/percpu.h | 120 ++++++++-------------------- 1 file changed, 35 insertions(+), 85 deletions(-)
_percpu_read() and _percpu_write() macros call __percpu_read()
and __percpu_write() static inline functions that result in a single
assembly instruction. Percpu infrastructure expects its leaf
definitions to encode the size of their percpu variable, so the patch
merges asm clauses from the static inline function into the
corresponding leaf macros.
The secondary effect of this change is to avoid explicit __percpu
function arguments. Currently, __percpu macro is defined in
include/linux/compiler_types.h, but with proposed patch [1],
__percpu definition will need macros from include/asm-generic/percpu.h,
creating forward dependency loop.
The proposed solution is the same as x86 architecture uses.
Patch is compile tested only.
[1] https://lore.kernel.org/lkml/20240812115945.484051-4-ubizjak@gmail.com/
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
arch/loongarch/include/asm/percpu.h | 120 ++++++++--------------------
1 file changed, 35 insertions(+), 85 deletions(-)
diff --git a/arch/loongarch/include/asm/percpu.h b/arch/loongarch/include/asm/percpu.h
index 8f290e5546cf..c0f8e787223c 100644
--- a/arch/loongarch/include/asm/percpu.h
+++ b/arch/loongarch/include/asm/percpu.h
@@ -68,74 +68,36 @@ PERCPU_OP(and, and, &)
PERCPU_OP(or, or, |)
#undef PERCPU_OP
-static __always_inline unsigned long __percpu_read(void __percpu *ptr, int size)
-{
- unsigned long ret;
+#define __pcpu_op_1(op) op ".b "
+#define __pcpu_op_2(op) op ".h "
+#define __pcpu_op_4(op) op ".w "
+#define __pcpu_op_8(op) op ".d "
- switch (size) {
- case 1:
- __asm__ __volatile__ ("ldx.b %[ret], $r21, %[ptr] \n"
- : [ret] "=&r"(ret)
- : [ptr] "r"(ptr)
- : "memory");
- break;
- case 2:
- __asm__ __volatile__ ("ldx.h %[ret], $r21, %[ptr] \n"
- : [ret] "=&r"(ret)
- : [ptr] "r"(ptr)
- : "memory");
- break;
- case 4:
- __asm__ __volatile__ ("ldx.w %[ret], $r21, %[ptr] \n"
- : [ret] "=&r"(ret)
- : [ptr] "r"(ptr)
- : "memory");
- break;
- case 8:
- __asm__ __volatile__ ("ldx.d %[ret], $r21, %[ptr] \n"
- : [ret] "=&r"(ret)
- : [ptr] "r"(ptr)
- : "memory");
- break;
- default:
- ret = 0;
- BUILD_BUG();
- }
+#define _percpu_read(size, _pcp) \
+({ \
+ unsigned long __pcp_ret; \
+ \
+ __asm__ __volatile__ (__pcpu_op_##size("ldx") "%[ret], $r21, %[ptr] \n" \
+ : [ret] "=&r"(__pcp_ret) \
+ : [ptr] "r"(&(_pcp)) \
+ : "memory"); \
+ (typeof(_pcp))__pcp_ret; \
+})
- return ret;
-}
+#define __pcpu_cast_1(val) (((unsigned long) val) & 0xff)
+#define __pcpu_cast_2(val) (((unsigned long) val) & 0xffff)
+#define __pcpu_cast_4(val) (((unsigned long) val) & 0xffffffff)
+#define __pcpu_cast_8(val) (val)
-static __always_inline void __percpu_write(void __percpu *ptr, unsigned long val, int size)
-{
- switch (size) {
- case 1:
- __asm__ __volatile__("stx.b %[val], $r21, %[ptr] \n"
- :
- : [val] "r" (val), [ptr] "r" (ptr)
- : "memory");
- break;
- case 2:
- __asm__ __volatile__("stx.h %[val], $r21, %[ptr] \n"
- :
- : [val] "r" (val), [ptr] "r" (ptr)
- : "memory");
- break;
- case 4:
- __asm__ __volatile__("stx.w %[val], $r21, %[ptr] \n"
- :
- : [val] "r" (val), [ptr] "r" (ptr)
- : "memory");
- break;
- case 8:
- __asm__ __volatile__("stx.d %[val], $r21, %[ptr] \n"
- :
- : [val] "r" (val), [ptr] "r" (ptr)
- : "memory");
- break;
- default:
- BUILD_BUG();
- }
-}
+#define _percpu_write(size, _pcp, _val) \
+do { \
+ unsigned long __pcp_val = __pcpu_cast_##size(_val); \
+ \
+ __asm__ __volatile__ (__pcpu_op_##size("stx") "%[val] $r21, %[ptr] \n" \
+ : \
+ : [val] "r"(__pcp_val), [ptr] "r"(&(_pcp)) \
+ : "memory"); \
+} while (0)
static __always_inline unsigned long __percpu_xchg(void *ptr, unsigned long val, int size)
{
@@ -167,18 +129,6 @@ static __always_inline unsigned long __percpu_xchg(void *ptr, unsigned long val,
__ret; \
})
-#define _percpu_read(pcp) \
-({ \
- typeof(pcp) __retval; \
- __retval = (typeof(pcp))__percpu_read(&(pcp), sizeof(pcp)); \
- __retval; \
-})
-
-#define _percpu_write(pcp, val) \
-do { \
- __percpu_write(&(pcp), (unsigned long)(val), sizeof(pcp)); \
-} while (0) \
-
#define _pcp_protect(operation, pcp, val) \
({ \
typeof(pcp) __retval; \
@@ -215,15 +165,15 @@ do { \
#define this_cpu_or_4(pcp, val) _percpu_or(pcp, val)
#define this_cpu_or_8(pcp, val) _percpu_or(pcp, val)
-#define this_cpu_read_1(pcp) _percpu_read(pcp)
-#define this_cpu_read_2(pcp) _percpu_read(pcp)
-#define this_cpu_read_4(pcp) _percpu_read(pcp)
-#define this_cpu_read_8(pcp) _percpu_read(pcp)
+#define this_cpu_read_1(pcp) _percpu_read(1, pcp)
+#define this_cpu_read_2(pcp) _percpu_read(2, pcp)
+#define this_cpu_read_4(pcp) _percpu_read(4, pcp)
+#define this_cpu_read_8(pcp) _percpu_read(8, pcp)
-#define this_cpu_write_1(pcp, val) _percpu_write(pcp, val)
-#define this_cpu_write_2(pcp, val) _percpu_write(pcp, val)
-#define this_cpu_write_4(pcp, val) _percpu_write(pcp, val)
-#define this_cpu_write_8(pcp, val) _percpu_write(pcp, val)
+#define this_cpu_write_1(pcp, val) _percpu_write(1, pcp, val)
+#define this_cpu_write_2(pcp, val) _percpu_write(2, pcp, val)
+#define this_cpu_write_4(pcp, val) _percpu_write(4, pcp, val)
+#define this_cpu_write_8(pcp, val) _percpu_write(8, pcp, val)
#define this_cpu_xchg_1(pcp, val) _percpu_xchg(pcp, val)
#define this_cpu_xchg_2(pcp, val) _percpu_xchg(pcp, val)
--
2.46.0
Hi Uros,
kernel test robot noticed the following build warnings:
[auto build test WARNING on dennis-percpu/for-next]
[also build test WARNING on linus/master v6.11-rc6 next-20240903]
[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/longsoon-percpu-Simplify-_percpu_read-and-_percpu_write/20240903-182524
base: https://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu.git for-next
patch link: https://lore.kernel.org/r/20240903102342.36957-1-ubizjak%40gmail.com
patch subject: [PATCH] longsoon/percpu: Simplify _percpu_read() and _percpu_write()
config: loongarch-loongson3_defconfig (https://download.01.org/0day-ci/archive/20240904/202409040542.OSJFk9k7-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 13.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240904/202409040542.OSJFk9k7-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/202409040542.OSJFk9k7-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/linux/irqflags.h:19,
from include/linux/spinlock.h:59,
from include/linux/sched.h:2134,
from arch/loongarch/kernel/asm-offsets.c:8:
include/linux/sched/mm.h: In function 'set_active_memcg':
>> arch/loongarch/include/asm/percpu.h:85:33: warning: initialization of 'long unsigned int' from 'struct mem_cgroup *' makes integer from pointer without a cast [-Wint-conversion]
85 | #define __pcpu_cast_8(val) (val)
| ^
arch/loongarch/include/asm/percpu.h:89:35: note: in expansion of macro '__pcpu_cast_8'
89 | unsigned long __pcp_val = __pcpu_cast_##size(_val); \
| ^~~~~~~~~~~~
arch/loongarch/include/asm/percpu.h:171:36: note: in expansion of macro '_percpu_write'
171 | #define this_cpu_write_8(pcp, val) _percpu_write(8, pcp, val)
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:368:25: note: in expansion of macro 'this_cpu_write_8'
368 | case 8: stem##8(variable, __VA_ARGS__);break; \
| ^~~~
include/linux/percpu-defs.h:490:41: note: in expansion of macro '__pcpu_size_call'
490 | #define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
| ^~~~~~~~~~~~~~~~
include/linux/sched/mm.h:420:17: note: in expansion of macro 'this_cpu_write'
420 | this_cpu_write(int_active_memcg, memcg);
| ^~~~~~~~~~~~~~
--
In file included from include/linux/percpu.h:13,
from include/linux/context_tracking_state.h:5,
from include/linux/hardirq.h:5,
from include/linux/interrupt.h:11,
from kernel/panic.c:14:
include/linux/sched/mm.h: In function 'set_active_memcg':
>> arch/loongarch/include/asm/percpu.h:85:33: warning: initialization of 'long unsigned int' from 'struct mem_cgroup *' makes integer from pointer without a cast [-Wint-conversion]
85 | #define __pcpu_cast_8(val) (val)
| ^
arch/loongarch/include/asm/percpu.h:89:35: note: in expansion of macro '__pcpu_cast_8'
89 | unsigned long __pcp_val = __pcpu_cast_##size(_val); \
| ^~~~~~~~~~~~
arch/loongarch/include/asm/percpu.h:171:36: note: in expansion of macro '_percpu_write'
171 | #define this_cpu_write_8(pcp, val) _percpu_write(8, pcp, val)
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:368:25: note: in expansion of macro 'this_cpu_write_8'
368 | case 8: stem##8(variable, __VA_ARGS__);break; \
| ^~~~
include/linux/percpu-defs.h:490:41: note: in expansion of macro '__pcpu_size_call'
490 | #define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
| ^~~~~~~~~~~~~~~~
include/linux/sched/mm.h:420:17: note: in expansion of macro 'this_cpu_write'
420 | this_cpu_write(int_active_memcg, memcg);
| ^~~~~~~~~~~~~~
kernel/panic.c: In function '__warn':
kernel/panic.c:670:17: warning: function '__warn' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
670 | vprintk(args->fmt, args->args);
| ^~~~~~~
--
In file included from include/linux/irqflags.h:19,
from include/linux/spinlock.h:59,
from include/linux/sched.h:2134,
from include/linux/sched/mm.h:7,
from kernel/cpu.c:6:
include/linux/sched/mm.h: In function 'set_active_memcg':
>> arch/loongarch/include/asm/percpu.h:85:33: warning: initialization of 'long unsigned int' from 'struct mem_cgroup *' makes integer from pointer without a cast [-Wint-conversion]
85 | #define __pcpu_cast_8(val) (val)
| ^
arch/loongarch/include/asm/percpu.h:89:35: note: in expansion of macro '__pcpu_cast_8'
89 | unsigned long __pcp_val = __pcpu_cast_##size(_val); \
| ^~~~~~~~~~~~
arch/loongarch/include/asm/percpu.h:171:36: note: in expansion of macro '_percpu_write'
171 | #define this_cpu_write_8(pcp, val) _percpu_write(8, pcp, val)
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:368:25: note: in expansion of macro 'this_cpu_write_8'
368 | case 8: stem##8(variable, __VA_ARGS__);break; \
| ^~~~
include/linux/percpu-defs.h:490:41: note: in expansion of macro '__pcpu_size_call'
490 | #define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
| ^~~~~~~~~~~~~~~~
include/linux/sched/mm.h:420:17: note: in expansion of macro 'this_cpu_write'
420 | this_cpu_write(int_active_memcg, memcg);
| ^~~~~~~~~~~~~~
{standard input}: Assembler messages:
{standard input}:5077: Error: no match insn: stx.w $r14 $r21,$r12
{standard input}:5084: Error: no match insn: stx.w $r14 $r21,$r12
--
In file included from include/linux/irqflags.h:19,
from include/linux/spinlock.h:59,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:7,
from include/linux/mm.h:7,
from kernel/audit.c:38:
include/linux/sched/mm.h: In function 'set_active_memcg':
>> arch/loongarch/include/asm/percpu.h:85:33: warning: initialization of 'long unsigned int' from 'struct mem_cgroup *' makes integer from pointer without a cast [-Wint-conversion]
85 | #define __pcpu_cast_8(val) (val)
| ^
arch/loongarch/include/asm/percpu.h:89:35: note: in expansion of macro '__pcpu_cast_8'
89 | unsigned long __pcp_val = __pcpu_cast_##size(_val); \
| ^~~~~~~~~~~~
arch/loongarch/include/asm/percpu.h:171:36: note: in expansion of macro '_percpu_write'
171 | #define this_cpu_write_8(pcp, val) _percpu_write(8, pcp, val)
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:368:25: note: in expansion of macro 'this_cpu_write_8'
368 | case 8: stem##8(variable, __VA_ARGS__);break; \
| ^~~~
include/linux/percpu-defs.h:490:41: note: in expansion of macro '__pcpu_size_call'
490 | #define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
| ^~~~~~~~~~~~~~~~
include/linux/sched/mm.h:420:17: note: in expansion of macro 'this_cpu_write'
420 | this_cpu_write(int_active_memcg, memcg);
| ^~~~~~~~~~~~~~
kernel/audit.c: In function 'audit_log_vformat':
kernel/audit.c:1979:9: warning: function 'audit_log_vformat' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
1979 | len = vsnprintf(skb_tail_pointer(skb), avail, fmt, args);
| ^~~
kernel/audit.c:1988:17: warning: function 'audit_log_vformat' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
1988 | len = vsnprintf(skb_tail_pointer(skb), avail, fmt, args2);
| ^~~
--
In file included from include/linux/irqflags.h:19,
from include/linux/spinlock.h:59,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:7,
from include/linux/slab.h:16,
from kernel/relay.c:17:
include/linux/sched/mm.h: In function 'set_active_memcg':
>> arch/loongarch/include/asm/percpu.h:85:33: warning: initialization of 'long unsigned int' from 'struct mem_cgroup *' makes integer from pointer without a cast [-Wint-conversion]
85 | #define __pcpu_cast_8(val) (val)
| ^
arch/loongarch/include/asm/percpu.h:89:35: note: in expansion of macro '__pcpu_cast_8'
89 | unsigned long __pcp_val = __pcpu_cast_##size(_val); \
| ^~~~~~~~~~~~
arch/loongarch/include/asm/percpu.h:171:36: note: in expansion of macro '_percpu_write'
171 | #define this_cpu_write_8(pcp, val) _percpu_write(8, pcp, val)
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:368:25: note: in expansion of macro 'this_cpu_write_8'
368 | case 8: stem##8(variable, __VA_ARGS__);break; \
| ^~~~
include/linux/percpu-defs.h:490:41: note: in expansion of macro '__pcpu_size_call'
490 | #define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
| ^~~~~~~~~~~~~~~~
include/linux/sched/mm.h:420:17: note: in expansion of macro 'this_cpu_write'
420 | this_cpu_write(int_active_memcg, memcg);
| ^~~~~~~~~~~~~~
kernel/relay.c: In function 'relay_create_buf_file':
kernel/relay.c:357:42: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
357 | snprintf(tmpname, NAME_MAX, "%s%d", chan->base_filename, cpu);
| ^
kernel/relay.c:357:9: note: 'snprintf' output between 2 and 266 bytes into a destination of size 255
357 | snprintf(tmpname, NAME_MAX, "%s%d", chan->base_filename, cpu);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
In file included from include/linux/irqflags.h:19,
from include/linux/spinlock.h:59,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:7,
from include/linux/mm.h:7,
from mm/slub.c:13:
include/linux/sched/mm.h: In function 'set_active_memcg':
>> arch/loongarch/include/asm/percpu.h:85:33: warning: initialization of 'long unsigned int' from 'struct mem_cgroup *' makes integer from pointer without a cast [-Wint-conversion]
85 | #define __pcpu_cast_8(val) (val)
| ^
arch/loongarch/include/asm/percpu.h:89:35: note: in expansion of macro '__pcpu_cast_8'
89 | unsigned long __pcp_val = __pcpu_cast_##size(_val); \
| ^~~~~~~~~~~~
arch/loongarch/include/asm/percpu.h:171:36: note: in expansion of macro '_percpu_write'
171 | #define this_cpu_write_8(pcp, val) _percpu_write(8, pcp, val)
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:368:25: note: in expansion of macro 'this_cpu_write_8'
368 | case 8: stem##8(variable, __VA_ARGS__);break; \
| ^~~~
include/linux/percpu-defs.h:490:41: note: in expansion of macro '__pcpu_size_call'
490 | #define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
| ^~~~~~~~~~~~~~~~
include/linux/sched/mm.h:420:17: note: in expansion of macro 'this_cpu_write'
420 | this_cpu_write(int_active_memcg, memcg);
| ^~~~~~~~~~~~~~
mm/slub.c: In function 'put_partials':
arch/loongarch/include/asm/percpu.h:85:33: warning: initialization of 'long unsigned int' from 'void *' makes integer from pointer without a cast [-Wint-conversion]
85 | #define __pcpu_cast_8(val) (val)
| ^
arch/loongarch/include/asm/percpu.h:89:35: note: in expansion of macro '__pcpu_cast_8'
89 | unsigned long __pcp_val = __pcpu_cast_##size(_val); \
| ^~~~~~~~~~~~
arch/loongarch/include/asm/percpu.h:171:36: note: in expansion of macro '_percpu_write'
171 | #define this_cpu_write_8(pcp, val) _percpu_write(8, pcp, val)
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:368:25: note: in expansion of macro 'this_cpu_write_8'
368 | case 8: stem##8(variable, __VA_ARGS__);break; \
| ^~~~
include/linux/percpu-defs.h:490:41: note: in expansion of macro '__pcpu_size_call'
490 | #define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
| ^~~~~~~~~~~~~~~~
mm/slub.c:2937:9: note: in expansion of macro 'this_cpu_write'
2937 | this_cpu_write(s->cpu_slab->partial, NULL);
| ^~~~~~~~~~~~~~
mm/slub.c: In function 'put_cpu_partial':
arch/loongarch/include/asm/percpu.h:85:33: warning: initialization of 'long unsigned int' from 'struct slab *' makes integer from pointer without a cast [-Wint-conversion]
85 | #define __pcpu_cast_8(val) (val)
| ^
arch/loongarch/include/asm/percpu.h:89:35: note: in expansion of macro '__pcpu_cast_8'
89 | unsigned long __pcp_val = __pcpu_cast_##size(_val); \
| ^~~~~~~~~~~~
arch/loongarch/include/asm/percpu.h:171:36: note: in expansion of macro '_percpu_write'
171 | #define this_cpu_write_8(pcp, val) _percpu_write(8, pcp, val)
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:368:25: note: in expansion of macro 'this_cpu_write_8'
368 | case 8: stem##8(variable, __VA_ARGS__);break; \
| ^~~~
include/linux/percpu-defs.h:490:41: note: in expansion of macro '__pcpu_size_call'
490 | #define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
| ^~~~~~~~~~~~~~~~
mm/slub.c:2992:9: note: in expansion of macro 'this_cpu_write'
2992 | this_cpu_write(s->cpu_slab->partial, slab);
| ^~~~~~~~~~~~~~
{standard input}: Assembler messages:
{standard input}:8207: Error: no match insn: stx.d $r13 $r21,$r14
{standard input}:9031: Error: no match insn: stx.d $r15 $r21,$r13
--
In file included from include/linux/irqflags.h:19,
from include/linux/spinlock.h:59,
from include/linux/wait.h:9,
from include/linux/wait_bit.h:8,
from include/linux/fs.h:6,
from include/linux/highmem.h:5,
from include/linux/bvec.h:10,
from include/linux/blk_types.h:10,
from include/linux/blkdev.h:9,
from mm/swapfile.c:9:
include/linux/sched/mm.h: In function 'set_active_memcg':
>> arch/loongarch/include/asm/percpu.h:85:33: warning: initialization of 'long unsigned int' from 'struct mem_cgroup *' makes integer from pointer without a cast [-Wint-conversion]
85 | #define __pcpu_cast_8(val) (val)
| ^
arch/loongarch/include/asm/percpu.h:89:35: note: in expansion of macro '__pcpu_cast_8'
89 | unsigned long __pcp_val = __pcpu_cast_##size(_val); \
| ^~~~~~~~~~~~
arch/loongarch/include/asm/percpu.h:171:36: note: in expansion of macro '_percpu_write'
171 | #define this_cpu_write_8(pcp, val) _percpu_write(8, pcp, val)
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:368:25: note: in expansion of macro 'this_cpu_write_8'
368 | case 8: stem##8(variable, __VA_ARGS__);break; \
| ^~~~
include/linux/percpu-defs.h:490:41: note: in expansion of macro '__pcpu_size_call'
490 | #define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
| ^~~~~~~~~~~~~~~~
include/linux/sched/mm.h:420:17: note: in expansion of macro 'this_cpu_write'
420 | this_cpu_write(int_active_memcg, memcg);
| ^~~~~~~~~~~~~~
{standard input}: Assembler messages:
{standard input}:1338: Error: no match insn: stx.w $r5 $r21,$r12
--
In file included from include/linux/irqflags.h:19,
from include/linux/spinlock.h:59,
from include/linux/sched.h:2134,
from include/linux/cgroup.h:12,
from include/linux/memcontrol.h:13,
from mm/memcontrol.c:29:
include/linux/sched/mm.h: In function 'set_active_memcg':
>> arch/loongarch/include/asm/percpu.h:85:33: warning: initialization of 'long unsigned int' from 'struct mem_cgroup *' makes integer from pointer without a cast [-Wint-conversion]
85 | #define __pcpu_cast_8(val) (val)
| ^
arch/loongarch/include/asm/percpu.h:89:35: note: in expansion of macro '__pcpu_cast_8'
89 | unsigned long __pcp_val = __pcpu_cast_##size(_val); \
| ^~~~~~~~~~~~
arch/loongarch/include/asm/percpu.h:171:36: note: in expansion of macro '_percpu_write'
171 | #define this_cpu_write_8(pcp, val) _percpu_write(8, pcp, val)
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:368:25: note: in expansion of macro 'this_cpu_write_8'
368 | case 8: stem##8(variable, __VA_ARGS__);break; \
| ^~~~
include/linux/percpu-defs.h:490:41: note: in expansion of macro '__pcpu_size_call'
490 | #define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
| ^~~~~~~~~~~~~~~~
include/linux/sched/mm.h:420:17: note: in expansion of macro 'this_cpu_write'
420 | this_cpu_write(int_active_memcg, memcg);
| ^~~~~~~~~~~~~~
{standard input}: Assembler messages:
{standard input}:5759: Error: no match insn: stx.d $r4 $r21,$r12
{standard input}:5781: Error: no match insn: stx.d $r25 $r21,$r12
--
In file included from include/linux/irqflags.h:19,
from include/linux/rcupdate.h:26,
from include/linux/rculist.h:11,
from include/linux/sched/signal.h:5,
from fs/buffer.c:23:
include/linux/sched/mm.h: In function 'set_active_memcg':
>> arch/loongarch/include/asm/percpu.h:85:33: warning: initialization of 'long unsigned int' from 'struct mem_cgroup *' makes integer from pointer without a cast [-Wint-conversion]
85 | #define __pcpu_cast_8(val) (val)
| ^
arch/loongarch/include/asm/percpu.h:89:35: note: in expansion of macro '__pcpu_cast_8'
89 | unsigned long __pcp_val = __pcpu_cast_##size(_val); \
| ^~~~~~~~~~~~
arch/loongarch/include/asm/percpu.h:171:36: note: in expansion of macro '_percpu_write'
171 | #define this_cpu_write_8(pcp, val) _percpu_write(8, pcp, val)
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:368:25: note: in expansion of macro 'this_cpu_write_8'
368 | case 8: stem##8(variable, __VA_ARGS__);break; \
| ^~~~
include/linux/percpu-defs.h:490:41: note: in expansion of macro '__pcpu_size_call'
490 | #define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
| ^~~~~~~~~~~~~~~~
include/linux/sched/mm.h:420:17: note: in expansion of macro 'this_cpu_write'
420 | this_cpu_write(int_active_memcg, memcg);
| ^~~~~~~~~~~~~~
{standard input}: Assembler messages:
{standard input}:1678: Error: no match insn: stx.d $r13 $r21,$r12
{standard input}:1733: Error: no match insn: stx.d $r28 $r21,$r12
..
vim +85 arch/loongarch/include/asm/percpu.h
81
82 #define __pcpu_cast_1(val) (((unsigned long) val) & 0xff)
83 #define __pcpu_cast_2(val) (((unsigned long) val) & 0xffff)
84 #define __pcpu_cast_4(val) (((unsigned long) val) & 0xffffffff)
> 85 #define __pcpu_cast_8(val) (val)
86
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Uros,
kernel test robot noticed the following build errors:
[auto build test ERROR on dennis-percpu/for-next]
[also build test ERROR on linus/master v6.11-rc6 next-20240903]
[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/longsoon-percpu-Simplify-_percpu_read-and-_percpu_write/20240903-182524
base: https://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu.git for-next
patch link: https://lore.kernel.org/r/20240903102342.36957-1-ubizjak%40gmail.com
patch subject: [PATCH] longsoon/percpu: Simplify _percpu_read() and _percpu_write()
config: loongarch-allmodconfig (https://download.01.org/0day-ci/archive/20240904/202409040319.2mRdIGd2-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240904/202409040319.2mRdIGd2-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/202409040319.2mRdIGd2-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from include/linux/irqflags.h:19,
from include/linux/spinlock.h:59,
from include/linux/sched.h:2134,
from arch/loongarch/kernel/asm-offsets.c:8:
include/linux/sched/mm.h: In function 'set_active_memcg':
>> arch/loongarch/include/asm/percpu.h:85:33: error: initialization of 'long unsigned int' from 'struct mem_cgroup *' makes integer from pointer without a cast [-Wint-conversion]
85 | #define __pcpu_cast_8(val) (val)
| ^
arch/loongarch/include/asm/percpu.h:89:35: note: in expansion of macro '__pcpu_cast_8'
89 | unsigned long __pcp_val = __pcpu_cast_##size(_val); \
| ^~~~~~~~~~~~
arch/loongarch/include/asm/percpu.h:171:36: note: in expansion of macro '_percpu_write'
171 | #define this_cpu_write_8(pcp, val) _percpu_write(8, pcp, val)
| ^~~~~~~~~~~~~
include/linux/percpu-defs.h:368:25: note: in expansion of macro 'this_cpu_write_8'
368 | case 8: stem##8(variable, __VA_ARGS__);break; \
| ^~~~
include/linux/percpu-defs.h:490:41: note: in expansion of macro '__pcpu_size_call'
490 | #define this_cpu_write(pcp, val) __pcpu_size_call(this_cpu_write_, pcp, val)
| ^~~~~~~~~~~~~~~~
include/linux/sched/mm.h:420:17: note: in expansion of macro 'this_cpu_write'
420 | this_cpu_write(int_active_memcg, memcg);
| ^~~~~~~~~~~~~~
make[3]: *** [scripts/Makefile.build:116: arch/loongarch/kernel/asm-offsets.s] Error 1
make[3]: Target 'prepare' not remade because of errors.
make[2]: *** [Makefile:1199: 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 +85 arch/loongarch/include/asm/percpu.h
81
82 #define __pcpu_cast_1(val) (((unsigned long) val) & 0xff)
83 #define __pcpu_cast_2(val) (((unsigned long) val) & 0xffff)
84 #define __pcpu_cast_4(val) (((unsigned long) val) & 0xffffffff)
> 85 #define __pcpu_cast_8(val) (val)
86
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On Tue, 2024-09-03 at 12:23 +0200, Uros Bizjak wrote:
> +#define _percpu_write(size, _pcp, _val) \
> +do { \
> + unsigned long __pcp_val = __pcpu_cast_##size(_val); \
> + \
> + __asm__ __volatile__ (__pcpu_op_##size("stx") "%[val] $r21, %[ptr] \n" \
Missing a comma before $r21 (as the bot already pointed out).
> + : \
> + : [val] "r"(__pcp_val), [ptr] "r"(&(_pcp)) \
> + : "memory"); \
> +} while (0)
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
On Tue, Sep 3, 2024 at 8:57 PM Xi Ruoyao <xry111@xry111.site> wrote:
>
> On Tue, 2024-09-03 at 12:23 +0200, Uros Bizjak wrote:
> > +#define _percpu_write(size, _pcp, _val) \
> > +do { \
> > + unsigned long __pcp_val = __pcpu_cast_##size(_val); \
> > + \
> > + __asm__ __volatile__ (__pcpu_op_##size("stx") "%[val] $r21, %[ptr] \n" \
>
> Missing a comma before $r21 (as the bot already pointed out).
Oh, indeed... I triple checked the patch and missed the most obvious thing :(
BR,
Uros.
>
> > + : \
> > + : [val] "r"(__pcp_val), [ptr] "r"(&(_pcp)) \
> > + : "memory"); \
> > +} while (0)
>
> --
> Xi Ruoyao <xry111@xry111.site>
> School of Aerospace Science and Technology, Xidian University
Hi Uros,
kernel test robot noticed the following build errors:
[auto build test ERROR on dennis-percpu/for-next]
[also build test ERROR on linus/master v6.11-rc6 next-20240903]
[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/longsoon-percpu-Simplify-_percpu_read-and-_percpu_write/20240903-182524
base: https://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu.git for-next
patch link: https://lore.kernel.org/r/20240903102342.36957-1-ubizjak%40gmail.com
patch subject: [PATCH] longsoon/percpu: Simplify _percpu_read() and _percpu_write()
config: loongarch-allnoconfig (https://download.01.org/0day-ci/archive/20240904/202409040211.HXF2MzXO-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240904/202409040211.HXF2MzXO-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/202409040211.HXF2MzXO-lkp@intel.com/
All errors (new ones prefixed by >>):
{standard input}: Assembler messages:
>> {standard input}:1503: Error: no match insn: stx.w $r12 $r21,$r13
{standard input}:1519: Error: no match insn: stx.w $r12 $r21,$r13
{standard input}:1548: Error: no match insn: stx.w $r12 $r21,$r13
{standard input}:1642: Error: no match insn: stx.w $r12 $r21,$r13
{standard input}:1658: Error: no match insn: stx.w $r12 $r21,$r13
{standard input}:1687: Error: no match insn: stx.w $r12 $r21,$r13
{standard input}:1889: Error: no match insn: stx.w $r12 $r21,$r13
{standard input}:1906: Error: no match insn: stx.w $r12 $r21,$r13
{standard input}:1920: Error: no match insn: stx.w $r12 $r21,$r13
--
{standard input}: Assembler messages:
{standard input}:1178: Error: no match insn: stx.w $r12 $r21,$r13
{standard input}:1971: Error: no match insn: stx.w $r12 $r21,$r13
>> {standard input}:8812: Error: no match insn: stx.w $r13 $r21,$r12
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2025 Red Hat, Inc.