mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Feng Tang <feng.tang@linux.alibaba.com>
Cc: Thomas Gleixner <tglx@kernel.org>,
	John Stultz <jstultz@google.com>, Stephen Boyd <sboyd@kernel.org>,
	Miroslav Lichvar <mlichvar@redhat.com>,
	Daniel Lezcano <daniel.lezcano@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Petr Mladek <pmladek@suse.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched_clock: Add option to use absolute time against hardware clock reset
Date: Mon, 07 Sep 2026 10:37:03 +0100	[thread overview]
Message-ID: <86h5k14d34.wl-maz@kernel.org> (raw)
In-Reply-To: <ap5-ZM-2RMih3iQ7@U-2FWC9VHC-2323.local>

On Mon, 07 Sep 2026 10:05:40 +0100,
Feng Tang <feng.tang@linux.alibaba.com> wrote:
> 
> On Sat, Sep 05, 2026 at 10:39:26PM +0200, Thomas Gleixner wrote:
> > On Wed, Sep 02 2026 at 16:21, Feng Tang wrote:
> > > Locally, it did help on chasing some RAS issues which needed cooperation
> > > between kernel, SCP firmware and ATF, by mapping the actions from each
> > > players into one timeline based on the timestamps in their logs.
> > 
> > I told you before that we don't care about your bug chasing war stories
> > at all. Educate your firmware people and stop pestering us with your
> > firmware debug hacks.
> 
> Hi Thomas,
> 
> Yes, this patch is hacky.
> 
> From the reply of Marc in this thread:
> 
> "
> I really have to ask: why isn't this just a one-off sampling of the
> counter, kept in some user accessible location (debugfs or something
> else), and ultimately post-processed to align your logs? People have
> been doing this... forever, and that has been "good enough" so far.
> "
> 
> IIUC, getting an absolute timestamp for logs is still practical in some
> cases. How about adding the offset-since-reset info into the message
> like Marc suggested:
> 
> ---
> diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
> index f3aaef695b8c..d5a54276b49d 100644
> --- a/kernel/time/sched_clock.c
> +++ b/kernel/time/sched_clock.c
> @@ -176,7 +176,7 @@ static enum hrtimer_restart sched_clock_poll(struct hrtimer *hrt)
>  
>  void sched_clock_register(u64 (*read)(void), int bits, unsigned long rate)
>  {
> -	u64 res, wrap, new_mask, new_epoch, cyc, ns;
> +	u64 res, wrap, new_mask, new_epoch, cyc, ns, reset_ns;
>  	u32 new_mult, new_shift;
>  	unsigned long r, flags;
>  	char r_unit;
> @@ -235,8 +235,11 @@ void sched_clock_register(u64 (*read)(void), int bits, unsigned long rate)
>  	/* Calculate the ns resolution of this counter */
>  	res = cyc_to_ns(1ULL, new_mult, new_shift);
>  
> -	pr_info("sched_clock: %u bits at %lu%cHz, resolution %lluns, wraps every %lluns\n",
> -		bits, r, r_unit, res, wrap);
> +	/* Calculate the time since last counter resetting to 0 */
> +	reset_ns = mul_u64_u64_div_u64(new_epoch, NSEC_PER_SEC, rate);
> +
> +	pr_info("sched_clock: %u bits at %lu%cHz, resolution %lluns, wraps every %lluns, has run %lluns since counter reset\n",
> +		bits, r, r_unit, res, wrap, reset_ns);
>  
>  	/* Enable IRQ time accounting if we have a fast enough sched_clock() */
>  	if (irqtime > 0 || (irqtime == -1 && rate >= 1000000))
> 

Which is what people have done locally since the beginning of times.
And the only time this is actually useful is when bringing up new
HW/FW that is broken.

So why the need to put that in an upstream kernel, instead of being as
part of your debug toolbox? I don't think the kernel shouldn't be the
recipient of this sort of stuff.

	M.

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

  reply	other threads:[~2026-09-07  9:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02  8:21 Feng Tang
2026-09-02 15:32 ` Marc Zyngier
2026-09-03  6:51   ` Yao Yuan
2026-09-03  7:38     ` Marc Zyngier
2026-09-03  8:07       ` Feng Tang
2026-09-03 10:20       ` Yao Yuan
2026-09-03  7:45   ` Feng Tang
2026-09-05 20:39 ` Thomas Gleixner
2026-09-07  9:05   ` Feng Tang
2026-09-07  9:37     ` Marc Zyngier [this message]
2026-09-07 10:57       ` Feng Tang

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=86h5k14d34.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=daniel.lezcano@kernel.org \
    --cc=feng.tang@linux.alibaba.com \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=sboyd@kernel.org \
    --cc=tglx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®