From: Gabriele Monaco <gmonaco@redhat.com>
To: linux-kernel@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
Nam Cao <namcao@linutronix.de>, Juri Lelli <jlelli@redhat.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
linux-trace-kernel@vger.kernel.org
Cc: K Prateek Nayak <kprateek.nayak@amd.com>,
Gabriele Monaco <gmonaco@redhat.com>,
Tomas Glozar <tglozar@redhat.com>,
Clark Williams <williams@redhat.com>,
John Kacur <jkacur@redhat.com>
Subject: [PATCH v6 08/16] sched: Add task enqueue/dequeue trace points
Date: Wed, 25 Feb 2026 10:51:14 +0100 [thread overview]
Message-ID: <20260225095122.80683-9-gmonaco@redhat.com> (raw)
In-Reply-To: <20260225095122.80683-1-gmonaco@redhat.com>
From: Nam Cao <namcao@linutronix.de>
Add trace points into enqueue_task() and dequeue_task().
Signed-off-by: Nam Cao <namcao@linutronix.de>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
Co-developed-by: Gabriele Monaco <gmonaco@redhat.com>
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
---
Notes:
V5:
* Do not fire enqueue tracepoint for delayed enqueues
include/trace/events/sched.h | 8 ++++++++
kernel/sched/core.c | 12 +++++++++++-
kernel/sched/sched.h | 2 ++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 7b2645b50e78..5844147ec5fd 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -896,6 +896,14 @@ DECLARE_TRACE(sched_set_need_resched,
TP_PROTO(struct task_struct *tsk, int cpu, int tif),
TP_ARGS(tsk, cpu, tif));
+DECLARE_TRACE(sched_enqueue,
+ TP_PROTO(struct task_struct *tsk, int cpu),
+ TP_ARGS(tsk, cpu));
+
+DECLARE_TRACE(sched_dequeue,
+ TP_PROTO(struct task_struct *tsk, int cpu),
+ TP_ARGS(tsk, cpu));
+
#endif /* _TRACE_SCHED_H */
/* This part must be outside protection */
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 759777694c78..4ca79ff58fca 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -122,6 +122,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_compute_energy_tp);
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_entry_tp);
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_exit_tp);
EXPORT_TRACEPOINT_SYMBOL_GPL(sched_set_need_resched_tp);
+EXPORT_TRACEPOINT_SYMBOL_GPL(sched_enqueue_tp);
+EXPORT_TRACEPOINT_SYMBOL_GPL(sched_dequeue_tp);
DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
DEFINE_PER_CPU(struct rnd_state, sched_rnd_state);
@@ -2094,6 +2096,9 @@ unsigned long get_wchan(struct task_struct *p)
void enqueue_task(struct rq *rq, struct task_struct *p, int flags)
{
+ if (trace_sched_enqueue_tp_enabled() && !(flags & ENQUEUE_DELAYED))
+ trace_sched_enqueue_tp(p, rq->cpu);
+
if (!(flags & ENQUEUE_NOCLOCK))
update_rq_clock(rq);
@@ -2120,6 +2125,8 @@ void enqueue_task(struct rq *rq, struct task_struct *p, int flags)
*/
inline bool dequeue_task(struct rq *rq, struct task_struct *p, int flags)
{
+ int ret;
+
if (sched_core_enabled(rq))
sched_core_dequeue(rq, p, flags);
@@ -2136,7 +2143,10 @@ inline bool dequeue_task(struct rq *rq, struct task_struct *p, int flags)
* and mark the task ->sched_delayed.
*/
uclamp_rq_dec(rq, p);
- return p->sched_class->dequeue_task(rq, p, flags);
+ ret = p->sched_class->dequeue_task(rq, p, flags);
+ if (trace_sched_dequeue_tp_enabled() && !(flags & DEQUEUE_SLEEP))
+ trace_sched_dequeue_tp(p, rq->cpu);
+ return ret;
}
void activate_task(struct rq *rq, struct task_struct *p, int flags)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index b82fb70a9d54..a83177742603 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -2944,6 +2944,8 @@ static inline void sub_nr_running(struct rq *rq, unsigned count)
static inline void __block_task(struct rq *rq, struct task_struct *p)
{
+ trace_sched_dequeue_tp(p, rq->cpu);
+
if (p->sched_contributes_to_load)
rq->nr_uninterruptible++;
--
2.53.0
next prev 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 ` Gabriele Monaco [this message]
2026-03-06 8:58 ` [PATCH v6 08/16] sched: Add task enqueue/dequeue trace points 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 ` [PATCH v6 14/16] sched_ext: Export task_is_scx_enabled() for verification Gabriele Monaco
2026-02-25 17:08 ` 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-9-gmonaco@redhat.com \
--to=gmonaco@redhat.com \
--cc=jkacur@redhat.com \
--cc=jlelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=namcao@linutronix.de \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglozar@redhat.com \
--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