sched/rt: Fix rt task's sched latency statistics error in sched_stat_wait trace_point
PATCH v2 1/1 sched/rt: Fix rt task's sched latency statistics error in sched_stat_wait trace_point
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.
---
Changes since v1:
https://lore.kernel.org/all/[email protected]/
kernel/sched/rt.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/sched/rt.c +7 -0
@@ -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. +*/ +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 27 lines · Junwen Wu
When enable
sched_stat_waittrace_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 thesched_statistics, so followupdate_stats_wait_end_fairupdate method.Signed-off-by Junwen Wu <[email protected]>---
Changes since v1:
https://lore.kernel.org/all/[email protected]/kernel/sched/rt.c | 7 +++++++ 1 file changed, 7 insertions(+)kernel/sched/rt.c +1
-0@@ -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 ())
kernel/sched/rt.c update_stats_dequeue_rt(struct rt_rq *rt_rq, struct sched_rt_entity *rt_se, · line 1375
Quoted 10 lines
kernel/sched/rt.c +6
-0return ;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);
It seems DL has the same issue. Pls. also fix it in update_stats_dequeue_dl(). And add the Fixes tag in the commit log:
Quoted 6 lines
kernel/sched/rt.c +0
-1if ((flags &DEQUEUE_SLEEP ) && p) {unsigned int state; --2.34.1
Signature · 2 lines
Regards Yafang
Quoted 4 lines
It seems DL has the same issue. Pls. also fix it in
update_stats_dequeue_dl(). And add the Fixes tag in the commit log:Fixes 57a5c2dafca8 ("sched/rt: Support schedstats for RT sched class")Fixes b5eb4a5f6521 ("sched/dl: Support schedstats for deadline sched class")
ok, the PATCH v3 below is ok?
Subject: [PATCH v3] sched/stats: Fix rt/dl task's sched latency statistics
error in sched_stat_wait trace_point
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.
--- kernel/sched/deadline.c | 8 +++++++- kernel/sched/rt.c | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +7 -1
@@ -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. +*/ +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 +7 -0
@@ -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. +*/ +if (p && (p != rq->curr)) +update_stats_wait_end_rt (rt_rq, rt_se);if ((flags &DEQUEUE_SLEEP ) && p) {unsigned int state;
--
Best regards
Yafang Shao
Acked-byQuoted 17 lines · Junwen Wu
Quoted 5 lines
It seems DL has the same issue. Pls. also fix it in
update_stats_dequeue_dl(). And add the Fixes tag in the commit log:Fixes 57a5c2dafca8 ("sched/rt: Support schedstats for RT sched class")Fixes b5eb4a5f6521 ("sched/dl: Support schedstats for deadline sched class")ok, the PATCH v3 below is ok?
Subject: [PATCH v3] sched/stats: Fix rt/dl task's sched latency statistics
error insched_stat_waittrace_pointWhen enable
sched_stat_waittrace_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 thesched_statistics, so followupdate_stats_wait_end_fairupdate method, so do dl tasks.
Quoted 3 lines
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 <[email protected]>
Quoted 55 lines
--- kernel/sched/deadline.c | 8 +++++++- kernel/sched/rt.c | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-)kernel/sched/deadline.c +7
-1@@ -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. +*/ +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 +7
-1@@ -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. +*/ +if (p && (p != rq->curr)) +update_stats_wait_end_rt (rt_rq, rt_se);if ((flags &DEQUEUE_SLEEP ) && p) {unsigned int state; --Best regards
Signature · 2 lines
Regards Yafang