From: David Laight <David.Laight@ACULAB.COM>
To: 'Evan Green' <evan@rivosinc.com>
Cc: Jessica Clarke <jrtc27@jrtc27.com>,
Palmer Dabbelt <palmer@rivosinc.com>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
Yangyu Chen <cyy@cyyself.name>,
Conor Dooley <conor.dooley@microchip.com>,
Guo Ren <guoren@kernel.org>, Jisheng Zhang <jszhang@kernel.org>,
linux-riscv <linux-riscv@lists.infradead.org>,
Jonathan Corbet <corbet@lwn.net>,
"Xianting Tian" <xianting.tian@linux.alibaba.com>,
Masahiro Yamada <masahiroy@kernel.org>,
Greentime Hu <greentime.hu@sifive.com>,
Simon Hosie <shosie@rivosinc.com>,
Li Zhengyu <lizhengyu3@huawei.com>,
Andrew Jones <ajones@ventanamicro.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alexghiti@rivosinc.com>,
Ley Foon Tan <leyfoon.tan@starfivetech.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
Heiko Stuebner <heiko.stuebner@vrull.eu>,
Anup Patel <apatel@ventanamicro.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Sia Jee Heng <jeeheng.sia@starfivetech.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
"Andy Chiu" <andy.chiu@sifive.com>
Subject: RE: [PATCH 1/2] RISC-V: Probe for unaligned access speed
Date: Fri, 30 Jun 2023 08:29:42 +0000 [thread overview]
Message-ID: <b9a23f8947014fdbb625d67134ed796d@AcuMS.aculab.com> (raw)
In-Reply-To: <CALs-HstgcnK=prSHm9D7bqWc05q52ObA5kozmxzr-euR=CFfKw@mail.gmail.com>
...
> Yeah, one thing I could do is disable interrupts, measure the cycle
> count of doing an individual iteration, do this N times, and take the
> minimum value as the time to compare. In the end I'll then have two
> numbers to compare, like I do in this patch. In theory the variance on
> that should be really tight. N will have to depend on the overall
> amount of time I'm taking so as not to shut interrupts off for very
> long. Let me experiment with this and see how the results look.
> -Evan
I doubt you'll need many iterations or a long test.
You can do tests in userspace without disabling pre-emption
or interrupts - the large/silly values they generate are
easily ignored.
I suspect you'll get enough info from something like:
unsigned long x[2];
volatile unsigned long *p = (void *)((unsigned char *)x + 1);
full_cpu_barrier()
start = rdtsc();
full_cpu_barrier();
*p; *p; *p; *p; *p; *p; *p; *p;
*p; *p; *p; *p; *p; *p; *p; *p;
full_cpu_barrier()
elapsed = rdtsc() - start;
Once the i-cache is loaded it should be pretty constant.
For aligned addresses I'd expect each extra '*p' to be
one more clock.
With hardware support for misaligned transfers at most
2 clocks (test on x86 and it will be 1 clock).
The emulated version will be 100s or 1000s.
I'm not sure how much of a cpu barrier you need.
Definitely needs to wait for all memory accesses
and the rdtsc().
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2023-06-30 8:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 22:20 [PATCH 0/2] RISC-V: Probe for misaligned " Evan Green
2023-06-23 22:20 ` [PATCH 1/2] RISC-V: Probe for unaligned " Evan Green
2023-06-25 21:42 ` David Laight
2023-06-26 14:14 ` Conor Dooley
2023-06-27 19:11 ` Evan Green
2023-06-29 14:03 ` Conor Dooley
2023-06-29 23:10 ` Evan Green
2023-06-26 21:42 ` Jessica Clarke
2023-06-27 19:11 ` Evan Green
2023-06-29 12:05 ` David Laight
2023-06-29 23:09 ` Evan Green
2023-06-30 8:29 ` David Laight [this message]
2023-06-23 22:20 ` [PATCH 2/2] RISC-V: alternative: Remove feature_probe_func Evan Green
2023-06-26 13:07 ` Conor Dooley
2023-06-30 21:57 ` Evan Green
2023-06-24 10:08 ` [PATCH 0/2] RISC-V: Probe for misaligned access speed Conor Dooley
2023-06-26 19:48 ` Evan Green
2023-06-24 10:22 ` Yangyu Chen
2023-06-26 9:24 ` David Laight
2023-06-26 19:49 ` Evan Green
2023-06-26 19:48 ` Evan Green
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=b9a23f8947014fdbb625d67134ed796d@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=ajones@ventanamicro.com \
--cc=alexghiti@rivosinc.com \
--cc=andy.chiu@sifive.com \
--cc=aou@eecs.berkeley.edu \
--cc=apatel@ventanamicro.com \
--cc=conor.dooley@microchip.com \
--cc=corbet@lwn.net \
--cc=cyy@cyyself.name \
--cc=evan@rivosinc.com \
--cc=greentime.hu@sifive.com \
--cc=guoren@kernel.org \
--cc=heiko.stuebner@vrull.eu \
--cc=jeeheng.sia@starfivetech.com \
--cc=jrtc27@jrtc27.com \
--cc=jszhang@kernel.org \
--cc=leyfoon.tan@starfivetech.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=lizhengyu3@huawei.com \
--cc=masahiroy@kernel.org \
--cc=palmer@dabbelt.com \
--cc=palmer@rivosinc.com \
--cc=paul.walmsley@sifive.com \
--cc=shosie@rivosinc.com \
--cc=xianting.tian@linux.alibaba.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
all inboxes | Powered by JetHome®