mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Bristot de Oliveira <bristot@redhat.com>
To: Junwen Wu <wudaemon@163.com>,
	mingo@redhat.com, laoar.shao@gmail.com, peterz@infradead.org,
	juri.lelli@redhat.com, vincent.guittot@linaro.org,
	dietmar.eggemann@arm.com, rostedt@goodmis.org,
	bsegall@google.com
Cc: mgorman@suse.de, vschneid@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] sched/stats: Fix rt/dl task's sched latency statistics error in sched_stat_wait trace_point
Date: Thu, 4 Jan 2024 12:02:20 +0100	[thread overview]
Message-ID: <87d33909-ef8c-43a6-a556-d01fe692d5cd@redhat.com> (raw)
In-Reply-To: <20240101031704.227541-1-wudaemon@163.com>

Hi Junwen

s/trace_point/tracepoint/g

On 1/1/24 04:17, Junwen Wu wrote:
> When enable sched_stat_wait trace_point, some rt tasks sched latency so long, like this,
> sched_stat_wait: comm=rcu_preempt pid=14 delay=4936139545261 [ns]
> Rt task has low latency, it must have a bug. When rt task balance off source cpu,
> dequeue operation not update the sched_statistics, so follow update_stats_wait_end_fair
> update method, so do dl tasks.

This is a little bit hard to read, how about something like this?

The sched_stat_wait tracepoint is showing unreasonably long
latencies for real-time tasks. For example:

sched_stat_wait: comm=rcu_preempt pid=14 delay=4936139545261 [ns]

This error happens when the rt task balances off the source CPU because
the dequeue operation is not updating the sched_statistics. So, follow
update_stats_wait_end_fair() and update the stats. Do the same for
SCHED_DEADLINE.

[ feel free to change ]

> 
> Fixes: 57a5c2dafca8 ("sched/rt: Support schedstats for RT sched class")
> Fixes: b5eb4a5f6521 ("sched/dl: Support schedstats for deadline sched class")
> Signed-off-by: Junwen Wu <wudaemon@163.com>
> ---
>  kernel/sched/deadline.c | 8 +++++++-
>  kernel/sched/rt.c       | 7 +++++++
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index b28114478b82..29223163ee22 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -1558,10 +1558,16 @@ update_stats_dequeue_dl(struct dl_rq *dl_rq, struct sched_dl_entity *dl_se,
>  			int flags)
>  {
>  	struct task_struct *p = dl_task_of(dl_se);
> +	struct rq *rq = rq_of_dl_rq(dl_rq);
>  
>  	if (!schedstat_enabled())
>  		return;
> -
> +	/*
> +	 * Mark the end of the wait period
> +	 * if dequeueing a waiting task.
> +	 */
make this a single line comment.

> +	if (p && (p != rq->curr))
> +		 update_stats_wait_end_dl(dl_rq, dl_se);
>  	if ((flags & DEQUEUE_SLEEP)) {
>  		unsigned int state;
>  
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 6aaf0a3d6081..6a2600213991 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -1360,12 +1360,19 @@ update_stats_dequeue_rt(struct rt_rq *rt_rq, struct sched_rt_entity *rt_se,
>  			int flags)
>  {
>  	struct task_struct *p = NULL;
> +	struct rq *rq = rq_of_rt_se(rt_se);
>  
>  	if (!schedstat_enabled())
>  		return;
>  
>  	if (rt_entity_is_task(rt_se))
>  		p = rt_task_of(rt_se);
> +	 /*
> +	  * Mark the end of the wait period
> +	  * if dequeueing a waiting task.
> +	  */

ditto

-- Daniel


  reply	other threads:[~2024-01-04 11:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-01  3:17 Junwen Wu
2024-01-04 11:02 ` Daniel Bristot de Oliveira [this message]
2024-01-10 12:27   ` Junwen Wu

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=87d33909-ef8c-43a6-a556-d01fe692d5cd@redhat.com \
    --to=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=laoar.shao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=wudaemon@163.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

all inboxes | Powered by JetHome®