public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Gabriele Monaco <gmonaco@redhat.com>
To: linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>,
	Andrea Righi <arighi@nvidia.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Nam Cao <namcao@linutronix.de>, Juri Lelli <jlelli@redhat.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	sched-ext@lists.linux.dev
Cc: Gabriele Monaco <gmonaco@redhat.com>,
	Tomas Glozar <tglozar@redhat.com>,
	Clark Williams <williams@redhat.com>,
	John Kacur <jkacur@redhat.com>,
	linux-trace-kernel@vger.kernel.org
Subject: [PATCH v6 14/16] sched_ext: Export task_is_scx_enabled() for verification
Date: Wed, 25 Feb 2026 10:51:20 +0100	[thread overview]
Message-ID: <20260225095122.80683-15-gmonaco@redhat.com> (raw)
In-Reply-To: <20260225095122.80683-1-gmonaco@redhat.com>

When a sched_ext scheduler is loaded, depending on the configuration, it
can handle also fair tasks, however it isn't trivial to understand if a
certain task is currently handled by fair or ext outside of scheduler
code. This can be a problem when writing verification or observability
tools like RV monitors.

Export a task_is_scx_enabled() to allow quick classification by using
the scx state SCX_TASK_ENABLED.

To: Tejun Heo <tj@kernel.org>
To: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
---
 include/linux/sched/ext.h | 2 ++
 kernel/sched/ext.c        | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/include/linux/sched/ext.h b/include/linux/sched/ext.h
index bcb962d5ee7d..68e5aff95159 100644
--- a/include/linux/sched/ext.h
+++ b/include/linux/sched/ext.h
@@ -232,6 +232,7 @@ void print_scx_info(const char *log_lvl, struct task_struct *p);
 void scx_softlockup(u32 dur_s);
 bool scx_hardlockup(int cpu);
 bool scx_rcu_cpu_stall(void);
+bool task_is_scx_enabled(struct task_struct *p);
 
 #else	/* !CONFIG_SCHED_CLASS_EXT */
 
@@ -240,6 +241,7 @@ static inline void print_scx_info(const char *log_lvl, struct task_struct *p) {}
 static inline void scx_softlockup(u32 dur_s) {}
 static inline bool scx_hardlockup(int cpu) { return false; }
 static inline bool scx_rcu_cpu_stall(void) { return false; }
+static inline bool task_is_scx_enabled(struct task_struct *p) { return false; }
 
 #endif	/* CONFIG_SCHED_CLASS_EXT */
 
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 62b1f3ac5630..1e48bc3cde15 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -3772,6 +3772,14 @@ bool task_should_scx(int policy)
 	return policy == SCHED_EXT;
 }
 
+/*
+ * Used by verification/observability tools like RV monitors.
+ */
+bool task_is_scx_enabled(struct task_struct *p)
+{
+	return scx_get_task_state(p) == SCX_TASK_ENABLED;
+}
+
 bool scx_allow_ttwu_queue(const struct task_struct *p)
 {
 	struct scx_sched *sch;
-- 
2.53.0


  parent reply	other threads:[~2026-02-25  9:52 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25  9:51 [PATCH v6 00/16] rv: Add Hybrid Automata monitor type, per-object and deadline monitors Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 01/16] rv: Unify DA event handling functions across monitor types Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 02/16] rv: Add Hybrid Automata monitor type Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 03/16] verification/rvgen: Allow spaces in and events strings Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 04/16] verification/rvgen: Add support for Hybrid Automata Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 05/16] Documentation/rv: Add documentation about hybrid automata Gabriele Monaco
2026-03-02 13:58   ` Juri Lelli
2026-03-02 14:23     ` Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 06/16] rv: Add sample hybrid monitors stall Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 07/16] rv: Convert the opid monitor to a hybrid automaton Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 08/16] sched: Add task enqueue/dequeue trace points Gabriele Monaco
2026-03-06  8:58   ` Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 09/16] rv: Add enqueue/dequeue to snroc monitor Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 10/16] rv: Add support for per-object monitors in DA/HA Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 11/16] verification/rvgen: Add support for per-obj monitors Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 12/16] sched: Add deadline tracepoints Gabriele Monaco
2026-03-02 14:15   ` Juri Lelli
2026-03-02 14:24     ` Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 13/16] sched/deadline: Move some utility functions to deadline.h Gabriele Monaco
2026-02-25  9:51 ` Gabriele Monaco [this message]
2026-02-25 17:08   ` [PATCH v6 14/16] sched_ext: Export task_is_scx_enabled() for verification Tejun Heo
2026-02-26  7:10     ` Gabriele Monaco
2026-02-26 15:22       ` Tejun Heo
2026-02-26 15:42         ` Gabriele Monaco
2026-02-26 15:48           ` Tejun Heo
2026-02-26 16:25             ` Gabriele Monaco
2026-02-26 17:54               ` Tejun Heo
2026-02-26 18:39                 ` Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 15/16] rv: Add deadline monitors Gabriele Monaco
2026-03-02 14:37   ` Juri Lelli
2026-03-02 15:11     ` Gabriele Monaco
2026-02-25  9:51 ` [PATCH v6 16/16] rv: Add dl_server specific monitors Gabriele Monaco

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=20260225095122.80683-15-gmonaco@redhat.com \
    --to=gmonaco@redhat.com \
    --cc=arighi@nvidia.com \
    --cc=jkacur@redhat.com \
    --cc=jlelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namcao@linutronix.de \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tglozar@redhat.com \
    --cc=tj@kernel.org \
    --cc=williams@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox