From: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, hpa@zytor.com, kernel@gpiccoli.net,
kernel-dev@igalia.com,
"Guilherme G. Piccoli" <gpiccoli@igalia.com>
Subject: [PATCH] x86/tsc: Add debugfs entry to mark TSC as unstable after boot
Date: Wed, 26 Feb 2025 10:27:13 -0300 [thread overview]
Message-ID: <20250226132733.58327-1-gpiccoli@igalia.com> (raw)
Right now, we can force the TSC to be marked as unstable through
boot parameter. There are debug / test cases though in which would
be preferable to simulate the clocksource watchdog behavior, i.e.,
marking TSC as unstable during the system run. Some paths might
change, for example: the tracing clock is auto switched to global
if TSC is marked as unstable on boot, but it could remain local if
TSC gets marked as unstable after tracing initialization.
Hence, the proposal here is to have a simple debugfs file that
gets TSC marked as unstable when written.
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
---
arch/x86/kernel/tsc.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 88e5a4ed9db3..6bce5f3a2848 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -9,6 +9,7 @@
#include <linux/timer.h>
#include <linux/acpi_pmtmr.h>
#include <linux/cpufreq.h>
+#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/clocksource.h>
#include <linux/percpu.h>
@@ -1602,3 +1603,24 @@ unsigned long calibrate_delay_is_known(void)
return 0;
}
#endif
+
+#ifdef CONFIG_DEBUG_FS
+static ssize_t tsc_debugfs_write(struct file *f, const char __user *ubuf,
+ size_t count, loff_t *ppos)
+{
+ mark_tsc_unstable("debugfs write");
+ return count;
+}
+
+static const struct file_operations tsc_debugfs_fops = {
+ .write = tsc_debugfs_write,
+};
+
+static __init int tsc_debugfs_init(void)
+{
+ debugfs_create_file("mark_tsc_unstable", 0200, /* write only */
+ arch_debugfs_dir, NULL, &tsc_debugfs_fops);
+ return 0;
+}
+late_initcall(tsc_debugfs_init);
+#endif /* CONFIG_DEBUG_FS */
--
2.48.1
next reply other threads:[~2025-02-26 13:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 13:27 Guilherme G. Piccoli [this message]
2025-03-17 14:35 ` Guilherme G. Piccoli
2025-03-17 18:42 ` H. Peter Anvin
2025-03-21 19:26 ` Guilherme G. Piccoli
2025-03-21 21:19 ` Thomas Gleixner
2025-03-23 17:53 ` Guilherme G. Piccoli
2025-03-23 18:14 ` Borislav Petkov
2025-03-23 19:21 ` Guilherme G. Piccoli
2025-03-23 19:51 ` Borislav Petkov
2025-03-23 19:59 ` Guilherme G. Piccoli
2025-03-17 14:40 ` Borislav Petkov
2025-03-17 15:03 ` Guilherme G. Piccoli
2025-03-17 15:14 ` Borislav Petkov
2025-03-17 15:24 ` Guilherme G. Piccoli
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=20250226132733.58327-1-gpiccoli@igalia.com \
--to=gpiccoli@igalia.com \
--cc=bp@alien8.de \
--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=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®