diff --git a/include/linux/sched.h b/include/linux/sched.h index c46f3a63b758..c2ddc47271b8 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -154,8 +154,8 @@ struct task_group; } while (0) #else -# define debug_normal_state_change(cond) do { } while (0) -# define debug_special_state_change(cond) do { } while (0) +# define debug_normal_state_change(cond) do { trace_printk("state %d\n", cond); } while (0) +# define debug_special_state_change(cond) do { trace_printk("state %d\n", cond); } while (0) # define debug_rtlock_wait_set_state() do { } while (0) # define debug_rtlock_wait_restore_state() do { } while (0) #endif diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 156a99283b11..2cb2ae8acf23 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -202,6 +202,7 @@ static bool ptrace_freeze_traced(struct task_struct *task) spin_lock_irq(&task->sighand->siglock); if (task_is_traced(task) && !looks_like_a_spurious_pid(task) && !__fatal_signal_pending(task)) { + trace_printk("task_is_traced: %d, fatal signal pending: %d\n", task_is_traced(task), __fatal_signal_pending(task)); task->jobctl |= JOBCTL_PTRACE_FROZEN; ret = true; } @@ -263,8 +264,10 @@ static int ptrace_check_attach(struct task_struct *child, bool ignore_state) * child->sighand can't be NULL, release_task() * does ptrace_unlink() before __exit_signal(). */ - if (ignore_state || ptrace_freeze_traced(child)) + if (ignore_state || ptrace_freeze_traced(child)) { + trace_printk("child->pid = %d, child->__flags=%d\n", child->pid, child->__state); ret = 0; + } } read_unlock(&tasklist_lock); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index da0bf6fe9ecd..73bb4c7882d0 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3301,8 +3301,10 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state * is actually now running somewhere else! */ while (task_running(rq, p)) { - if (match_state && unlikely(READ_ONCE(p->__state) != match_state)) + if (match_state && unlikely(READ_ONCE(p->__state) != match_state)) { + trace_printk("NO MATCH: state %d, match_state %d, pid %d\n", p->__state, match_state, p->pid); return 0; + } cpu_relax(); } diff --git a/kernel/signal.c b/kernel/signal.c index edb1dc9b00dc..0ea8e6b6a641 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2232,6 +2232,8 @@ static int ptrace_stop(int exit_code, int why, unsigned long message, if (!current->ptrace || __fatal_signal_pending(current)) return exit_code; + if (current->jobctl & JOBCTL_TRACED) + trace_printk("JOBCTL_TRACED already set, state=%d\n", current->__state); set_special_state(TASK_TRACED); current->jobctl |= JOBCTL_TRACED;