[<prev] [next>] [day] [month] [year] [list]
Message-ID: <46a74705b04cab96aa8acdff7df710a8@kernel.org>
Date: Mon, 7 Oct 2024 13:30:08 -0500
From: Clark Williams <clrkwllms@...nel.org>
To: Peter Ziljstra <peterz@...radead.org>,Steven Rostedt <rostedt@...dmis.org>,Thomas Gleixner <tglx@...utronix.de>, Sebastian Andrzej Siewior <bigeasy@...utronix.de>, linux-kernel@...r.kernel.org
Cc: akpm@...ux-foundation.org, bhe@...hat.com,
yang.lee@...ux.alibaba.com, ardb@...nel.org, edumazet@...gle.com,
".com"@web.codeaurora.org, penguin-kernel@...ove.SAKURA.ne.jp
Subject: [PATCH] ksysfs: add a sysfs preemption_mode entry
This patch is the result of a discussion at the last
stable-rt maintainers meeting, regarding what to do about a
commit that basically just made a 'realtime' entry in /sys/kernel
to indicate that the running kernel was compiled with PREEMPT_RT.
Not very useful to non-rt-users.
This commit adds a sysfs entry /sys/kernel/preempt_mode which
allows a user to determine what preemption mode is active for
the running kernel.
When read, the file will return one of the following set of
string values:
NONE
VOLUNTARY
FULL
RT
These values correspond to the options CONFIG_PREEMPT_NONE,
CONFIG_PREEMPT_VOLUNTARY, CONFIG_PREEMPT_FULL and CONFIG_PREEMPT_RT.
Signed-off-by: Clark Williams <williams@...hat.com>
---
kernel/ksysfs.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 1bab21b4718f..57ebde28e4b9 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -188,6 +188,27 @@ KERNEL_ATTR_RO(crash_elfcorehdr_size);
#endif /* CONFIG_VMCORE_INFO */
+/*
+ * entry to display the current preemption mode
+ */
+static ssize_t preempt_mode_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ char *mode = NULL;
+
+ if (preempt_model_rt())
+ mode = "RT";
+ else if (preempt_model_full())
+ mode = "FULL";
+ else if (preempt_model_voluntary())
+ mode = "VOLUNTARY";
+ else
+ mode = "NONE";
+ WARN_ON(mode == NULL);
+ return sysfs_emit(buf, "%s\n", mode);
+}
+KERNEL_ATTR_RO(preempt_mode);
+
/* whether file capabilities are enabled */
static ssize_t fscaps_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
@@ -263,6 +284,7 @@ static struct attribute * kernel_attrs[] = {
&uevent_seqnum_attr.attr,
&cpu_byteorder_attr.attr,
&address_bits_attr.attr,
+ &preempt_mode_attr.attr,
#ifdef CONFIG_UEVENT_HELPER
&uevent_helper_attr.attr,
#endif
--
2.46.2
Powered by blists - more mailing lists