The patch introduces per_cpu_qual define and repurposes __percpu
tag as a named address space qualifier using the new define.
Arches can now conditionally define __per_cpu_qual as their
named address space qualifier for percpu variables.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Acked-by: Nadav Amit <nadav.amit@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Dennis Zhou <dennis@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Peter Zijlstra <peterz@infradead.org>
---
include/asm-generic/percpu.h | 15 +++++++++++++++
include/linux/compiler_types.h | 2 +-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index 50597b975a49..3b93b168faa1 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -6,6 +6,21 @@
#include <linux/threads.h>
#include <linux/percpu-defs.h>
+/*
+ * per_cpu_qual is the qualifier for the percpu named address space.
+ *
+ * Most arches use generic named address space for percpu variables but
+ * some arches define percpu variables in different named address space
+ * (on the x86 arch, percpu variable may be declared as being relative
+ * to the %fs or %gs segments using __seg_fs or __seg_gs named address
+ * space qualifier).
+ */
+#ifdef __per_cpu_qual
+# define per_cpu_qual __per_cpu_qual
+#else
+# define per_cpu_qual
+#endif
+
#ifdef CONFIG_SMP
/*
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 981cc3d7e3aa..877fe0c43c5d 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -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 per_cpu_qual BTF_TYPE_TAG(percpu)
# define __rcu BTF_TYPE_TAG(rcu)
# define __chk_user_ptr(x) (void)0
--
2.42.0
Hi Uros,
On Thu, Dec 05, 2024 at 04:40:55PM +0100, Uros Bizjak wrote:
> The patch introduces per_cpu_qual define and repurposes __percpu
> tag as a named address space qualifier using the new define.
>
> Arches can now conditionally define __per_cpu_qual as their
> named address space qualifier for percpu variables.
>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Acked-by: Nadav Amit <nadav.amit@gmail.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Dennis Zhou <dennis@kernel.org>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Christoph Lameter <cl@linux.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Brian Gerst <brgerst@gmail.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> ---
> include/asm-generic/percpu.h | 15 +++++++++++++++
> include/linux/compiler_types.h | 2 +-
> 2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
> index 50597b975a49..3b93b168faa1 100644
> --- a/include/asm-generic/percpu.h
> +++ b/include/asm-generic/percpu.h
> @@ -6,6 +6,21 @@
> #include <linux/threads.h>
> #include <linux/percpu-defs.h>
>
> +/*
> + * per_cpu_qual is the qualifier for the percpu named address space.
> + *
> + * Most arches use generic named address space for percpu variables but
> + * some arches define percpu variables in different named address space
> + * (on the x86 arch, percpu variable may be declared as being relative
> + * to the %fs or %gs segments using __seg_fs or __seg_gs named address
> + * space qualifier).
> + */
> +#ifdef __per_cpu_qual
I read through the series and I think my only nit would be here. Can we
name this __percpu_qual? My thoughts are that it keeps it consistent
with the old address space identifier and largely most of the core
percpu stuff is defined with percpu as the naming scheme.
> +# define per_cpu_qual __per_cpu_qual
> +#else
> +# define per_cpu_qual
> +#endif
> +
> #ifdef CONFIG_SMP
>
> /*
> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> index 981cc3d7e3aa..877fe0c43c5d 100644
> --- a/include/linux/compiler_types.h
> +++ b/include/linux/compiler_types.h
> @@ -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 per_cpu_qual BTF_TYPE_TAG(percpu)
> # define __rcu BTF_TYPE_TAG(rcu)
>
> # define __chk_user_ptr(x) (void)0
> --
> 2.42.0
>
Thanks,
Dennis
On Fri, Dec 6, 2024 at 8:35 AM Dennis Zhou <dennis@kernel.org> wrote:
>
> Hi Uros,
>
> On Thu, Dec 05, 2024 at 04:40:55PM +0100, Uros Bizjak wrote:
> > The patch introduces per_cpu_qual define and repurposes __percpu
> > tag as a named address space qualifier using the new define.
> >
> > Arches can now conditionally define __per_cpu_qual as their
> > named address space qualifier for percpu variables.
> >
> > Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> > Acked-by: Nadav Amit <nadav.amit@gmail.com>
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Dennis Zhou <dennis@kernel.org>
> > Cc: Tejun Heo <tj@kernel.org>
> > Cc: Christoph Lameter <cl@linux.com>
> > Cc: Linus Torvalds <torvalds@linux-foundation.org>
> > Cc: Andy Lutomirski <luto@kernel.org>
> > Cc: Ingo Molnar <mingo@kernel.org>
> > Cc: Brian Gerst <brgerst@gmail.com>
> > Cc: "H. Peter Anvin" <hpa@zytor.com>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > ---
> > include/asm-generic/percpu.h | 15 +++++++++++++++
> > include/linux/compiler_types.h | 2 +-
> > 2 files changed, 16 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
> > index 50597b975a49..3b93b168faa1 100644
> > --- a/include/asm-generic/percpu.h
> > +++ b/include/asm-generic/percpu.h
> > @@ -6,6 +6,21 @@
> > #include <linux/threads.h>
> > #include <linux/percpu-defs.h>
> >
> > +/*
> > + * per_cpu_qual is the qualifier for the percpu named address space.
> > + *
> > + * Most arches use generic named address space for percpu variables but
> > + * some arches define percpu variables in different named address space
> > + * (on the x86 arch, percpu variable may be declared as being relative
> > + * to the %fs or %gs segments using __seg_fs or __seg_gs named address
> > + * space qualifier).
> > + */
> > +#ifdef __per_cpu_qual
>
> I read through the series and I think my only nit would be here. Can we
> name this __percpu_qual? My thoughts are that it keeps it consistent
> with the old address space identifier and largely most of the core
> percpu stuff is defined with percpu as the naming scheme.
I based the approach on the definition of per_cpu_offset() a few lines
bellow in include/asm-generic/percpu.h:
--q--
#ifndef __per_cpu_offset
extern unsigned long __per_cpu_offset[NR_CPUS];
#define per_cpu_offset(x) (__per_cpu_offset[x])
#endif
--/q--
Sure, we can call this __percpu_qual. So, the definition in
arch/x86/include/asm/percpu.h would read as:
# define __percpu_qual __percpu_seg_override
> > +# define per_cpu_qual __per_cpu_qual
> > +#else
> > +# define per_cpu_qual
> > +#endif
The above part could be recoded as:
#ifndef __percpu_qual
# define __percpu_qual
#endif
while the line below would become:
# define __percpu __percpu_qual BTF_TYPE_TAG(percpu)
> > +
> > #ifdef CONFIG_SMP
> >
> > /*
> > diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> > index 981cc3d7e3aa..877fe0c43c5d 100644
> > --- a/include/linux/compiler_types.h
> > +++ b/include/linux/compiler_types.h
> > @@ -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 per_cpu_qual BTF_TYPE_TAG(percpu)
> > # define __rcu BTF_TYPE_TAG(rcu)
> >
> > # define __chk_user_ptr(x) (void)0
Let me test these changes a bit, I'll send a v3 in a couple of days.
Thanks,
Uros.
On Thu, 5 Dec 2024, Dennis Zhou wrote: > I read through the series and I think my only nit would be here. Can we > name this __percpu_qual? My thoughts are that it keeps it consistent > with the old address space identifier and largely most of the core > percpu stuff is defined with percpu as the naming scheme. Yes lets keep it consistent.
© 2016 - 2025 Red Hat, Inc.