Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: Sven Schnelle <svens@xxxxxxxxxxxxx>
- Subject: Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state
- From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
- Date: Wed, 6 Jul 2022 10:59:00 +0200
- Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>, Alexander Gordeev <agordeev@xxxxxxxxxxxxx>, "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, rjw@xxxxxxxxxxxxx, Oleg Nesterov <oleg@xxxxxxxxxx>, mingo@xxxxxxxxxx, vincent.guittot@xxxxxxxxxx, dietmar.eggemann@xxxxxxx, mgorman@xxxxxxx, bigeasy@xxxxxxxxxxxxx, Will Deacon <will@xxxxxxxxxx>, tj@xxxxxxxxxx, linux-pm@xxxxxxxxxxxxxxx, Richard Weinberger <richard@xxxxxx>, Anton Ivanov <anton.ivanov@xxxxxxxxxxxxxxxxxx>, Johannes Berg <johannes@xxxxxxxxxxxxxxxx>, linux-um@xxxxxxxxxxxxxxxxxxx, Chris Zankel <chris@xxxxxxxxxx>, Max Filippov <jcmvbkbc@xxxxxxxxx>, linux-xtensa@xxxxxxxxxxxxxxxx, Kees Cook <keescook@xxxxxxxxxxxx>, Jann Horn <jannh@xxxxxxxxxx>, linux-ia64@xxxxxxxxxxxxxxx
- In-reply-to: <yt9dsfneaczk.fsf@linux.ibm.com>
- References: <87a6bv6dl6.fsf_-_@email.froward.int.ebiederm.org> <20220505182645.497868-12-ebiederm@xmission.com> <YrHA5UkJLornOdCz@li-4a3a4a4c-28e5-11b2-a85c-a8d192c6f089.ibm.com> <877d5ajesi.fsf@email.froward.int.ebiederm.org> <YrHgo8GKFPWwoBoJ@li-4a3a4a4c-28e5-11b2-a85c-a8d192c6f089.ibm.com> <20220628191541.34a073fc@gandalf.local.home> <yt9d5ykbekn3.fsf@linux.ibm.com> <yt9dpmijcvu6.fsf@linux.ibm.com> <YsSQRmCZSIQ1ewzo@worktop.programming.kicks-ass.net> <yt9dsfneaczk.fsf@linux.ibm.com>
On Wed, Jul 06, 2022 at 09:58:55AM +0200, Sven Schnelle wrote:
> >> [ 86.218551] kill_chi-343805 6d.... 79990141us : ptrace_stop: JOBCTL_TRACED already set, state=0 <------ valid combination of flags?
> >
> > Yeah, that's not supposed to be so. JOBCTL_TRACED is supposed to follow
> > __TASK_TRACED for now. Set when __TASK_TRACED, cleared when
> > TASK_RUNNING.
> >
> > Specifically {ptrace_,}signal_wake_up() in signal.h clear JOBCTL_TRACED
> > when they would wake a __TASK_TRACED task.
>
> try_to_wake_up() clears TASK_TRACED in this case because a signal
> (SIGKILL) has to be delivered. As a test I put the following change
> on top, and it "fixes" the problem:
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index da0bf6fe9ecd..f2e0f5e70e77 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -4141,6 +4149,9 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
> * TASK_WAKING such that we can unlock p->pi_lock before doing the
> * enqueue, such as ttwu_queue_wakelist().
> */
> + if (p->__state & TASK_TRACED)
> + trace_printk("clearing TASK_TRACED 2\n");
> + p->jobctl &= ~JOBCTL_TRACED;
> WRITE_ONCE(p->__state, TASK_WAKING);
>
> /*
>
> There are several places where the state is changed from TASK_TRACED to
> something else without clearing JOBCTL_TRACED.
I'm having difficulty spotting them; I find:
TASK_WAKEKILL: signal_wake_up()
__TASK_TRACED: ptrace_signal_wake_up(), ptrace_unfreeze_traced(), ptrace_resume()
And all those sites dutifully clear JOBCTL_TRACED.
I'd be most interested in the calstack for the 'clearing TASK_TRACED 2'
events to see where we miss a spot.
- References:
- [PATCH v4 0/12] ptrace: cleaning up ptrace_stop
- [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state
- Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state
- Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state
- Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state
- Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state
- Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state
- Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state
- Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state
- Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state
[Index of Archives]
[Linux Kernel]
[Sparc Linux]
[DCCP]
[Linux ARM]
[Yosemite News]
[Linux SCSI]
[Linux x86_64]
[Linux for Ham Radio]