From: xieliujie <xieliujie92@gmail.com>
To: mingo@redhat.com, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org, LiuJie Xie <xieliujie@xiaomi.com>
Subject: Re: [PATCH] sched/rt: Update wait_time when doing migration.
Date: Mon, 16 Jun 2025 20:10:18 +0800 [thread overview]
Message-ID: <0911287d-b936-4a3d-af24-76c351393b5b@gmail.com> (raw)
In-Reply-To: <20250414114841.2181865-1-xieliujie@xiaomi.com>
[ping]
在 2025/4/14 19:48, LiuJie Xie 写道:
> From: LiuJie Xie <xieliujie@xiaomi.com>
>
> With __update_stats_wait_start() and __update_stats_wait_end(), we track
> task's latency and the info can be seen in proc node '/proc/pid/sched'.
> But it seems that we loss updating wait_time when rt task doing migration.
> In update_stats_dequeue_fair() by calling update_stats_wait_end_fair(), the
> fair sched class make this update work.
>
> When a rt doing migration, we can see:
> step1: wait_start=1503718063442 C:(__update_stats_wait_start<-ttwu_do_activate<-try_to_wake_up)
> step2: wait_start=124844 C:(__update_stats_wait_start<-activate_task<-push_rt_task<-push_rt_tasks<-finish_task_switch)
> step3: wait_start=124844 delta=1503718120473 C:(__update_stats_wait_end<-__schedule<-schedule)
>
> In step2, the wait_start become very small after doing the below logic
> and we will get a very big delta in step3.
> void __update_stats_wait_start()
> {
> prev_wait_start = schedstat_val(stats->wait_start);
>
> if (p && likely(wait_start > prev_wait_start))
> wait_start -= prev_wait_start;
>
> __schedstat_set(stats->wait_start, wait_start);
> }
>
> So, update_stats_dequeue_rt() should also update wait_time just like
> fair to get the correct delta.
>
> Signed-off-by: LiuJie Xie <xieliujie@xiaomi.com>
> ---
> kernel/sched/rt.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index fa03ec3ed56a..a93d23b839ad 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -1346,6 +1346,13 @@ update_stats_dequeue_rt(struct rt_rq *rt_rq, struct sched_rt_entity *rt_se,
> 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:
> + */
> + if (p && !task_on_cpu(task_rq(p), p))
> + update_stats_wait_end_rt(rt_rq, rt_se);
> +
> if ((flags & DEQUEUE_SLEEP) && p) {
> unsigned int state;
>
prev parent reply other threads:[~2025-06-16 12:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-14 11:48 LiuJie Xie
2025-06-16 12:10 ` xieliujie [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=0911287d-b936-4a3d-af24-76c351393b5b@gmail.com \
--to=xieliujie92@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=xieliujie@xiaomi.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®