Skip to content

Commit b171501

Browse files
Cruz ZhaoPeter Zijlstra
authored andcommitted
sched/core: Accounting forceidle time for all tasks except idle task
There are two types of forced idle time: forced idle time from cookie'd task and forced idle time form uncookie'd task. The forced idle time from uncookie'd task is actually caused by the cookie'd task in runqueue indirectly, and it's more accurate to measure the capacity loss with the sum of both. Assuming cpu x and cpu y are a pair of SMT siblings, consider the following scenarios: 1.There's a cookie'd task running on cpu x, and there're 4 uncookie'd tasks running on cpu y. For cpu x, there will be 80% forced idle time (from uncookie'd task); for cpu y, there will be 20% forced idle time (from cookie'd task). 2.There's a uncookie'd task running on cpu x, and there're 4 cookie'd tasks running on cpu y. For cpu x, there will be 80% forced idle time (from cookie'd task); for cpu y, there will be 20% forced idle time (from uncookie'd task). The scenario1 can recurrent by stress-ng(scenario2 can recurrent similary): (cookie'd)taskset -c x stress-ng -c 1 -l 100 (uncookie'd)taskset -c y stress-ng -c 4 -l 100 In the above two scenarios, the total capacity loss is 1 cpu, but in scenario1, the cookie'd forced idle time tells us 20% cpu capacity loss, in scenario2, the cookie'd forced idle time tells us 80% cpu capacity loss, which are not accurate. It'll be more accurate to measure with cookie'd forced idle time and uncookie'd forced idle time. Signed-off-by: Cruz Zhao <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Josh Don <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2d02fa8 commit b171501

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

kernel/sched/core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5822,8 +5822,7 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
58225822
}
58235823

58245824
if (schedstat_enabled() && rq->core->core_forceidle_count) {
5825-
if (cookie)
5826-
rq->core->core_forceidle_start = rq_clock(rq->core);
5825+
rq->core->core_forceidle_start = rq_clock(rq->core);
58275826
rq->core->core_forceidle_occupation = occ;
58285827
}
58295828

kernel/sched/core_sched.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ void __sched_core_account_forceidle(struct rq *rq)
277277
rq_i = cpu_rq(i);
278278
p = rq_i->core_pick ?: rq_i->curr;
279279

280-
if (!p->core_cookie)
280+
if (p == rq_i->idle)
281281
continue;
282282

283283
__schedstat_add(p->stats.core_forceidle_sum, delta);

0 commit comments

Comments
 (0)