sched/stats: Fix rt/dl task's sched latency statistics error in sched_stat_wait tracepoint
PATCH v5 1/1 sched/stats: Fix rt/dl task's sched latency statistics error in sched_stat_wait tracepoint
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.
--- kernel/sched/deadline.c | 5 ++++- kernel/sched/rt.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +4 -1
@@ -1558,10 +1558,13 @@ 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.*/ +if (p && (p != rq->curr)) +update_stats_wait_end_dl (dl_rq, dl_se);if ((flags &DEQUEUE_SLEEP )) {unsigned int state;
kernel/sched/rt.c +4 -0
@@ -1360,12 +1360,16 @@ 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. */ +if (p && (p != rq->curr)) +update_stats_wait_end_rt (rt_rq, rt_se);if ((flags &DEQUEUE_SLEEP ) && p) {unsigned int state;
Signature · 1 line
2.34.1
Quoted 5 lines · Junwen Wu
The
sched_stat_waittracepoint is showing unreasonably long latencies for real-time tasks. For example:
sched_stat_wait: comm=rcu_preempt pid=14 delay=4936139545261 [ns]
Quoted 7 lines
This error happens when the rt task balances off the source CPU because the dequeue operation is not updating the
sched_statistics. So, followupdate_stats_wait_end_fair()and update the stats. Do the same forSCHED_DEADLINE.Fixes 57a5c2dafca8 ("sched/rt: Support schedstats for RT sched class")Fixes b5eb4a5f6521 ("sched/dl: Support schedstats for deadline sched class")
Thanks
-- Daniel
Quoted 4 lines
Reviewed-by Daniel Bristot de Oliveira <[email protected]>Thanks
-- Daniel
Hi, Daniel, this change is pending one month, when this change can be merged into mainline? Thanks
--
Best regards