lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 26 Apr 2018 11:14:49 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     "Kohli, Gaurav" <gkohli@...eaurora.org>
Cc:     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 09:34:36AM +0530, Kohli, Gaurav wrote:
> On 4/26/2018 1:39 AM, Peter Zijlstra wrote:
> 
> > On Wed, Apr 25, 2018 at 02:03:19PM +0530, Gaurav Kohli wrote:
> > > diff --git a/kernel/smpboot.c b/kernel/smpboot.c
> > > index 5043e74..c5c5184 100644
> > > --- a/kernel/smpboot.c
> > > +++ b/kernel/smpboot.c
> > > @@ -122,7 +122,45 @@ static int smpboot_thread_fn(void *data)
> > >   		}
> > >   		if (kthread_should_park()) {
> > > +			/*
> > > +			 * Serialize against wakeup.
> > 			 *
> > 			 * Prior wakeups must complete and later wakeups
> > 			 * will observe TASK_RUNNING.
> > 			 *
> > 			 * This avoids the case where the TASK_RUNNING
> > 			 * store from ttwu() competes with the
> > 			 * TASK_PARKED store from kthread_parkme().
> > 			 *
> > 			 * If the TASK_PARKED store looses that
> > 			 * competition, kthread_unpark() will go wobbly.
> > > +			 */
> > > +			raw_spin_lock(&current->pi_lock);
> > >   			__set_current_state(TASK_RUNNING);
> > > +			raw_spin_unlock(&current->pi_lock);
> > >   			preempt_enable();
> > >   			if (ht->park && td->status == HP_THREAD_ACTIVE) {
> > >   				BUG_ON(td->cpu != smp_processor_id());
> > Does that work for you?
> 
> We have given patch for testing, usually it takes around 2-3 days for
> reproduction(we will update for the same).

I only changed the comment; surely your compiler doesn't generate
different code for that?

I was asking if the proposed comment was good with you; but see my more
recent email, that actually proposes a different fix.

> > 			/*
> > 			 * A similar race is possible here, but loosing
> > 			 * the TASK_INTERRUPTIBLE store is harmless and
> > 			 * will make us go around the loop once more.
> > 			 */
> 
> Actually instead of race, i am seeing wakeup miss problem which is
> very rare, if we take case of hotplug thread

Yes, triggering these issues is tricky, no doubt about that.

> > And of course, I suspect we actually want to use TASK_IDLE, smpboot
> > threads don't want signals do they? But that probably ought to be a
> > separate patch.
> 
> Yes I agree, we can control race from here as well,  Please suggest
> would below change be any help here:

That is not what I suggested. I said the thing should use TASK_IDLE
instead of TASK_INTERRUPTIBLE. Not change the location of it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ