public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Parri <parri.andrea@gmail.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>,
	Lai Jiangshan <jiangshanlai@gmail.com>
Subject: Re: [PATCH] workqueue: Document (some) memory-ordering properties of {queue,schedule}_work()
Date: Mon, 20 Jan 2020 21:44:29 +0100	[thread overview]
Message-ID: <20200120204429.GA1473@andrea> (raw)
In-Reply-To: <20200120020235.GA8126@paulmck-ThinkPad-P72>

On Sun, Jan 19, 2020 at 06:02:35PM -0800, Paul E. McKenney wrote:
> On Sat, Jan 18, 2020 at 10:58:20PM +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@kernel.org>
> > Signed-off-by: Andrea Parri <parri.andrea@gmail.com>
> 
> Acked-by: Paul E. McKenney <paulmck@kernel.org>

Thanks!

>
> An alternative to Randy's suggestion of dropping the comma following
> the "cf." is to just drop that whole phrase.  I will let you and Randy
> work that one out, though.  ;-)

Either way works for me.

I'd give Tejun and Lai some more time to review this and send a non-RFC with
your Ack and this nit fixed later this week (unless I hear some objections).

Thanks,
  Andrea

      reply	other threads:[~2020-01-20 20:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-18 21:58 [PATCH] workqueue: Document (some) memory-ordering properties of {queue,schedule}_work() Andrea Parri
2020-01-19  3:07 ` Randy Dunlap
2020-01-20  2:02 ` Paul E. McKenney
2020-01-20 20:44   ` Andrea Parri [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200120204429.GA1473@andrea \
    --to=parri.andrea@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox