From: Marc Zyngier <maz@kernel.org>
To: Oliver Upton <oupton@google.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Shier <pshier@google.com>,
Raghavendra Rao Ananta <rananta@google.com>,
Ricardo Koller <ricarkol@google.com>
Subject: Re: [PATCH v2] clocksource/arm_arch_timer: Fix masking for high freq counters
Date: Mon, 09 Aug 2021 11:45:16 +0100 [thread overview]
Message-ID: <87mtpqc2wz.wl-maz@kernel.org> (raw)
In-Reply-To: <CAOQ_Qsi-r0=YubmaTezB7Cq-RhzU3njWm+P5w-RWZcUz4kMfDA@mail.gmail.com>
On Sun, 08 Aug 2021 20:01:10 +0100,
Oliver Upton <oupton@google.com> wrote:
>
> On Sun, Aug 8, 2021 at 3:40 AM Marc Zyngier <maz@kernel.org> wrote:
> >
> > On Sun, 08 Aug 2021 02:14:35 +0100,
> > Oliver Upton <oupton@google.com> wrote:
> >
> > > The only other sane idea that I could come up with is providing this
> > > information to the kernel through DT, although that would leave ACPI
> > > systems behind.
> >
> > It also has the disadvantage that a large number of DT timer nodes are
> > a mess of cargo-culted, copy-pasted idioms, and that adding another
> > property would only make it worse.
>
> Agreed, this does seem like the best solution, short of the
> architecture actually providing something to determine the counter
> width.
>
> On that note, I wonder how (if ever) we will be able to move away from
> unnecessarily masking a 64 bit counter, i.e. a v8.6 or above
> implementation. With this patch, one such counter would wrap after
> 36.56 years, short of the 40 year guarantee we have from the
> architecture for < v8.6 implementations. Getting it to 64 bits would
> squarely make it someone else's problem ~585 years from now :)
Hmmm. If you end-up with something that falls short of 40 years, then
I suspect something is wrong in the way you compute the required
width.
40 years @1GHz (which we shall call FY1G from now on) fits comfortably
in 61 bits, and I fear that your use of ilog2() gives you one less bit
than what it should be:
log2(FY1G) ~= 60.13
What you are after is probably (ilog2(FY1G - 1) + 1), similar to the
way roundup_pow_of_two() works.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Oliver Upton <oupton@google.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Shier <pshier@google.com>,
Raghavendra Rao Ananta <rananta@google.com>,
Ricardo Koller <ricarkol@google.com>
Subject: Re: [PATCH v2] clocksource/arm_arch_timer: Fix masking for high freq counters
Date: Mon, 09 Aug 2021 11:45:16 +0100 [thread overview]
Message-ID: <87mtpqc2wz.wl-maz@kernel.org> (raw)
In-Reply-To: <CAOQ_Qsi-r0=YubmaTezB7Cq-RhzU3njWm+P5w-RWZcUz4kMfDA@mail.gmail.com>
On Sun, 08 Aug 2021 20:01:10 +0100,
Oliver Upton <oupton@google.com> wrote:
>
> On Sun, Aug 8, 2021 at 3:40 AM Marc Zyngier <maz@kernel.org> wrote:
> >
> > On Sun, 08 Aug 2021 02:14:35 +0100,
> > Oliver Upton <oupton@google.com> wrote:
> >
> > > The only other sane idea that I could come up with is providing this
> > > information to the kernel through DT, although that would leave ACPI
> > > systems behind.
> >
> > It also has the disadvantage that a large number of DT timer nodes are
> > a mess of cargo-culted, copy-pasted idioms, and that adding another
> > property would only make it worse.
>
> Agreed, this does seem like the best solution, short of the
> architecture actually providing something to determine the counter
> width.
>
> On that note, I wonder how (if ever) we will be able to move away from
> unnecessarily masking a 64 bit counter, i.e. a v8.6 or above
> implementation. With this patch, one such counter would wrap after
> 36.56 years, short of the 40 year guarantee we have from the
> architecture for < v8.6 implementations. Getting it to 64 bits would
> squarely make it someone else's problem ~585 years from now :)
Hmmm. If you end-up with something that falls short of 40 years, then
I suspect something is wrong in the way you compute the required
width.
40 years @1GHz (which we shall call FY1G from now on) fits comfortably
in 61 bits, and I fear that your use of ilog2() gives you one less bit
than what it should be:
log2(FY1G) ~= 60.13
What you are after is probably (ilog2(FY1G - 1) + 1), similar to the
way roundup_pow_of_two() works.
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2021-08-09 10:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-07 19:14 [PATCH v2] clocksource/arm_arch_timer: Fix masking for high freq counters Oliver Upton
2021-08-07 19:14 ` Oliver Upton
2021-08-07 22:30 ` Linus Walleij
2021-08-07 22:30 ` Linus Walleij
2021-08-08 1:14 ` Oliver Upton
2021-08-08 1:14 ` Oliver Upton
2021-08-08 10:40 ` Marc Zyngier
2021-08-08 10:40 ` Marc Zyngier
2021-08-08 19:01 ` Oliver Upton
2021-08-08 19:01 ` Oliver Upton
2021-08-09 10:45 ` Marc Zyngier [this message]
2021-08-09 10:45 ` Marc Zyngier
2021-08-09 15:08 ` Oliver Upton
2021-08-09 15:08 ` Oliver Upton
2021-08-08 10:29 ` Marc Zyngier
2021-08-08 10:29 ` Marc Zyngier
2021-08-09 11:07 ` Marc Zyngier
2021-08-09 11:07 ` Marc Zyngier
2021-10-24 15:39 ` [tip: timers/core] clocksource/drivers/arm_arch_timer: " tip-bot2 for Oliver Upton
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=87mtpqc2wz.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=oupton@google.com \
--cc=pshier@google.com \
--cc=rananta@google.com \
--cc=ricarkol@google.com \
--cc=tglx@linutronix.de \
/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.