mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, hpa@zytor.com, rostedt@goodmis.org,
	kernel-dev@igalia.com, kernel@gpiccoli.net,
	stable@vger.kernel.org,
	Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Subject: Re: [PATCH] x86/tsc: Always save/restore TSC sched_clock on suspend/resume
Date: Mon, 17 Feb 2025 15:49:13 -0300	[thread overview]
Message-ID: <3bcf3eac-555c-6f30-8e32-b8c39967eefe@igalia.com> (raw)
In-Reply-To: <20250215210314.351480-1-gpiccoli@igalia.com>

On 15/02/2025 17:58, Guilherme G. Piccoli wrote:
> TSC could be reset in deep ACPI sleep states, even with invariant TSC.
> That's the reason we have sched_clock() save/restore functions, to deal
> with this situation. But happens that such functions are guarded with a
> check for the stability of sched_clock - if not considered stable, the
> save/restore routines aren't executed.
> 
> On top of that, we have a clear comment on native_sched_clock() saying
> that *even* with TSC unstable, we continue using TSC for sched_clock due
> to its speed. In other words, if we have a situation of TSC getting
> detected as unstable, it marks the sched_clock as unstable as well,
> so subsequent S3 sleep cycles could bring bogus sched_clock values due
> to the lack of the save/restore mechanism, causing warnings like this:
> 
> [22.954918] ------------[ cut here ]------------
> [22.954923] Delta way too big! 18446743750843854390 ts=18446744072977390405 before=322133536015 after=322133536015 write stamp=18446744072977390405
> [22.954923] If you just came from a suspend/resume,
> [22.954923] please switch to the trace global clock:
> [22.954923]   echo global > /sys/kernel/tracing/trace_clock
> [22.954923] or add trace_clock=global to the kernel command line
> [22.954937] WARNING: CPU: 2 PID: 5728 at kernel/trace/ring_buffer.c:2890 rb_add_timestamp+0x193/0x1c0
> 
> Notice that the above was reproduced even with "trace_clock=global".
> 
> The fix for that is to _always_ save/restore the sched_clock on suspend
> cycle _if TSC is used_ as sched_clock - only if we fallback to jiffies
> the sched_clock_stable() check becomes relevant to save/restore the
> sched_clock.
> 

Hi folks, I would like to ask if possible to add the following tag:

Debugged-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>

Cascardo helped me a lot on debugging this issue but I forgot to add it
earlier, so nothing more fair than add it now!

Thanks,


Guilherme

> Cc: stable@vger.kernel.org
> Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
> [...]

  reply	other threads:[~2025-02-17 18:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-15 20:58 Guilherme G. Piccoli
2025-02-17 18:49 ` Guilherme G. Piccoli [this message]
2025-02-21 14:37 ` [tip: sched/core] x86/tsc: Always save/restore TSC sched_clock() " tip-bot2 for Guilherme G. Piccoli
2025-02-21 19:17   ` Peter Zijlstra

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=3bcf3eac-555c-6f30-8e32-b8c39967eefe@igalia.com \
    --to=gpiccoli@igalia.com \
    --cc=bp@alien8.de \
    --cc=cascardo@igalia.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kernel-dev@igalia.com \
    --cc=kernel@gpiccoli.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@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®