Generic Linux architectural discussions
 help / color / mirror / Atom feed
* [PATCH v3 6/7] asm-generic: percpu: Add assembly guard
       [not found] <20250914155658.1028790-1-tiwei.bie@linux.dev>
@ 2025-09-14 15:56 ` Tiwei Bie
  2025-09-15  7:40   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Tiwei Bie @ 2025-09-14 15:56 UTC (permalink / raw)
  To: richard, anton.ivanov, johannes
  Cc: linux-um, linux-kernel, benjamin, arnd, tiwei.btw, tiwei.bie,
	linux-arch

From: Tiwei Bie <tiwei.btw@antgroup.com>

Currently, asm/percpu.h is directly or indirectly included by
some assembly files on x86. Some of them (e.g., checksum_32.S)
are also used on um. But x86 and um provide different versions
of asm/percpu.h -- um uses asm-generic/percpu.h directly.

When SMP is enabled, asm-generic/percpu.h will introduce C code
that cannot be assembled. Since asm-generic/percpu.h currently
is not designed for use in assembly, and these assembly files
do not actually need asm/percpu.h on um, let's add the assembly
guard in asm-generic/percpu.h to fix this issue.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arch@vger.kernel.org
Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
---
 include/asm-generic/percpu.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index 02aeca21479a..6628670bcb90 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -2,6 +2,8 @@
 #ifndef _ASM_GENERIC_PERCPU_H_
 #define _ASM_GENERIC_PERCPU_H_
 
+#ifndef __ASSEMBLER__
+
 #include <linux/compiler.h>
 #include <linux/threads.h>
 #include <linux/percpu-defs.h>
@@ -557,4 +559,5 @@ do {									\
 	this_cpu_generic_cmpxchg(pcp, oval, nval)
 #endif
 
+#endif /* __ASSEMBLER__ */
 #endif /* _ASM_GENERIC_PERCPU_H_ */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 6/7] asm-generic: percpu: Add assembly guard
  2025-09-14 15:56 ` [PATCH v3 6/7] asm-generic: percpu: Add assembly guard Tiwei Bie
@ 2025-09-15  7:40   ` Arnd Bergmann
  2025-09-15 15:29     ` Tiwei Bie
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2025-09-15  7:40 UTC (permalink / raw)
  To: Tiwei Bie, Richard Weinberger, Anton Ivanov, Johannes Berg
  Cc: linux-um, linux-kernel, benjamin, Tiwei Bie, Linux-Arch

On Sun, Sep 14, 2025, at 17:56, Tiwei Bie wrote:
> From: Tiwei Bie <tiwei.btw@antgroup.com>
>
> Currently, asm/percpu.h is directly or indirectly included by
> some assembly files on x86. Some of them (e.g., checksum_32.S)
> are also used on um. But x86 and um provide different versions
> of asm/percpu.h -- um uses asm-generic/percpu.h directly.
>
> When SMP is enabled, asm-generic/percpu.h will introduce C code
> that cannot be assembled. Since asm-generic/percpu.h currently
> is not designed for use in assembly, and these assembly files
> do not actually need asm/percpu.h on um, let's add the assembly
> guard in asm-generic/percpu.h to fix this issue.
>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: linux-arch@vger.kernel.org
> Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>

Have you tried if you can remove the percpu.h dependency from
the files that currently include it? In many cases it should
be enough to use percpu-defs.h.

If that doesn't work, I have no objections to this patch either.

Acked-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 6/7] asm-generic: percpu: Add assembly guard
  2025-09-15  7:40   ` Arnd Bergmann
@ 2025-09-15 15:29     ` Tiwei Bie
  0 siblings, 0 replies; 3+ messages in thread
From: Tiwei Bie @ 2025-09-15 15:29 UTC (permalink / raw)
  To: arnd
  Cc: richard, anton.ivanov, johannes, benjamin, linux-arch,
	linux-kernel, linux-um, tiwei.btw, tiwei.bie

On Mon, 15 Sep 2025 09:40:35 +0200, Arnd Bergmann wrote:
> On Sun, Sep 14, 2025, at 17:56, Tiwei Bie wrote:
> > From: Tiwei Bie <tiwei.btw@antgroup.com>
> >
> > Currently, asm/percpu.h is directly or indirectly included by
> > some assembly files on x86. Some of them (e.g., checksum_32.S)
> > are also used on um. But x86 and um provide different versions
> > of asm/percpu.h -- um uses asm-generic/percpu.h directly.
> >
> > When SMP is enabled, asm-generic/percpu.h will introduce C code
> > that cannot be assembled. Since asm-generic/percpu.h currently
> > is not designed for use in assembly, and these assembly files
> > do not actually need asm/percpu.h on um, let's add the assembly
> > guard in asm-generic/percpu.h to fix this issue.
> >
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: linux-arch@vger.kernel.org
> > Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
> 
> Have you tried if you can remove the percpu.h dependency from
> the files that currently include it? In many cases it should
> be enough to use percpu-defs.h.

It doesn't seem to work. The indirect inclusion of asm/percpu.h
comes from asm/nospec-branch.h, which expands DECLARE_PER_CPU()
and thus requires asm/percpu.h.

> 
> If that doesn't work, I have no objections to this patch either.
> 
> Acked-by: Arnd Bergmann <arnd@arndb.de>

Thanks! :)

Regards,
Tiwei

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-15 15:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250914155658.1028790-1-tiwei.bie@linux.dev>
2025-09-14 15:56 ` [PATCH v3 6/7] asm-generic: percpu: Add assembly guard Tiwei Bie
2025-09-15  7:40   ` Arnd Bergmann
2025-09-15 15:29     ` Tiwei Bie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox