Subject: Re: Does clocksource arch_sys_counter synchronize across CPUs?

From: Marc Zyngier <[email-masked]>
Date: Mon, 10 Jan 2022 17:30:55 +0000

On Mon, 10 Jan 2022 16:51:14 +0000,
Huichun Feng <[email-masked]> wrote:
> 
> Hi list,
> 
> AFAIK, one of the clocksource in arm64 (armv8.3, Rpi4) --

RPI4 is ARMv8.0 (not that it matters here).

> arch_sys_counter, uses a per-core register CNTVCT as the accessor.
> 
> And comes to consistency of CNTVCT's, after searching some of the
> related manuals [0-2], I didn't find statements saying that it is
> synchronize across CPUs. However, I've found a recent patch [3] says
> that CNTVCT is synchronized in armv8.6.
> 
> So, does CNTVCT synchronize across CPUs in armv8.3?

CNTVCT_EL0 is guaranteed to be identical across CPUs as long as
CNTVOFF_EL2 is identical across CPUs. That's because all the CPUs
source their counters from the same source (see the architecture spec
in section D11 for the details).

The patch you mention makes use of the *self-synchronisation* feature
of the CNTVCTSS_EL0 instruction. which guarantees that the instruction
won't be reordered wrt to other instructions in the stream, avoiding
the use of an ISB instruction. Nothing to do with cross-CPU
synchronisation, which has always been guaranteed (there are broken
system integrations though).

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
[email-masked]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel