From: Charlie Jenkins <charlie@rivosinc.com>
To: Guo Ren <guoren@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
Conor Dooley <conor@kernel.org>,
Samuel Holland <samuel.holland@sifive.com>,
David Laight <David.Laight@aculab.com>,
Xiao Wang <xiao.w.wang@intel.com>, Evan Green <evan@rivosinc.com>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-arch@vger.kernel.org,
Paul Walmsley <paul.walmsley@sifive.com>,
Albert Ou <aou@eecs.berkeley.edu>, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v13 2/5] riscv: Add static key for misaligned accesses
Date: Thu, 21 Dec 2023 17:37:51 -0800 [thread overview]
Message-ID: <ZYTobxPZVNct4toQ@ghost> (raw)
In-Reply-To: <CAJF2gTR9ZxLZwEs=TMeih+vEEuuxNHRkgLsG2ShjXPEZ-G44_w@mail.gmail.com>
On Fri, Dec 22, 2023 at 08:33:18AM +0800, Guo Ren wrote:
> On Thu, Dec 21, 2023 at 7:38 AM Charlie Jenkins <charlie@rivosinc.com> wrote:
> >
> > Support static branches depending on the value of misaligned accesses.
> > This will be used by a later patch in the series. All cpus must be
> > considered "fast" for this static branch to be flipped.
> >
> > Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
> > ---
> > arch/riscv/include/asm/cpufeature.h | 2 ++
> > arch/riscv/kernel/cpufeature.c | 30 ++++++++++++++++++++++++++++++
> > 2 files changed, 32 insertions(+)
> >
> > diff --git a/arch/riscv/include/asm/cpufeature.h b/arch/riscv/include/asm/cpufeature.h
> > index a418c3112cd6..7b129e5e2f07 100644
> > --- a/arch/riscv/include/asm/cpufeature.h
> > +++ b/arch/riscv/include/asm/cpufeature.h
> > @@ -133,4 +133,6 @@ static __always_inline bool riscv_cpu_has_extension_unlikely(int cpu, const unsi
> > return __riscv_isa_extension_available(hart_isa[cpu].isa, ext);
> > }
> >
> > +DECLARE_STATIC_KEY_FALSE(fast_misaligned_access_speed_key);
> > +
> > #endif
> > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
> > index b3785ffc1570..095eb6ebdcaa 100644
> > --- a/arch/riscv/kernel/cpufeature.c
> > +++ b/arch/riscv/kernel/cpufeature.c
> > @@ -10,6 +10,7 @@
> > #include <linux/bitmap.h>
> > #include <linux/cpuhotplug.h>
> > #include <linux/ctype.h>
> > +#include <linux/jump_label.h>
> > #include <linux/log2.h>
> > #include <linux/memory.h>
> > #include <linux/module.h>
> > @@ -728,6 +729,35 @@ void riscv_user_isa_enable(void)
> > csr_set(CSR_SENVCFG, ENVCFG_CBZE);
> > }
> >
> > +DEFINE_STATIC_KEY_FALSE(fast_misaligned_access_speed_key);
> > +
> > +static int set_unaligned_access_static_branches(void)
> > +{
> > + /*
> > + * This will be called after check_unaligned_access_all_cpus so the
> > + * result of unaligned access speed for all cpus will be available.
> > + */
> > +
> > + int cpu;
> > + bool fast_misaligned_access_speed = true;
> > +
> > + for_each_online_cpu(cpu) {
> Each online_cpu? Is there any offline_cpu that is no
> fast_misaligned_access_speed?
I think instead of checking offline cpus, it would make more sense to
adjust the static branch when offline cpus come online. Since
riscv_online_cpu is called when a new CPU comes online, I can update the
static branch inside of that function.
>
> Move into your riscv_online_cpu for each CPU, and use stop_machine for
> synchronization.
>
I do not understand what you mean by "Move into your riscv_online_cpu
for each CPU", but I am assuming you are referring to updating the
static branch inside of riscv_online_cpu.
I believe any race condition that could be solved by stop_machine will
become irrelevent by ensuring that the static branch is updated when a
new cpu comes online.
- Charlie
> > + int this_perf = per_cpu(misaligned_access_speed, cpu);
> > +
> > + if (this_perf != RISCV_HWPROBE_MISALIGNED_FAST) {
> > + fast_misaligned_access_speed = false;
> > + break;
> > + }
> > + }
> > +
> > + if (fast_misaligned_access_speed)
> > + static_branch_enable(&fast_misaligned_access_speed_key);
> > +
> > + return 0;
> > +}
> > +
> > +arch_initcall_sync(set_unaligned_access_static_branches);
> > +
> > #ifdef CONFIG_RISCV_ALTERNATIVE
> > /*
> > * Alternative patch sites consider 48 bits when determining when to patch
> >
> > --
> > 2.43.0
> >
> >
>
>
> --
> Best Regards
> Guo Ren
WARNING: multiple messages have this Message-ID (diff)
From: Charlie Jenkins <charlie@rivosinc.com>
To: Guo Ren <guoren@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
Conor Dooley <conor@kernel.org>,
Samuel Holland <samuel.holland@sifive.com>,
David Laight <David.Laight@aculab.com>,
Xiao Wang <xiao.w.wang@intel.com>, Evan Green <evan@rivosinc.com>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-arch@vger.kernel.org,
Paul Walmsley <paul.walmsley@sifive.com>,
Albert Ou <aou@eecs.berkeley.edu>, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v13 2/5] riscv: Add static key for misaligned accesses
Date: Thu, 21 Dec 2023 17:37:51 -0800 [thread overview]
Message-ID: <ZYTobxPZVNct4toQ@ghost> (raw)
In-Reply-To: <CAJF2gTR9ZxLZwEs=TMeih+vEEuuxNHRkgLsG2ShjXPEZ-G44_w@mail.gmail.com>
On Fri, Dec 22, 2023 at 08:33:18AM +0800, Guo Ren wrote:
> On Thu, Dec 21, 2023 at 7:38 AM Charlie Jenkins <charlie@rivosinc.com> wrote:
> >
> > Support static branches depending on the value of misaligned accesses.
> > This will be used by a later patch in the series. All cpus must be
> > considered "fast" for this static branch to be flipped.
> >
> > Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
> > ---
> > arch/riscv/include/asm/cpufeature.h | 2 ++
> > arch/riscv/kernel/cpufeature.c | 30 ++++++++++++++++++++++++++++++
> > 2 files changed, 32 insertions(+)
> >
> > diff --git a/arch/riscv/include/asm/cpufeature.h b/arch/riscv/include/asm/cpufeature.h
> > index a418c3112cd6..7b129e5e2f07 100644
> > --- a/arch/riscv/include/asm/cpufeature.h
> > +++ b/arch/riscv/include/asm/cpufeature.h
> > @@ -133,4 +133,6 @@ static __always_inline bool riscv_cpu_has_extension_unlikely(int cpu, const unsi
> > return __riscv_isa_extension_available(hart_isa[cpu].isa, ext);
> > }
> >
> > +DECLARE_STATIC_KEY_FALSE(fast_misaligned_access_speed_key);
> > +
> > #endif
> > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
> > index b3785ffc1570..095eb6ebdcaa 100644
> > --- a/arch/riscv/kernel/cpufeature.c
> > +++ b/arch/riscv/kernel/cpufeature.c
> > @@ -10,6 +10,7 @@
> > #include <linux/bitmap.h>
> > #include <linux/cpuhotplug.h>
> > #include <linux/ctype.h>
> > +#include <linux/jump_label.h>
> > #include <linux/log2.h>
> > #include <linux/memory.h>
> > #include <linux/module.h>
> > @@ -728,6 +729,35 @@ void riscv_user_isa_enable(void)
> > csr_set(CSR_SENVCFG, ENVCFG_CBZE);
> > }
> >
> > +DEFINE_STATIC_KEY_FALSE(fast_misaligned_access_speed_key);
> > +
> > +static int set_unaligned_access_static_branches(void)
> > +{
> > + /*
> > + * This will be called after check_unaligned_access_all_cpus so the
> > + * result of unaligned access speed for all cpus will be available.
> > + */
> > +
> > + int cpu;
> > + bool fast_misaligned_access_speed = true;
> > +
> > + for_each_online_cpu(cpu) {
> Each online_cpu? Is there any offline_cpu that is no
> fast_misaligned_access_speed?
I think instead of checking offline cpus, it would make more sense to
adjust the static branch when offline cpus come online. Since
riscv_online_cpu is called when a new CPU comes online, I can update the
static branch inside of that function.
>
> Move into your riscv_online_cpu for each CPU, and use stop_machine for
> synchronization.
>
I do not understand what you mean by "Move into your riscv_online_cpu
for each CPU", but I am assuming you are referring to updating the
static branch inside of riscv_online_cpu.
I believe any race condition that could be solved by stop_machine will
become irrelevent by ensuring that the static branch is updated when a
new cpu comes online.
- Charlie
> > + int this_perf = per_cpu(misaligned_access_speed, cpu);
> > +
> > + if (this_perf != RISCV_HWPROBE_MISALIGNED_FAST) {
> > + fast_misaligned_access_speed = false;
> > + break;
> > + }
> > + }
> > +
> > + if (fast_misaligned_access_speed)
> > + static_branch_enable(&fast_misaligned_access_speed_key);
> > +
> > + return 0;
> > +}
> > +
> > +arch_initcall_sync(set_unaligned_access_static_branches);
> > +
> > #ifdef CONFIG_RISCV_ALTERNATIVE
> > /*
> > * Alternative patch sites consider 48 bits when determining when to patch
> >
> > --
> > 2.43.0
> >
> >
>
>
> --
> Best Regards
> Guo Ren
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2023-12-22 1:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-20 23:37 [PATCH v13 0/5] riscv: Add fine-tuned checksum functions Charlie Jenkins
2023-12-20 23:37 ` Charlie Jenkins
2023-12-20 23:37 ` [PATCH v13 1/5] asm-generic: Improve csum_fold Charlie Jenkins
2023-12-20 23:37 ` Charlie Jenkins
2023-12-20 23:37 ` [PATCH v13 2/5] riscv: Add static key for misaligned accesses Charlie Jenkins
2023-12-20 23:37 ` Charlie Jenkins
2023-12-21 17:53 ` Evan Green
2023-12-21 17:53 ` Evan Green
2023-12-22 0:33 ` Guo Ren
2023-12-22 0:33 ` Guo Ren
2023-12-22 1:37 ` Charlie Jenkins [this message]
2023-12-22 1:37 ` Charlie Jenkins
2023-12-22 4:43 ` Guo Ren
2023-12-22 4:43 ` Guo Ren
2023-12-20 23:37 ` [PATCH v13 3/5] riscv: Add checksum header Charlie Jenkins
2023-12-20 23:37 ` Charlie Jenkins
2023-12-20 23:37 ` [PATCH v13 4/5] riscv: Add checksum library Charlie Jenkins
2023-12-20 23:37 ` Charlie Jenkins
2023-12-20 23:37 ` [PATCH v13 5/5] kunit: Add tests for csum_ipv6_magic and ip_fast_csum Charlie Jenkins
2023-12-20 23:37 ` Charlie Jenkins
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=ZYTobxPZVNct4toQ@ghost \
--to=charlie@rivosinc.com \
--cc=David.Laight@aculab.com \
--cc=aou@eecs.berkeley.edu \
--cc=arnd@arndb.de \
--cc=conor@kernel.org \
--cc=evan@rivosinc.com \
--cc=guoren@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=samuel.holland@sifive.com \
--cc=xiao.w.wang@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.