* [PATCH] sched/rt: Update wait_time when doing migration.
@ 2025-04-14 11:48 LiuJie Xie
2025-06-16 12:10 ` xieliujie
0 siblings, 1 reply; 2+ messages in thread
From: LiuJie Xie @ 2025-04-14 11:48 UTC (permalink / raw)
To: mingo, peterz; +Cc: linux-kernel, xieliujie92, 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;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sched/rt: Update wait_time when doing migration.
2025-04-14 11:48 [PATCH] sched/rt: Update wait_time when doing migration LiuJie Xie
@ 2025-06-16 12:10 ` xieliujie
0 siblings, 0 replies; 2+ messages in thread
From: xieliujie @ 2025-06-16 12:10 UTC (permalink / raw)
To: mingo, peterz; +Cc: linux-kernel, LiuJie Xie
[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;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-16 12:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-14 11:48 [PATCH] sched/rt: Update wait_time when doing migration LiuJie Xie
2025-06-16 12:10 ` xieliujie
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).