Re: [PATCH] lib/klist: Remove mb() before wake_up_process

From: Greg KH
Date: Wed Jun 15 2022 - 03:41:18 EST


On Wed, Jun 15, 2022 at 11:30:51AM +0800, chi wu wrote:
> Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> 于2022年6月14日周二 22:58写道:
> >
> > On Tue, Jun 14, 2022 at 10:44:43PM +0800, wuchi wrote:
> > > Function wake_up_process always executes a general memory barrier,
> > > so remove the mb() before it.
> >
> > Really? On all systems? I do not see that, where does it happen?
> >
> As I understand it, it is on all systems. Please help correct the
> mistake, thanks.
>
> 1. Follow Documentation/memory-barriers.txt line 2128 ~ 2278,
> especially line 2187 ~ 2202 snippet:
> A general memory barrier is executed by wake_up() if it wakes
> something up.
> If it doesn't wake anything up then a memory barrier may or may not be
> executed; you must not rely on it.

So as the documentation states, it might not be there, so if you have to
have a memory barrier, you must not rely on this function to provide it.

So unless you have testing proof otherwise, the code should be correct
as-is.

thanks,

greg k-h