Skip to content

Commit f124c0e

Browse files
committed
sched: Fix trace_sched_switch(.prev_state)
JIRA: https://issues.redhat.com/browse/RHEL-110301 commit 8feb053 Author: Peter Zijlstra <[email protected]> Date: Wed Mar 19 22:23:23 2025 +0100 sched: Fix trace_sched_switch(.prev_state) Gabriele noted that in case of signal_pending_state(), the tracepoint sees a stale task-state. Fixes: fa2c325 ("sched/tracing: Don't re-read p->state when emitting sched_switch event") Reported-by: Gabriele Monaco <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Valentin Schneider <[email protected]> Signed-off-by: Phil Auld <[email protected]>
1 parent 53b7d2d commit f124c0e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/sched/core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6495,12 +6495,14 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
64956495
* Otherwise marks the task's __state as RUNNING
64966496
*/
64976497
static bool try_to_block_task(struct rq *rq, struct task_struct *p,
6498-
unsigned long task_state)
6498+
unsigned long *task_state_p)
64996499
{
6500+
unsigned long task_state = *task_state_p;
65006501
int flags = DEQUEUE_NOCLOCK;
65016502

65026503
if (signal_pending_state(task_state, p)) {
65036504
WRITE_ONCE(p->__state, TASK_RUNNING);
6505+
*task_state_p = TASK_RUNNING;
65046506
return false;
65056507
}
65066508

@@ -6637,7 +6639,7 @@ static void __sched notrace __schedule(int sched_mode)
66376639
goto picked;
66386640
}
66396641
} else if (!preempt && prev_state) {
6640-
try_to_block_task(rq, prev, prev_state);
6642+
try_to_block_task(rq, prev, &prev_state);
66416643
switch_count = &prev->nvcsw;
66426644
}
66436645

0 commit comments

Comments
 (0)