linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: Dennis Zhou <dennis@kernel.org>
Cc: x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	 linux-bcachefs@vger.kernel.org, linux-arch@vger.kernel.org,
	 netdev@vger.kernel.org, Nadav Amit <nadav.amit@gmail.com>,
	 Arnd Bergmann <arnd@arndb.de>,
	Thomas Gleixner <tglx@linutronix.de>, Tejun Heo <tj@kernel.org>,
	 Christoph Lameter <cl@linux.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	 Andy Lutomirski <luto@kernel.org>,
	Ingo Molnar <mingo@kernel.org>, Brian Gerst <brgerst@gmail.com>,
	 "H. Peter Anvin" <hpa@zytor.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v2 5/6] percpu: Repurpose __percpu tag as a named address space qualifier
Date: Fri, 6 Dec 2024 21:13:03 +0100	[thread overview]
Message-ID: <CAFULd4ardZ1GT0a9E_Bnu+8VAbxXTcFfvU7QrC14p+XbwdgC2A@mail.gmail.com> (raw)
In-Reply-To: <Z1KpWenJGqhjtNL9@V92F7Y9K0C.lan>

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.


  parent reply	other threads:[~2024-12-06 20:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-05 15:40 [PATCH v2 0/6] Enable strict percpu address space checks Uros Bizjak
2024-12-05 15:40 ` [PATCH v2 1/6] x86/kgdb: Use IS_ERR_PCPU() macro Uros Bizjak
2024-12-05 15:40 ` [PATCH v2 2/6] compiler.h: Introduce TYPEOF_UNQUAL() macro Uros Bizjak
2024-12-05 15:40 ` [PATCH v2 3/6] percpu: Use TYPEOF_UNQUAL() in variable declarations Uros Bizjak
2024-12-05 15:40 ` [PATCH v2 4/6] percpu: Use TYPEOF_UNQUAL() in *_cpu_ptr() accessors Uros Bizjak
2024-12-05 15:40 ` [PATCH v2 5/6] percpu: Repurpose __percpu tag as a named address space qualifier Uros Bizjak
2024-12-06  7:35   ` Dennis Zhou
2024-12-06 19:07     ` Christoph Lameter (Ampere)
2024-12-06 20:13     ` Uros Bizjak [this message]
2024-12-05 15:40 ` [PATCH v2 6/6] percpu/x86: Enable strict percpu checks via named AS qualifiers Uros Bizjak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFULd4ardZ1GT0a9E_Bnu+8VAbxXTcFfvU7QrC14p+XbwdgC2A@mail.gmail.com \
    --to=ubizjak@gmail.com \
    --cc=arnd@arndb.de \
    --cc=brgerst@gmail.com \
    --cc=cl@linux.com \
    --cc=dennis@kernel.org \
    --cc=hpa@zytor.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-bcachefs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=nadav.amit@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox