From: Clark Williams <clrkwllms@kernel.org>
To: Peter Ziljstra <peterz@infradead.org>,Steven Rostedt
<rostedt@goodmis.org>,Thomas Gleixner <tglx@linutronix.de>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, bhe@redhat.com,
yang.lee@linux.alibaba.com,ardb@kernel.org,edumazet@google.com,
.com, penguin-kernel@I-love.SAKURA.ne.jp
Subject: [PATCH] ksysfs: add a sysfs preemption_mode entry
Date: Mon, 7 Oct 2024 13:30:08 -0500 [thread overview]
Message-ID: <46a74705b04cab96aa8acdff7df710a8@kernel.org> (raw)
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@redhat.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
reply other threads:[~2024-10-11 2:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=46a74705b04cab96aa8acdff7df710a8@kernel.org \
--to=clrkwllms@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=bhe@redhat.com \
--cc=bigeasy@linutronix.de \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=yang.lee@linux.alibaba.com \
/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.