Skip to content

Commit 5ebde09

Browse files
Hao JiaPeter Zijlstra
authored andcommitted
sched/core: Fix RQCF_ACT_SKIP leak
Igor Raits and Bagas Sanjaya report a RQCF_ACT_SKIP leak warning. This warning may be triggered in the following situations: CPU0 CPU1 __schedule() *rq->clock_update_flags <<= 1;* unregister_fair_sched_group() pick_next_task_fair+0x4a/0x410 destroy_cfs_bandwidth() newidle_balance+0x115/0x3e0 for_each_possible_cpu(i) *i=0* rq_unpin_lock(this_rq, rf) __cfsb_csd_unthrottle() raw_spin_rq_unlock(this_rq) rq_lock(*CPU0_rq*, &rf) rq_clock_start_loop_update() rq->clock_update_flags & RQCF_ACT_SKIP <-- raw_spin_rq_lock(this_rq) The purpose of RQCF_ACT_SKIP is to skip the update rq clock, but the update is very early in __schedule(), but we clear RQCF_*_SKIP very late, causing it to span that gap above and triggering this warning. In __schedule() we can clear the RQCF_*_SKIP flag immediately after update_rq_clock() to avoid this RQCF_ACT_SKIP leak warning. And set rq->clock_update_flags to RQCF_UPDATED to avoid rq->clock_update_flags < RQCF_ACT_SKIP warning that may be triggered later. Fixes: ebb83d8 ("sched/core: Avoid multiple calling update_rq_clock() in __cfsb_csd_unthrottle()") Closes: https://lore.kernel.org/all/[email protected] Reported-by: Igor Raits <[email protected]> Reported-by: Bagas Sanjaya <[email protected]> Suggested-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Hao Jia <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/all/[email protected]
1 parent 4e5b65a commit 5ebde09

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

kernel/sched/core.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5361,8 +5361,6 @@ context_switch(struct rq *rq, struct task_struct *prev,
53615361
/* switch_mm_cid() requires the memory barriers above. */
53625362
switch_mm_cid(rq, prev, next);
53635363

5364-
rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP);
5365-
53665364
prepare_lock_switch(rq, next, rf);
53675365

53685366
/* Here we just switch the register state and the stack. */
@@ -6600,6 +6598,7 @@ static void __sched notrace __schedule(unsigned int sched_mode)
66006598
/* Promote REQ to ACT */
66016599
rq->clock_update_flags <<= 1;
66026600
update_rq_clock(rq);
6601+
rq->clock_update_flags = RQCF_UPDATED;
66036602

66046603
switch_count = &prev->nivcsw;
66056604

@@ -6679,8 +6678,6 @@ static void __sched notrace __schedule(unsigned int sched_mode)
66796678
/* Also unlocks the rq: */
66806679
rq = context_switch(rq, prev, next, &rf);
66816680
} else {
6682-
rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP);
6683-
66846681
rq_unpin_lock(rq, &rf);
66856682
__balance_callbacks(rq);
66866683
raw_spin_rq_unlock_irq(rq);

0 commit comments

Comments
 (0)