All of lore.kernel.org
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Marc Zyngier <maz@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, arnd@arndb.de,
	kernel-team@meta.com, vincenzo.frascino@arm.com,
	anders.roxell@linaro.org, ndecarli@meta.com, rmikey@meta.com
Subject: Re: [PATCH RFC] arm64: vdso: Use __arch_counter_get_cntvct()
Date: Fri, 4 Apr 2025 06:36:18 -0700	[thread overview]
Message-ID: <Z+/gUiv5gCuc7JfK@gmail.com> (raw)
In-Reply-To: <871pu9yvlb.wl-maz@kernel.org>

Hello Marc,

On Thu, Apr 03, 2025 at 06:59:44PM +0100, Marc Zyngier wrote:
> On Thu, 03 Apr 2025 13:14:49 +0100,
> Breno Leitao <leitao@debian.org> wrote:
> > 
> > Since you created *all* this noise regarding instruction ordering, can
> > I pick your brain in the same topic? :-P
> > 
> > If my machine has Speculation Barrier (sb)[1] support, is it a good
> > replacement for `isb` ? Do you happen to know?
> 
> Probably not. SB prevent speculation past it, while ISB is here to
> enforce ordering. We're pretty happy to let the CPU speculate the
> counter, as long as it does it the order we have defined.

I understand `isb` kills any speculation very badly today, given it
flushes the pipeline completely. That might be reason that replacing
`isb` by `sb` makes the operation 20%.

iThis is what the `isb` manual[1] says:

 > An ISB flushes the pipeline and ensures that the effects of any
 > completed context-changing operation before the ISB are visible to
 > any instruction after the ISB

[1] https://developer.arm.com/documentation/100941/0101/Barriers

> On some implementation, this can be have a similar effect (drain the
> fetch queue, restart). But the intent clearly isn't the same, and some
> implementations may do things differently.

Let me back-up to `isb` purpose in such case (before reading CNTVCT_EL0).

From my understand, it severs two propositions:

1) Make sure that the code after the `mrs CNTVCT_EL0` is not executed
   out-of-order before the read
 
2) Code that comes before the the CNTVCT_EL0 read retires before the
   read.

If I understand what `sb` does, it only protects against 1) but not 2).
Is this the right way to understand it?

Thanks for you time,
--breno


      reply	other threads:[~2025-04-04 13:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-02 19:22 [PATCH RFC] arm64: vdso: Use __arch_counter_get_cntvct() Breno Leitao
2025-04-02 22:04 ` Marc Zyngier
2025-04-02 22:22   ` Marc Zyngier
2025-04-03 12:14     ` Breno Leitao
2025-04-03 17:59       ` Marc Zyngier
2025-04-04 13:36         ` Breno Leitao [this message]

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=Z+/gUiv5gCuc7JfK@gmail.com \
    --to=leitao@debian.org \
    --cc=anders.roxell@linaro.org \
    --cc=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --cc=kernel-team@meta.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=ndecarli@meta.com \
    --cc=rmikey@meta.com \
    --cc=vincenzo.frascino@arm.com \
    --cc=will@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 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.