public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	linux-kernel@vger.kernel.org, adobriyan@gmail.com,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [RFC][PATCH] task_struct::state frobbing
Date: Fri, 26 Mar 2021 08:58:27 +0100	[thread overview]
Message-ID: <YF2UI8LFH0YaY6aJ@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20210325182735.GA28349@redhat.com>

On Thu, Mar 25, 2021 at 07:27:35PM +0100, Oleg Nesterov wrote:
> On 03/25, Peter Zijlstra wrote:
> >
> >  static void ptrace_unfreeze_traced(struct task_struct *task)
> >  {
> > -	if (task->state != __TASK_TRACED)
> > +	if (READ_ONCE(task->__state) != __TASK_TRACED)
> >  		return;
> 
> this change is correct,
> 
> > @@ -201,11 +201,11 @@ static void ptrace_unfreeze_traced(struct task_struct *task)
> >  	 * Recheck state under the lock to close this race.
> >  	 */
> >  	spin_lock_irq(&task->sighand->siglock);
> > -	if (task->state == __TASK_TRACED) {
> > +	if (READ_ONCE(task->__state) == __TASK_TRACED) {
> 
> this too,
> 
> > @@ -240,7 +240,7 @@ static int ptrace_check_attach(struct task_struct *child, bool ignore_state)
> >  	 */
> >  	read_lock(&tasklist_lock);
> >  	if (child->ptrace && child->parent == current) {
> > -		WARN_ON(child->state == __TASK_TRACED);
> > +		WARN_ON(task_is_traced(child));
> >  		/*
> >  		 * child->sighand can't be NULL, release_task()
> >  		 * does ptrace_unlink() before __exit_signal().
> > @@ -257,7 +257,7 @@ static int ptrace_check_attach(struct task_struct *child, bool ignore_state)
> >  			 * ptrace_stop() changes ->state back to TASK_RUNNING,
> >  			 * so we should not worry about leaking __TASK_TRACED.
> >  			 */
> > -			WARN_ON(child->state == __TASK_TRACED);
> > +			WARN_ON(task_is_traced(child));
> 
> 
> the two above are not.
> 
> "state == __TASK_TRACED" and task_is_traced() is not the same thing.
> 
> "state == __TASK_TRACED" means that debugger changed the state from TASK_TRACED
> to __TASK_TRACED (iow, removed TASK_WAKEKILL) to ensure the tracee can not run,
> this doesn't affect task_is_traced().

Ah, my bad. I didn't expect the other bits to be relevant there,
should've read the code better. Will fix. Thanks!

  reply	other threads:[~2021-03-26  7:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25 18:11 [RFC][PATCH] task_struct::state frobbing Peter Zijlstra
2021-03-25 18:27 ` Oleg Nesterov
2021-03-26  7:58   ` Peter Zijlstra [this message]
2021-03-25 18:33 ` Steven Rostedt
2021-03-25 19:51 ` Thomas Gleixner
2021-03-26  7:56   ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YF2UI8LFH0YaY6aJ@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=adobriyan@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox