From: Peter Xu <peterx@redhat.com>
To: nsaenzju@redhat.com
Cc: linux-rt-users@vger.kernel.org, williams@redhat.com, jkacur@redhat.com
Subject: Re: [PATCH 2/3] oslat: Add aarch64 support
Date: Thu, 9 Sep 2021 14:03:39 -0400 [thread overview]
Message-ID: <YTpMe2+58YxJ0IFM@t490s> (raw)
In-Reply-To: <466f7d726df2dfec8ac83a9d3f603439e3cec1b1.camel@redhat.com>
On Thu, Sep 09, 2021 at 12:10:49PM +0200, nsaenzju@redhat.com wrote:
> On Wed, 2021-09-08 at 14:09 -0400, Peter Xu wrote:
> > On Wed, Sep 08, 2021 at 12:02:08PM +0200, Nicolas Saenz Julienne wrote:
> > > The callbacks are based on Linux's implementation:
> > > - CNTVCT_EL0 provides direct access to the system virtual timer[1].
> > > - 'yield' serves as a CPU hint with similar semantics as x86's
> > > 'pause'[2].
> > >
> > > [1] See Linux's '__arch_get_hw_counter()' in arch/arm64/include/asm/vdso/gettimeofday.h
> > > [2] See Linux's 1baa82f4803 ("arm64: Implement cpu_relax as yield").
> > > Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
> > > ---
> > > src/oslat/oslat.c | 13 +++++++++++++
> > > 1 file changed, 13 insertions(+)
> > >
> > > diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
> > > index a4aa5f1..bd155a6 100644
> > > --- a/src/oslat/oslat.c
> > > +++ b/src/oslat/oslat.c
> > > @@ -71,6 +71,19 @@ static inline void frc(uint64_t *pval)
> > > {
> > > __asm__ __volatile__("mfspr %0, 268\n" : "=r" (*pval));
> > > }
> > > +# elif defined(__aarch64__)
> > > +# define relax() __asm__ __volatile("yield" : : : "memory")
> > > +
> > > +static inline void frc(uint64_t *pval)
> > > +{
> > > +
> >
> > newline to drop?
>
> Noted.
>
> > > + /*
> > > + * This isb() is required to prevent that the counter value
> > > + * is speculated.
> > > + */
> > > + __asm__ __volatile__("isb; mrs %0, cntvct_el0" : "=r" (*pval));
> >
> > I saw that commit 27e11a9fe2e2e added two isbs, one before, one after. Then
> > commit 77ec462536a1 replaced the 2nd isb into another magic. This function
> > dropped the 2nd barrier. Also, the same to compiler barrier "memory" that's
> > gone too.
> >
> > Is it on purpose to drop them?
>
> Yes, I removed it on purpose. VDSO's gettimeofday implementation uses a seqlock
> to protect against changes to the counter's properties/state: you want to make
> sure access to the counter register is ordered WRT access to the seqlock
> protecting it. We don't really care for all this, as we trust our counters to
> be stable.
OK, since you've referenced the code, would you mind add these into the commit
message too?
I also don't understand why you explicitly removed the compiler barrier. IIUC
when without it the compiler could move these instructions to be before/after
other instructions generated in the c code. That may not really happen in
practise, but just curious why the explicit removal.
--
Peter Xu
next prev parent reply other threads:[~2021-09-09 18:03 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-08 10:02 [PATCH 1/3] oslat: rename cpu_mhz/cpu_hz to timer_mhz/cpu_hz Nicolas Saenz Julienne
2021-09-08 10:02 ` [PATCH 2/3] oslat: Add aarch64 support Nicolas Saenz Julienne
2021-09-08 18:09 ` Peter Xu
2021-09-09 10:10 ` nsaenzju
2021-09-09 18:03 ` Peter Xu [this message]
2021-09-10 12:19 ` nsaenzju
2021-09-10 13:33 ` Peter Xu
2021-09-10 14:27 ` nsaenzju
2021-09-10 17:00 ` Peter Xu
2021-09-08 10:02 ` [PATCH 3/3] oslat: Allow for arch specific timer frequency measurements Nicolas Saenz Julienne
2021-09-08 18:16 ` Peter Xu
2021-09-09 10:29 ` nsaenzju
2021-09-09 18:04 ` Peter Xu
2021-09-08 14:40 ` [PATCH 1/3] oslat: rename cpu_mhz/cpu_hz to timer_mhz/cpu_hz Peter Xu
2021-09-08 16:30 ` nsaenzju
2021-09-08 17:51 ` Peter Xu
2021-09-09 9:41 ` nsaenzju
2021-09-09 18:05 ` Peter Xu
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=YTpMe2+58YxJ0IFM@t490s \
--to=peterx@redhat.com \
--cc=jkacur@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=nsaenzju@redhat.com \
--cc=williams@redhat.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