sched: Fix trace_sched_switch(.prev_state)
[ Upstream commit 8feb053d53194382fcfb68231296fdc220497ea6 ]
Gabriele noted that in case of signal_pending_state(), the tracepoint
sees a stale task-state.
Fixes: fa2c3254d7 ("sched/tracing: Don't re-read p->state when emitting sched_switch event")
Reported-by: Gabriele Monaco <gmonaco@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Valentin Schneider <vschneid@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
e8d0d9ae99
commit
623074162b
@@ -6517,12 +6517,14 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
|
||||
* Otherwise marks the task's __state as RUNNING
|
||||
*/
|
||||
static bool try_to_block_task(struct rq *rq, struct task_struct *p,
|
||||
unsigned long task_state)
|
||||
unsigned long *task_state_p)
|
||||
{
|
||||
unsigned long task_state = *task_state_p;
|
||||
int flags = DEQUEUE_NOCLOCK;
|
||||
|
||||
if (signal_pending_state(task_state, p)) {
|
||||
WRITE_ONCE(p->__state, TASK_RUNNING);
|
||||
*task_state_p = TASK_RUNNING;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -6656,7 +6658,7 @@ static void __sched notrace __schedule(int sched_mode)
|
||||
goto picked;
|
||||
}
|
||||
} else if (!preempt && prev_state) {
|
||||
try_to_block_task(rq, prev, prev_state);
|
||||
try_to_block_task(rq, prev, &prev_state);
|
||||
switch_count = &prev->nvcsw;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user