linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched/rt: Add pid and comm when RT throttling activated
@ 2022-12-06  8:36 Yajun Deng
  2022-12-09 21:36 ` Steven Rostedt
  2022-12-12  2:05 ` Yajun Deng
  0 siblings, 2 replies; 3+ messages in thread
From: Yajun Deng @ 2022-12-06  8:36 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, bristot, vschneid
  Cc: linux-kernel, Yajun Deng

It is difficult to know which process consumes time when RT throttling
activated.

So add pid and comm for this case.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
 kernel/sched/rt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index ed2a47e4ddae..1f267ab1b59a 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1012,6 +1012,7 @@ static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)
 
 	if (rt_rq->rt_time > runtime) {
 		struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
+		struct task_struct *curr = rq_of_rt_rq(rt_rq)->curr;
 
 		/*
 		 * Don't actually throttle groups that have no runtime assigned
@@ -1019,7 +1020,8 @@ static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)
 		 */
 		if (likely(rt_b->rt_runtime)) {
 			rt_rq->rt_throttled = 1;
-			printk_deferred_once("sched: RT throttling activated\n");
+			printk_deferred_once("pid: %d, comm: %s, sched: RT throttling activated\n",
+					     curr->pid, curr->comm);
 		} else {
 			/*
 			 * In case we did anyway, make it go away,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched/rt: Add pid and comm when RT throttling activated
  2022-12-06  8:36 [PATCH] sched/rt: Add pid and comm when RT throttling activated Yajun Deng
@ 2022-12-09 21:36 ` Steven Rostedt
  2022-12-12  2:05 ` Yajun Deng
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2022-12-09 21:36 UTC (permalink / raw)
  To: Yajun Deng
  Cc: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	bsegall, mgorman, bristot, vschneid, linux-kernel

On Tue,  6 Dec 2022 16:36:41 +0800
Yajun Deng <yajun.deng@linux.dev> wrote:

> It is difficult to know which process consumes time when RT throttling
> activated.
> 
> So add pid and comm for this case.
> 

Unfortunately, that only shows the process that "broke the camel's
back"[1]. The things is, it is the amount of time *all* RT tasks use to
trigger throttling. You are only printing the task that the throttling
occurred on.

Try running https://rostedt.org/code/migrate.c . It will create a bunch of
RT tasks, and they all will throttle once it hits 950ms ever second.

  trace-cmd record -e sched_switch ./migrate
  kernelshark

Then plot all the migrate tasks.

The above will demonstrate it very well.

-- Steve


[1] https://en.wikipedia.org/wiki/Straw_that_broke_the_camel%27s_back

> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> ---
>  kernel/sched/rt.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index ed2a47e4ddae..1f267ab1b59a 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -1012,6 +1012,7 @@ static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)
>  
>  	if (rt_rq->rt_time > runtime) {
>  		struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
> +		struct task_struct *curr = rq_of_rt_rq(rt_rq)->curr;
>  
>  		/*
>  		 * Don't actually throttle groups that have no runtime assigned
> @@ -1019,7 +1020,8 @@ static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)
>  		 */
>  		if (likely(rt_b->rt_runtime)) {
>  			rt_rq->rt_throttled = 1;
> -			printk_deferred_once("sched: RT throttling activated\n");
> +			printk_deferred_once("pid: %d, comm: %s, sched: RT throttling activated\n",
> +					     curr->pid, curr->comm);
>  		} else {
>  			/*
>  			 * In case we did anyway, make it go away,


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched/rt: Add pid and comm when RT throttling activated
  2022-12-06  8:36 [PATCH] sched/rt: Add pid and comm when RT throttling activated Yajun Deng
  2022-12-09 21:36 ` Steven Rostedt
@ 2022-12-12  2:05 ` Yajun Deng
  1 sibling, 0 replies; 3+ messages in thread
From: Yajun Deng @ 2022-12-12  2:05 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	bsegall, mgorman, bristot, vschneid, linux-kernel

December 10, 2022 5:36 AM, "Steven Rostedt" <rostedt@goodmis.org> wrote:

> On Tue, 6 Dec 2022 16:36:41 +0800
> Yajun Deng <yajun.deng@linux.dev> wrote:
> 
>> It is difficult to know which process consumes time when RT throttling
>> activated.
>> 
>> So add pid and comm for this case.
> 
> Unfortunately, that only shows the process that "broke the camel's
> back"[1]. The things is, it is the amount of time *all* RT tasks use to
> trigger throttling. You are only printing the task that the throttling
> occurred on.
> 
> Try running https://rostedt.org/code/migrate.c . It will create a bunch of
> RT tasks, and they all will throttle once it hits 950ms ever second.
> 
> trace-cmd record -e sched_switch ./migrate
> kernelshark
> 
> Then plot all the migrate tasks.
> 
> The above will demonstrate it very well.

Thanks for your patient answer, I'll test it.

> 
> -- Steve
> 
> [1] https://en.wikipedia.org/wiki/Straw_that_broke_the_camel's_back
> 
>> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
>> ---
>> kernel/sched/rt.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>> 
>> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
>> index ed2a47e4ddae..1f267ab1b59a 100644
>> --- a/kernel/sched/rt.c
>> +++ b/kernel/sched/rt.c
>> @@ -1012,6 +1012,7 @@ static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)
>> 
>> if (rt_rq->rt_time > runtime) {
>> struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
>> + struct task_struct *curr = rq_of_rt_rq(rt_rq)->curr;
>> 
>> /*
>> * Don't actually throttle groups that have no runtime assigned
>> @@ -1019,7 +1020,8 @@ static int sched_rt_runtime_exceeded(struct rt_rq *rt_rq)
>> */
>> if (likely(rt_b->rt_runtime)) {
>> rt_rq->rt_throttled = 1;
>> - printk_deferred_once("sched: RT throttling activated\n");
>> + printk_deferred_once("pid: %d, comm: %s, sched: RT throttling activated\n",
>> + curr->pid, curr->comm);
>> } else {
>> /*
>> * In case we did anyway, make it go away,

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-12  2:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-06  8:36 [PATCH] sched/rt: Add pid and comm when RT throttling activated Yajun Deng
2022-12-09 21:36 ` Steven Rostedt
2022-12-12  2:05 ` Yajun Deng

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).