* [PATCH v2 1/1] tracing/sched: add 'next_policy' to trace_sched_switch
[not found] <cover.1755920363.git.gaoxiang17@xiaomi.com>
@ 2025-08-23 3:45 ` Xiang Gao
0 siblings, 0 replies; 5+ messages in thread
From: Xiang Gao @ 2025-08-23 3:45 UTC (permalink / raw)
To: rostedt, mhiramat
Cc: mingo, peterz, juri.lelli, vincent.guittot, mathieu.desnoyers,
andrii, mingo, oleg, akpm, gmonaco, ricardo.neri-calderon,
libo.chen, linux-kernel, linux-trace-kernel, gaoxiang17
From: gaoxiang17 <gaoxiang17@xiaomi.com>
Sometimes, when analyzing some real-time process issues, it is necessary to know the sched policy.
Show up in the trace as:
72.267374: sched_switch: prev_comm=grep prev_pid=67 prev_prio=19 prev_state=S ==> next_comm=cat next_pid=66 next_prio=120 next_policy=normal
72.267594: sched_switch: prev_comm=cat prev_pid=66 prev_prio=120 prev_state=R+ ==> next_comm=grep next_pid=67 next_prio=19 next_policy=RR
562.192567: sched_switch: prev_comm=grep prev_pid=85 prev_prio=19 prev_state=S ==> next_comm=cat next_pid=84 next_prio=120 next_policy=normal
562.192944: sched_switch: prev_comm=cat prev_pid=84 prev_prio=120 prev_state=R+ ==> next_comm=grep next_pid=85 next_prio=19 next_policy=FIFO
Signed-off-by: gaoxiang17 <gaoxiang17@xiaomi.com>
---
include/trace/events/sched.h | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 7b2645b50e78..00336211aca6 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -234,6 +234,7 @@ TRACE_EVENT(sched_switch,
__array( char, next_comm, TASK_COMM_LEN )
__field( pid_t, next_pid )
__field( int, next_prio )
+ __field( unsigned int, next_policy )
),
TP_fast_assign(
@@ -244,10 +245,11 @@ TRACE_EVENT(sched_switch,
memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
__entry->next_pid = next->pid;
__entry->next_prio = next->prio;
+ __entry->next_policy = next->policy;
/* XXX SCHED_DEADLINE */
),
- TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d",
+ TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d next_policy=%s",
__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
(__entry->prev_state & (TASK_REPORT_MAX - 1)) ?
@@ -263,7 +265,16 @@ TRACE_EVENT(sched_switch,
"R",
__entry->prev_state & TASK_REPORT_MAX ? "+" : "",
- __entry->next_comm, __entry->next_pid, __entry->next_prio)
+ __entry->next_comm, __entry->next_pid, __entry->next_prio,
+ __print_symbolic(__entry->next_policy,
+ { SCHED_NORMAL, "normal" },
+ { SCHED_FIFO, "FIFO" },
+ { SCHED_RR, "RR" },
+ { SCHED_BATCH, "batch" },
+ { SCHED_IDLE, "idle" },
+ { SCHED_DEADLINE, "deadline" },
+ { SCHED_EXT, "sched_ext"})
+ )
);
/*
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 1/1] tracing/sched: add 'next_policy' to trace_sched_switch
[not found] <cover.1756212396.git.gaoxiang17@xiaomi.com>
@ 2025-08-26 12:48 ` Xiang Gao
2025-09-12 14:30 ` Steven Rostedt
0 siblings, 1 reply; 5+ messages in thread
From: Xiang Gao @ 2025-08-26 12:48 UTC (permalink / raw)
To: rostedt, mhiramat
Cc: mingo, peterz, juri.lelli, vincent.guittot, mathieu.desnoyers,
andrii, mingo, oleg, akpm, gmonaco, ricardo.neri-calderon,
linux-kernel, linux-trace-kernel, gaoxiang17
From: gaoxiang17 <gaoxiang17@xiaomi.com>
Sometimes, when analyzing some real-time process issues, it is necessary to know the sched policy.
Show up in the trace as:
72.267374: sched_switch: prev_comm=grep prev_pid=67 prev_prio=19 prev_state=S ==> next_comm=cat next_pid=66 next_prio=120 next_policy=normal
72.267594: sched_switch: prev_comm=cat prev_pid=66 prev_prio=120 prev_state=R+ ==> next_comm=grep next_pid=67 next_prio=19 next_policy=RR
562.192567: sched_switch: prev_comm=grep prev_pid=85 prev_prio=19 prev_state=S ==> next_comm=cat next_pid=84 next_prio=120 next_policy=normal
562.192944: sched_switch: prev_comm=cat prev_pid=84 prev_prio=120 prev_state=R+ ==> next_comm=grep next_pid=85 next_prio=19 next_policy=FIFO
Signed-off-by: gaoxiang17 <gaoxiang17@xiaomi.com>
---
include/trace/events/sched.h | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 7b2645b50e78..00336211aca6 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -234,6 +234,7 @@ TRACE_EVENT(sched_switch,
__array( char, next_comm, TASK_COMM_LEN )
__field( pid_t, next_pid )
__field( int, next_prio )
+ __field( unsigned int, next_policy )
),
TP_fast_assign(
@@ -244,10 +245,11 @@ TRACE_EVENT(sched_switch,
memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
__entry->next_pid = next->pid;
__entry->next_prio = next->prio;
+ __entry->next_policy = next->policy;
/* XXX SCHED_DEADLINE */
),
- TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d",
+ TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d next_policy=%s",
__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
(__entry->prev_state & (TASK_REPORT_MAX - 1)) ?
@@ -263,7 +265,16 @@ TRACE_EVENT(sched_switch,
"R",
__entry->prev_state & TASK_REPORT_MAX ? "+" : "",
- __entry->next_comm, __entry->next_pid, __entry->next_prio)
+ __entry->next_comm, __entry->next_pid, __entry->next_prio,
+ __print_symbolic(__entry->next_policy,
+ { SCHED_NORMAL, "normal" },
+ { SCHED_FIFO, "FIFO" },
+ { SCHED_RR, "RR" },
+ { SCHED_BATCH, "batch" },
+ { SCHED_IDLE, "idle" },
+ { SCHED_DEADLINE, "deadline" },
+ { SCHED_EXT, "sched_ext"})
+ )
);
/*
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] tracing/sched: add 'next_policy' to trace_sched_switch
2025-08-26 12:48 ` [PATCH v2 1/1] tracing/sched: add 'next_policy' to trace_sched_switch Xiang Gao
@ 2025-09-12 14:30 ` Steven Rostedt
2025-09-24 12:41 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2025-09-12 14:30 UTC (permalink / raw)
To: Xiang Gao
Cc: mhiramat, mingo, peterz, juri.lelli, vincent.guittot,
mathieu.desnoyers, andrii, mingo, oleg, akpm, gmonaco,
ricardo.neri-calderon, linux-kernel, linux-trace-kernel,
gaoxiang17
On Tue, 26 Aug 2025 20:48:54 +0800
Xiang Gao <gxxa03070307@gmail.com> wrote:
> From: gaoxiang17 <gaoxiang17@xiaomi.com>
>
> Sometimes, when analyzing some real-time process issues, it is necessary to know the sched policy.
>
> Show up in the trace as:
>
> 72.267374: sched_switch: prev_comm=grep prev_pid=67 prev_prio=19 prev_state=S ==> next_comm=cat next_pid=66 next_prio=120 next_policy=normal
> 72.267594: sched_switch: prev_comm=cat prev_pid=66 prev_prio=120 prev_state=R+ ==> next_comm=grep next_pid=67 next_prio=19 next_policy=RR
> 562.192567: sched_switch: prev_comm=grep prev_pid=85 prev_prio=19 prev_state=S ==> next_comm=cat next_pid=84 next_prio=120 next_policy=normal
> 562.192944: sched_switch: prev_comm=cat prev_pid=84 prev_prio=120 prev_state=R+ ==> next_comm=grep next_pid=85 next_prio=19 next_policy=FIFO
>
Peter,
Are you OK with extending the sched switch tracepoint?
-- Steve
> Signed-off-by: gaoxiang17 <gaoxiang17@xiaomi.com>
> ---
> include/trace/events/sched.h | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
> index 7b2645b50e78..00336211aca6 100644
> --- a/include/trace/events/sched.h
> +++ b/include/trace/events/sched.h
> @@ -234,6 +234,7 @@ TRACE_EVENT(sched_switch,
> __array( char, next_comm, TASK_COMM_LEN )
> __field( pid_t, next_pid )
> __field( int, next_prio )
> + __field( unsigned int, next_policy )
> ),
>
> TP_fast_assign(
> @@ -244,10 +245,11 @@ TRACE_EVENT(sched_switch,
> memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
> __entry->next_pid = next->pid;
> __entry->next_prio = next->prio;
> + __entry->next_policy = next->policy;
> /* XXX SCHED_DEADLINE */
> ),
>
> - TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d",
> + TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d next_policy=%s",
> __entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
>
> (__entry->prev_state & (TASK_REPORT_MAX - 1)) ?
> @@ -263,7 +265,16 @@ TRACE_EVENT(sched_switch,
> "R",
>
> __entry->prev_state & TASK_REPORT_MAX ? "+" : "",
> - __entry->next_comm, __entry->next_pid, __entry->next_prio)
> + __entry->next_comm, __entry->next_pid, __entry->next_prio,
> + __print_symbolic(__entry->next_policy,
> + { SCHED_NORMAL, "normal" },
> + { SCHED_FIFO, "FIFO" },
> + { SCHED_RR, "RR" },
> + { SCHED_BATCH, "batch" },
> + { SCHED_IDLE, "idle" },
> + { SCHED_DEADLINE, "deadline" },
> + { SCHED_EXT, "sched_ext"})
> + )
> );
>
> /*
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] tracing/sched: add 'next_policy' to trace_sched_switch
2025-09-12 14:30 ` Steven Rostedt
@ 2025-09-24 12:41 ` Peter Zijlstra
2025-09-24 12:45 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2025-09-24 12:41 UTC (permalink / raw)
To: Steven Rostedt
Cc: Xiang Gao, mhiramat, mingo, juri.lelli, vincent.guittot,
mathieu.desnoyers, andrii, mingo, oleg, akpm, gmonaco,
ricardo.neri-calderon, linux-kernel, linux-trace-kernel,
gaoxiang17
On Fri, Sep 12, 2025 at 10:30:50AM -0400, Steven Rostedt wrote:
> On Tue, 26 Aug 2025 20:48:54 +0800
> Xiang Gao <gxxa03070307@gmail.com> wrote:
>
> > From: gaoxiang17 <gaoxiang17@xiaomi.com>
> >
> > Sometimes, when analyzing some real-time process issues, it is necessary to know the sched policy.
> >
> > Show up in the trace as:
> >
> > 72.267374: sched_switch: prev_comm=grep prev_pid=67 prev_prio=19 prev_state=S ==> next_comm=cat next_pid=66 next_prio=120 next_policy=normal
> > 72.267594: sched_switch: prev_comm=cat prev_pid=66 prev_prio=120 prev_state=R+ ==> next_comm=grep next_pid=67 next_prio=19 next_policy=RR
> > 562.192567: sched_switch: prev_comm=grep prev_pid=85 prev_prio=19 prev_state=S ==> next_comm=cat next_pid=84 next_prio=120 next_policy=normal
> > 562.192944: sched_switch: prev_comm=cat prev_pid=84 prev_prio=120 prev_state=R+ ==> next_comm=grep next_pid=85 next_prio=19 next_policy=FIFO
> >
>
> Peter,
>
> Are you OK with extending the sched switch tracepoint?
I'm not convinced; this is a bit like whitespace patches, people will
want their favourite field added and before you know it the thing will
be fat as never before.
OTOH changing it will be yet another opportunity to find people that are
not following the recommended practise. Someone will come forward and go
complain we broke their shit or something.
Anyway, if we go touch it, you might as well go do it right and move
prev_prio, next_prio and the polcy things into a u8 [*].
Also, I don't know why we have prev_prio, but if that is useful,
shouldn't we also have prev_policy for consistenty sake?
That said, you can mostly guess the policy from the prio, I mean the
distinction between fair/batch and rr/fifo gets lots, but you can
readily tell the difference between the fair and rt and deadline tasks.
[*] I mean, we do use -1 for dl, and that'll map to 255 in u8, but we
can't really use s8 since MAX_PRIO is 140. u8 is bits plenty, but just a
bit weird *shurg*.
this way the event shrinks by 4 bytes, which is at least somewhat of a
reason to do this.
> > Signed-off-by: gaoxiang17 <gaoxiang17@xiaomi.com>
> > ---
> > include/trace/events/sched.h | 15 +++++++++++++--
> > 1 file changed, 13 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
> > index 7b2645b50e78..00336211aca6 100644
> > --- a/include/trace/events/sched.h
> > +++ b/include/trace/events/sched.h
> > @@ -234,6 +234,7 @@ TRACE_EVENT(sched_switch,
> > __array( char, next_comm, TASK_COMM_LEN )
> > __field( pid_t, next_pid )
> > __field( int, next_prio )
> > + __field( unsigned int, next_policy )
> > ),
> >
> > TP_fast_assign(
> > @@ -244,10 +245,11 @@ TRACE_EVENT(sched_switch,
> > memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
> > __entry->next_pid = next->pid;
> > __entry->next_prio = next->prio;
> > + __entry->next_policy = next->policy;
> > /* XXX SCHED_DEADLINE */
> > ),
> >
> > - TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d",
> > + TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d next_policy=%s",
> > __entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
> >
> > (__entry->prev_state & (TASK_REPORT_MAX - 1)) ?
> > @@ -263,7 +265,16 @@ TRACE_EVENT(sched_switch,
> > "R",
> >
> > __entry->prev_state & TASK_REPORT_MAX ? "+" : "",
> > - __entry->next_comm, __entry->next_pid, __entry->next_prio)
> > + __entry->next_comm, __entry->next_pid, __entry->next_prio,
> > + __print_symbolic(__entry->next_policy,
> > + { SCHED_NORMAL, "normal" },
> > + { SCHED_FIFO, "FIFO" },
> > + { SCHED_RR, "RR" },
> > + { SCHED_BATCH, "batch" },
> > + { SCHED_IDLE, "idle" },
> > + { SCHED_DEADLINE, "deadline" },
> > + { SCHED_EXT, "sched_ext"})
> > + )
> > );
> >
> > /*
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] tracing/sched: add 'next_policy' to trace_sched_switch
2025-09-24 12:41 ` Peter Zijlstra
@ 2025-09-24 12:45 ` Peter Zijlstra
0 siblings, 0 replies; 5+ messages in thread
From: Peter Zijlstra @ 2025-09-24 12:45 UTC (permalink / raw)
To: Steven Rostedt
Cc: Xiang Gao, mhiramat, mingo, juri.lelli, vincent.guittot,
mathieu.desnoyers, andrii, mingo, oleg, akpm, gmonaco,
ricardo.neri-calderon, linux-kernel, linux-trace-kernel,
gaoxiang17
On Wed, Sep 24, 2025 at 02:41:07PM +0200, Peter Zijlstra wrote:
> That said, you can mostly guess the policy from the prio, I mean the
> distinction between fair/batch and rr/fifo gets lots, but you can
> readily tell the difference between the fair and rt and deadline tasks.
FWIW mixing RR and FIFO tasks is asking for pain, adding tracing
information isn't going to help you restore your sanity.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-24 12:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1756212396.git.gaoxiang17@xiaomi.com>
2025-08-26 12:48 ` [PATCH v2 1/1] tracing/sched: add 'next_policy' to trace_sched_switch Xiang Gao
2025-09-12 14:30 ` Steven Rostedt
2025-09-24 12:41 ` Peter Zijlstra
2025-09-24 12:45 ` Peter Zijlstra
[not found] <cover.1755920363.git.gaoxiang17@xiaomi.com>
2025-08-23 3:45 ` Xiang Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox