[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200212210053.GA80993@mtj.thefacebook.com>
Date: Wed, 12 Feb 2020 16:00:53 -0500
From: Tejun Heo <tj@...nel.org>
To: Andrea Parri <parri.andrea@...il.com>
Cc: linux-kernel@...r.kernel.org,
Lai Jiangshan <jiangshanlai@...il.com>,
"Paul E . McKenney" <paulmck@...nel.org>,
Randy Dunlap <rdunlap@...radead.org>
Subject: Re: [PATCH v2] workqueue: Document (some) memory-ordering properties
of {queue,schedule}_work()
On Wed, Jan 22, 2020 at 07:39:52PM +0100, Andrea Parri wrote:
> It's desirable to be able to rely on the following property: All stores
> preceding (in program order) a call to a successful queue_work() will be
> visible from the CPU which will execute the queued work by the time such
> work executes, e.g.,
>
> { x is initially 0 }
>
> CPU0 CPU1
>
> WRITE_ONCE(x, 1); [ "work" is being executed ]
> r0 = queue_work(wq, work); r1 = READ_ONCE(x);
>
> Forbids: r0 == true && r1 == 0
>
> The current implementation of queue_work() provides such memory-ordering
> property:
>
> - In __queue_work(), the ->lock spinlock is acquired.
>
> - On the other side, in worker_thread(), this same ->lock is held
> when dequeueing work.
>
> So the locking ordering makes things work out.
>
> Add this property to the DocBook headers of {queue,schedule}_work().
>
> Suggested-by: Paul E. McKenney <paulmck@...nel.org>
> Signed-off-by: Andrea Parri <parri.andrea@...il.com>
> Acked-by: Paul E. McKenney <paulmck@...nel.org>
Applied to wq/for-5.7.
Thanks.
--
tejun
Powered by blists - more mailing lists