linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Xiang Gao <gxxa03070307@gmail.com>
Cc: mhiramat@kernel.org, mathieu.desnoyers@efficios.com,
	andrii@kernel.org, mingo@kernel.org, oleg@redhat.com,
	akpm@linux-foundation.org, gmonaco@redhat.com,
	ricardo.neri-calderon@linux.intel.com, libo.chen@oracle.com,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	gaoxiang17 <gaoxiang17@xiaomi.com>
Subject: Re: [PATCH] tracing/sched: add 'next_policy' to trace_sched_switch
Date: Fri, 22 Aug 2025 10:02:09 -0400	[thread overview]
Message-ID: <20250822100209.7b1c5acf@gandalf.local.home> (raw)
In-Reply-To: <20250822105113.1102099-1-gxxa03070307@gmail.com>

On Fri, 22 Aug 2025 18:51:13 +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:
> 
>       113.457176: sched_switch: prev_comm=kcompactd0 prev_pid=30 prev_prio=120 prev_state=S ==> next_comm=kworker/u4:1 next_pid=27 next_prio=120 next_policy=0
>       113.457282: sched_switch: prev_comm=kworker/u4:1 prev_pid=27 prev_prio=120 prev_state=I ==> next_comm=swapper/0 next_pid=0 next_prio=120 next_policy=0
>       113.461166: sched_switch: prev_comm=swapper/0 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kworker/u4:1 next_pid=27 next_prio=120 next_policy=0
> 
> Signed-off-by: gaoxiang17 <gaoxiang17@xiaomi.com>
> ---
>  include/trace/events/sched.h | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
> index 7b2645b50e78..b416b7bafee4 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=%u",
>  		__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
>  
>  		(__entry->prev_state & (TASK_REPORT_MAX - 1)) ?
> @@ -263,7 +265,7 @@ 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, __entry->next_policy)


I'm fine with this change, but I'm not sure how Peter feels about updating
scheduler tracepoints. That said, why not show the policy name?

	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->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"}))

-- Steve






>  );
>  
>  /*


  reply	other threads:[~2025-08-22 14:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-22 10:51 [PATCH] tracing/sched: add 'next_policy' to trace_sched_switch Xiang Gao
2025-08-22 14:02 ` Steven Rostedt [this message]
2025-08-22 14:04   ` Steven Rostedt

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=20250822100209.7b1c5acf@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrii@kernel.org \
    --cc=gaoxiang17@xiaomi.com \
    --cc=gmonaco@redhat.com \
    --cc=gxxa03070307@gmail.com \
    --cc=libo.chen@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=ricardo.neri-calderon@linux.intel.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;
as well as URLs for NNTP newsgroup(s).