mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhang Qiao <zhangqiao22@huawei.com>
To: <mingo@redhat.com>, <peterz@infradead.org>,
	<juri.lelli@redhat.com>, <vincent.guittot@linaro.org>,
	<dietmar.eggemann@arm.com>, <rostedt@goodmis.org>,
	<bsegall@google.com>, <mgorman@suse.de>, <bristot@redhat.com>,
	<vschneid@redhat.com>
Cc: <linux-kernel@vger.kernel.org>, <qianjun.kernel@gmail.com>,
	<laoar.shao@gmail.com>
Subject: Re: [PATCH] sched: Improve the accuracy of sched_stat_wait statistics for rt and dl
Date: Tue, 16 Apr 2024 15:13:00 +0800	[thread overview]
Message-ID: <de5ca0cf-e868-a415-83e7-19d5cdf2aaad@huawei.com> (raw)
In-Reply-To: <20240322081521.2687856-1-zhangqiao22@huawei.com>

ping.

在 2024/3/22 16:15, Zhang Qiao 写道:
> Where commit b9c88f752268 ("sched/fair: Improve the accuracy of
> sched_stat_wait statistics") fixed a wrong scenairio for cfs schedstat.
> 
> This wrong scenario is also present for the RT task. For avoiding this
> scenario, add wait_start check in __update_stats_wait_end();
> 
> Signed-off-by: Zhang Qiao <zhangqiao22@huawei.com>
> ---
>  kernel/sched/fair.c  |  9 ---------
>  kernel/sched/stats.c | 11 ++++++++++-
>  2 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 6a16129f9a5c..36c81fe0086b 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -1208,15 +1208,6 @@ update_stats_wait_end_fair(struct cfs_rq *cfs_rq, struct sched_entity *se)
>  
>  	stats = __schedstats_from_se(se);
>  
> -	/*
> -	 * When the sched_schedstat changes from 0 to 1, some sched se
> -	 * maybe already in the runqueue, the se->statistics.wait_start
> -	 * will be 0.So it will let the delta wrong. We need to avoid this
> -	 * scenario.
> -	 */
> -	if (unlikely(!schedstat_val(stats->wait_start)))
> -		return;
> -
>  	if (entity_is_task(se))
>  		p = task_of(se);
>  
> diff --git a/kernel/sched/stats.c b/kernel/sched/stats.c
> index 857f837f52cb..7077eb490c09 100644
> --- a/kernel/sched/stats.c
> +++ b/kernel/sched/stats.c
> @@ -20,8 +20,17 @@ void __update_stats_wait_start(struct rq *rq, struct task_struct *p,
>  void __update_stats_wait_end(struct rq *rq, struct task_struct *p,
>  			     struct sched_statistics *stats)
>  {
> -	u64 delta = rq_clock(rq) - schedstat_val(stats->wait_start);
> +	u64 delta;
>  
> +	/*
> +	 * When the sched_schedstat changes from 0 to 1, some sched se
> +	 * maybe already in the runqueue, the stats->wait_start will be 0.
> +	 * So it will let the delta wrong. We need to avoid this scenario.
> +	 */
> +	if (unlikely(!schedstat_val(stats->wait_start)))
> +		return;
> +
> +	delta = rq_clock(rq) - schedstat_val(stats->wait_start);
>  	if (p) {
>  		if (task_on_rq_migrating(p)) {
>  			/*
> 

      reply	other threads:[~2024-04-16  7:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22  8:15 Zhang Qiao
2024-04-16  7:13 ` Zhang Qiao [this message]

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=de5ca0cf-e868-a415-83e7-19d5cdf2aaad@huawei.com \
    --to=zhangqiao22@huawei.com \
    --cc=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=qianjun.kernel@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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®