[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250912103050.5bf82967@gandalf.local.home>
Date: Fri, 12 Sep 2025 10:30:50 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Xiang Gao <gxxa03070307@...il.com>
Cc: mhiramat@...nel.org, mingo@...hat.com, peterz@...radead.org,
juri.lelli@...hat.com, vincent.guittot@...aro.org,
mathieu.desnoyers@...icios.com, andrii@...nel.org, mingo@...nel.org,
oleg@...hat.com, akpm@...ux-foundation.org, gmonaco@...hat.com,
ricardo.neri-calderon@...ux.intel.com, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org, gaoxiang17 <gaoxiang17@...omi.com>
Subject: Re: [PATCH v2 1/1] tracing/sched: add 'next_policy' to
trace_sched_switch
On Tue, 26 Aug 2025 20:48:54 +0800
Xiang Gao <gxxa03070307@...il.com> wrote:
> From: gaoxiang17 <gaoxiang17@...omi.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@...omi.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"})
> + )
> );
>
> /*
Powered by blists - more mailing lists