From: Conor Dooley <conor@kernel.org>
To: Evan Green <evan@rivosinc.com>
Cc: Atish Patra <atishp@atishpatra.org>,
Anup Patel <apatel@ventanamicro.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Heiko Stuebner <heiko@sntech.de>, Marc Zyngier <maz@kernel.org>,
linux-kernel@vger.kernel.org,
Palmer Dabbelt <palmer@rivosinc.com>,
Conor Dooley <conor.dooley@microchip.com>,
David Laight <David.Laight@aculab.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Jisheng Zhang <jszhang@kernel.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Greentime Hu <greentime.hu@sifive.com>,
linux-riscv@lists.infradead.org,
Andrew Jones <ajones@ventanamicro.com>
Subject: Re: [PATCH v2] RISC-V: Probe misaligned access speed in parallel
Date: Wed, 20 Sep 2023 23:25:02 +0100 [thread overview]
Message-ID: <20230920-0e2bce9821557cce8d022157@fedora> (raw)
In-Reply-To: <CALs-HsuurXBZ2p=jYKvPq6ZMScugm5rBchttD6Wv9Mtupfx3NQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4990 bytes --]
On Wed, Sep 20, 2023 at 03:06:45PM -0700, Evan Green wrote:
> On Wed, Sep 20, 2023 at 2:27 PM Atish Patra <atishp@atishpatra.org> wrote:
> >
> > On Wed, Sep 20, 2023 at 2:04 PM Conor Dooley <conor@kernel.org> wrote:
> > >
> > > Yo,
> > >
> > > On Wed, Sep 20, 2023 at 12:38:01PM -0700, Evan Green wrote:
> > > > Probing for misaligned access speed takes about 0.06 seconds. On a
> > > > system with 64 cores, doing this in smp_callin() means it's done
> > > > serially, extending boot time by 3.8 seconds. That's a lot of boot time.
> > > >
> > > > Instead of measuring each CPU serially, let's do the measurements on
> > > > all CPUs in parallel. If we disable preemption on all CPUs, the
> > > > jiffies stop ticking, so we can do this in stages of 1) everybody
> > > > except core 0, then 2) core 0.
> > > >
> > > > The measurement call in smp_callin() stays around, but is now
> > > > conditionalized to only run if a new CPU shows up after the round of
> > > > in-parallel measurements has run. The goal is to have the measurement
> > > > call not run during boot or suspend/resume, but only on a hotplug
> > > > addition.
> > > >
> > > > Reported-by: Jisheng Zhang <jszhang@kernel.org>
> > > > Closes: https://lore.kernel.org/all/mhng-9359993d-6872-4134-83ce-c97debe1cf9a@palmer-ri-x1c9/T/#mae9b8f40016f9df428829d33360144dc5026bcbf
> > > > Fixes: 584ea6564bca ("RISC-V: Probe for unaligned access speed")
> > > > Signed-off-by: Evan Green <evan@rivosinc.com>
> > > > Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> > > > Tested-by: Andrew Jones <ajones@ventanamicro.com>
> > > >
> > > > ---
> > > >
> > > > Changes in v2:
> > > > - Removed new global, used system_state == SYSTEM_RUNNING instead
> > > > (Jisheng)
> > > > - Added tags
> > > >
> > > > arch/riscv/include/asm/cpufeature.h | 2 +-
> > > > arch/riscv/kernel/cpufeature.c | 22 +++++++++++++++++-----
> > > > arch/riscv/kernel/smpboot.c | 11 ++++++++++-
> > > > 3 files changed, 28 insertions(+), 7 deletions(-)
> > > >
> > > > diff --git a/arch/riscv/include/asm/cpufeature.h b/arch/riscv/include/asm/cpufeature.h
> > > > index d0345bd659c9..b139796392d0 100644
> > > > --- a/arch/riscv/include/asm/cpufeature.h
> > > > +++ b/arch/riscv/include/asm/cpufeature.h
> > > > @@ -30,6 +30,6 @@ DECLARE_PER_CPU(long, misaligned_access_speed);
> > > > /* Per-cpu ISA extensions. */
> > > > extern struct riscv_isainfo hart_isa[NR_CPUS];
> > > >
> > > > -void check_unaligned_access(int cpu);
> > > > +int check_unaligned_access(void *unused);
> > > >
> > > > #endif
> > > > diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
> > > > index 1cfbba65d11a..40bb854fcb96 100644
> > > > --- a/arch/riscv/kernel/cpufeature.c
> > > > +++ b/arch/riscv/kernel/cpufeature.c
> > > > @@ -556,8 +556,9 @@ unsigned long riscv_get_elf_hwcap(void)
> > > > return hwcap;
> > > > }
> > > >
> > > > -void check_unaligned_access(int cpu)
> > > > +int check_unaligned_access(void *unused)
> > > > {
> > > > + int cpu = smp_processor_id();
> > > > u64 start_cycles, end_cycles;
> > > > u64 word_cycles;
> > > > u64 byte_cycles;
> > > > @@ -571,7 +572,7 @@ void check_unaligned_access(int cpu)
> > > > page = alloc_pages(GFP_NOWAIT, get_order(MISALIGNED_BUFFER_SIZE));
> > > > if (!page) {
> > > > pr_warn("Can't alloc pages to measure memcpy performance");
> > > > - return;
> > > > + return 0;
> > >
> > > Dumb question maybe, but I am limited setup wise at the moment due to
> > > a hardware failure which makes checking stuff hard, why the signature
> > > change? Requirement for on_each_cpu()?
> > >
> >
> > Requirement for smp_call_on_cpu.
>
> Right.
>
> >
> > > > }
> > > >
> > > > /* Make an unaligned destination buffer. */
> > > > @@ -643,15 +644,26 @@ void check_unaligned_access(int cpu)
> > > >
> > > > out:
> > > > __free_pages(page, get_order(MISALIGNED_BUFFER_SIZE));
> > > > + return 0;
> > > > +}
> > > > +
> > > > +static void check_unaligned_access_nonboot_cpu(void *param)
> > > > +{
> > > > + if (smp_processor_id() != 0)
> > > > + check_unaligned_access(param);
> > > > }
> > > >
> > > > -static int check_unaligned_access_boot_cpu(void)
> > > > +static int check_unaligned_access_all_cpus(void)
> > > > {
> > > > - check_unaligned_access(0);
> > > > + /* Check everybody except 0, who stays behind to tend jiffies. */
> > > > + on_each_cpu(check_unaligned_access_nonboot_cpu, NULL, 1);
> > > > +
> > > > + /* Check core 0. */
> > > > + smp_call_on_cpu(0, check_unaligned_access, NULL, true);
> > > > return 0;
> > >
> > > Why does this function return an int if it can only return 0?
> > >
>
> This is a requirement on the initcall_t function pointer type.
Ahh great, thanks for the explanations!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2023-09-20 22:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 19:38 [PATCH v2] RISC-V: Probe misaligned access speed in parallel Evan Green
2023-09-20 21:03 ` Conor Dooley
2023-09-20 21:27 ` Atish Patra
2023-09-20 22:06 ` Evan Green
2023-09-20 22:25 ` Conor Dooley [this message]
2023-09-29 11:19 ` Conor Dooley
2023-09-20 22:57 ` Atish Patra
2023-09-20 23:54 ` Evan Green
2023-09-21 10:22 ` David Laight
2023-09-21 16:44 ` Evan Green
2023-09-21 16:49 ` Evan Green
2023-09-21 2:41 ` Jisheng Zhang
2023-11-02 20:20 ` patchwork-bot+linux-riscv
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=20230920-0e2bce9821557cce8d022157@fedora \
--to=conor@kernel.org \
--cc=David.Laight@aculab.com \
--cc=ajones@ventanamicro.com \
--cc=aou@eecs.berkeley.edu \
--cc=apatel@ventanamicro.com \
--cc=atishp@atishpatra.org \
--cc=conor.dooley@microchip.com \
--cc=evan@rivosinc.com \
--cc=greentime.hu@sifive.com \
--cc=heiko@sntech.de \
--cc=jszhang@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=maz@kernel.org \
--cc=palmer@dabbelt.com \
--cc=palmer@rivosinc.com \
--cc=paul.walmsley@sifive.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox