Re: [PATCH v3 7/8] clocksource/drivers/arm_arch_timer: Expose a direct accessor for the virtual counter
From: Marc Zyngier
Date: Tue Sep 29 2026 - 10:57:03 EST
On Tue, 29 Sep 2026 15:35:16 +0100,
Will Deacon <will@xxxxxxxxxx> wrote:
>
> On Tue, Sep 29, 2026 at 03:28:47PM +0100, Marc Zyngier wrote:
> > On Tue, 29 Sep 2026 13:55:30 +0100,
> > Will Deacon <will@xxxxxxxxxx> wrote:
> > >
> > > On Sun, Aug 02, 2026 at 05:53:26PM +0100, Marc Zyngier wrote:
> > > > We allow access to the architected counter via arch_timer_read_counter().
> > > > However, this accessor can either be the virtual or the physical
> > > > view of the counter, depending on how the kernel has been booted.
> > > >
> > > > At the same time, we have some architectural features (such as WFIT,
> > > > WFET) that rely on the virtual counter, and nothing else.
> > > >
> > > > If implementations were perfect, we'd rely on reading CNTVCT_EL0,
> > > > and be done with it. However, we have a bunch of broken implementations
> > > > in the wild, which rely on preemption being disabled and other
> > > > costly workarounds.
> > > >
> > > > In order to provide decent performance on non-broken HW while still
> > > > supporting the legacy horrors, expose arch_timer_read_vcounter() as
> > > > a new helper that hides this complexity. Obviously, this is simply
> > > > a global alias of arch_counter_get_cntvct().
> > > >
> > > > Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx>
> > > > ---
> > > > drivers/clocksource/arm_arch_timer.c | 2 ++
> > > > include/clocksource/arm_arch_timer.h | 1 +
> > > > 2 files changed, 3 insertions(+)
> > > >
> > > > diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> > > > index b3b31d4f4815f..9c7501ce57073 100644
> > > > --- a/drivers/clocksource/arm_arch_timer.c
> > > > +++ b/drivers/clocksource/arm_arch_timer.c
> > > > @@ -128,6 +128,8 @@ static notrace u64 arch_counter_get_cntvct(void)
> > > > return __arch_counter_get_cntvct();
> > > > }
> > > >
> > > > +u64 arch_timer_read_vcounter(void) __attribute__((alias("arch_counter_get_cntvct")));
> > >
> > > nit: compiler-attributes.h provides __alias to make this a tiny bit cleaner.
> > >
> > > That said, why did you decide on the alias rather than just having this
> > > as a wrapper function?
> >
> > No idea. Laziness, probably.
> >
> > But I've paged most of this stuff out, and I'm not sure it even serves
> > a purpose, given that we've lived for about a decade with the problem
> > it tries to solve.
> >
> > Consider it an abandoned series.
>
> Ok, but patch one is probably worth taking to fix the PMU issue, no?
Yes, I think it is still relevant.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.