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:   Mon, 11 Nov 2019 23:38:26 +0100
From:   Frederic Weisbecker <frederic@...nel.org>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Ingo Molnar <mingo@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        "Paul E . McKenney" <paulmck@...ux.vnet.ibm.com>,
        Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [RFC PATCH 4/4] irq_work: Weaken ordering in irq_work_run_list()

On Mon, Nov 11, 2019 at 09:43:13AM +0100, Peter Zijlstra wrote:
> On Fri, Nov 08, 2019 at 05:08:58PM +0100, Frederic Weisbecker wrote:
> 
> > diff --git a/kernel/irq_work.c b/kernel/irq_work.c
> > index 49c53f80a13a..b709ab05cbfd 100644
> > --- a/kernel/irq_work.c
> > +++ b/kernel/irq_work.c
> > @@ -34,8 +34,8 @@ static bool irq_work_claim(struct irq_work *work)
> >  	oflags = atomic_fetch_or(IRQ_WORK_CLAIMED, &work->flags);
> >  	/*
> >  	 * If the work is already pending, no need to raise the IPI.
> > +	 * The pairing atomic_andnot() followed by a barrier in irq_work_run()
> > +	 * makes sure everything we did before is visible.
> >  	 */
> >  	if (oflags & IRQ_WORK_PENDING)
> >  		return false;
> 
> > @@ -151,14 +151,16 @@ static void irq_work_run_list(struct llist_head *list)
> >  		 * to claim that work don't rely on us to handle their data
> >  		 * while we are in the middle of the func.
> >  		 */
> > -		flags = atomic_fetch_andnot(IRQ_WORK_PENDING, &work->flags);
> > +		atomic_andnot(IRQ_WORK_PENDING, &work->flags);
> > +		smp_mb__after_atomic();
> 
> I think I'm prefering you use:
> 
> 		flags = atomic_fetch_andnot_acquire(IRQ_WORK_PENDING, &work->flags);

Ah good point. Preparing that.

> 
> Also, I'm cursing at myself for the horrible comments here.

Hmm, I wrote many of those, which one? :o)

Thanks.

> 
> >  		work->func(work);
> >  		/*
> >  		 * Clear the BUSY bit and return to the free state if
> >  		 * no-one else claimed it meanwhile.
> >  		 */
> > -		(void)atomic_cmpxchg(&work->flags, flags, flags & ~IRQ_WORK_BUSY);
> > +		(void)atomic_cmpxchg(&work->flags, flags & ~IRQ_WORK_PENDING,
> > +				     flags & ~IRQ_WORK_CLAIMED);
> >  	}
> >  }
> >  
> > -- 
> > 2.23.0
> > 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ