[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180430112029.GF4082@hirez.programming.kicks-ass.net>
Date: Mon, 30 Apr 2018 13:20:29 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Gaurav Kohli <gkohli@...eaurora.org>, tglx@...utronix.de,
mpe@...erman.id.au, mingo@...nel.org, bigeasy@...utronix.de,
linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
Neeraj Upadhyay <neeraju@...eaurora.org>,
Will Deacon <will.deacon@....com>
Subject: Re: [PATCH v1] kthread/smpboot: Serialize kthread parking against
wakeup
On Thu, Apr 26, 2018 at 06:18:20PM +0200, Oleg Nesterov wrote:
> On 04/26, Peter Zijlstra wrote:
> >
> > For the others, I think we want to do something like the below. I still
> > need to look at TASK_TRACED, which I suspect is also special,
>
> Yes, and TASK_STOPPED.
I already did that one, right ;-)
>
> ptrace_freeze_traced() and ptrace_unfreeze_traced() should be fine, but
> ptrace_stop() wants set_special_state() too, I think.
Thanks for going through that, I'll update the patch.
> > +/*
> > + * set_special_state() should be used for those states when the blocking task
> > + * can not use the regular condition based wait-loop. In that case we must
> > + * serialize against wakeups such that any possible in-flight TASK_RUNNING stores
> > + * will not collide with out state change.
> > + */
> > +#define set_special_state(state_value) \
> > + do { \
> > + unsigned long flags; /* may shadow */ \
> > + raw_spin_lock_irqsave(¤t->pi_lock, flags); \
> > + current->state = (state_value); \
> > + raw_spin_unlock_irqrestore(¤t->pi_lock, flags); \
> > + } while (0)
> > +
>
> Agreed.
>
> I thought that perhaps we can change ttwu_do_wakeup() cmpxchg() instead of
> plain p->state = TASK_RUNNING, but this helper looks much more clear and simple.
Aside from cmpxchg() slowing down the common fast path, that also
would not work on architectures where cmpxchg() is not in fact atomic vs
regular stores (and yes, sadly we still have those, PARISC and SPARC32
come to mind).
Powered by blists - more mailing lists