Sched/fair: Improve the accuracy of sched_stat_wait statistics
PATCH 1/1 Sched/fair: Improve the accuracy of sched_stat_wait statistics
From: jun qian <[email protected]>
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 (rq_of(cfs_rq)) - se->statistics.wait_start) wrong. We need to avoid this scenario.
--- kernel/sched/fair.c | 9 +++++++++ 1 file changed, 9 insertions(+)
kernel/sched/fair.c +9 -0
@@ -906,6 +906,15 @@ static void update_curr_fair(struct rq *rq)if (!schedstat_enabled ())return ; +/* +* 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 (se->statistics.wait_start))) +return ; + delta =rq_clock (rq_of (cfs_rq)) -schedstat_val (se->statistics.wait_start);if (entity_is_task (se)) {
Signature · 1 line
1.8.3.1
Peter Zijlstra
maintainerQuoted 9 lines · On Fri, Oct 09, 2020 at 05:25:30PM +0800, [email protected] wrote:
From: jun qian <[email protected]>
When the
sched_schedstatchanges from 0 to 1, some sched se maybe already in the runqueue, these->statistics.wait_startwill be 0. So it will let the (rq_of(cfs_rq)) -se->statistics.wait_start) wrong. We need to avoid this scenario.Signed-off-by jun qian <[email protected]>Signed-off-by Yafang Shao <[email protected]>
This SoB chain isn't valid. Did Yafang's tag need to a reviewed-by or something?
Quoted 27 lines
--- kernel/sched/fair.c | 9 +++++++++ 1 file changed, 9 insertions(+)kernel/sched/fair.c +9
-0@@ -906,6 +906,15 @@ static void update_curr_fair(struct rq *rq)if (!schedstat_enabled ())return ; +/* +* 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 (se->statistics.wait_start))) +return ; + delta =rq_clock (rq_of (cfs_rq)) -schedstat_val (se->statistics.wait_start);if (entity_is_task (se)) {Signature · 1 line
1.8.3.1
Yafang Shao
Reviewed-byQuoted 9 lines · Peter Zijlstra
Quoted 7 lines · On Fri, Oct 09, 2020 at 05:25:30PM +0800, [email protected] wrote:
From: jun qian <[email protected]>
When the
sched_schedstatchanges from 0 to 1, some sched se maybe already in the runqueue, these->statistics.wait_startwill be 0. So it will let the (rq_of(cfs_rq)) -se->statistics.wait_start) wrong. We need to avoid this scenario.
Quoted 6 lines
Quoted 2 lines
Signed-off-by jun qian <[email protected]>Signed-off-by Yafang Shao <[email protected]>This SoB chain isn't valid. Did Yafang's tag need to a reviewed-by or something?
This patch improves the behavior when sched_schedstat is changed from 0 to 1, so it looks good to me.
Quoted 27 lines
Quoted 27 lines
--- kernel/sched/fair.c | 9 +++++++++ 1 file changed, 9 insertions(+)kernel/sched/fair.c +9
-1@@ -906,6 +906,15 @@ static void update_curr_fair(struct rq *rq)if (!schedstat_enabled ())return ; +/* +* 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 (se->statistics.wait_start))) +return ; + delta =rq_clock (rq_of (cfs_rq)) -schedstat_val (se->statistics.wait_start);if (entity_is_task (se)) { --1.8.3.1
Signature · 2 lines
Thanks Yafang