linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Jan Stancek <jstancek@redhat.com>
Cc: Will Deacon <will@kernel.org>, Waiman Long <longman@redhat.com>,
	linux-kernel@vger.kernel.org, dbueso@suse.de, mingo@redhat.com,
	jade alglave <jade.alglave@arm.com>,
	paulmck@linux.vnet.ibm.com
Subject: Re: [PATCH v2] locking/rwsem: add acquire barrier to read_slowpath exit when queue is empty
Date: Thu, 18 Jul 2019 13:04:46 +0200	[thread overview]
Message-ID: <20190718110446.GC3419@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <79224323.853324.1563447052432.JavaMail.zimbra@redhat.com>

On Thu, Jul 18, 2019 at 06:50:52AM -0400, Jan Stancek wrote:
> > In writing this, I also noticed that we don't have any explicit ordering
> > at the end of the reader slowpath when we wait on the queue but get woken
> > immediately:
> > 
> > 	if (!waiter.task)
> > 		break;
> > 
> > Am I missing something?
> 
> I'm assuming this isn't problem, because set_current_state() on line above
> is using smp_store_mb().


X = 0;

								X = 1;
	rwsem_down_read()					rwsem_up_write();

	  for (;;) {
	    set_current_state(TASK_UNINTERRUPTIBLE);

								  rwsem_mark_wake()
								    atomic_long_add(adjustment, &sem->count);
								    smp_store_release(&waiter->task, NULL);

	    if (!waiter.task)
	      break;

	    ...
	  }


	r = X;


can I think result in r==0 just fine, because there's nothing ordering
the load of waiter.task with the store of X.

It is exceedingly unlikely, but not impossible afaict.

  reply	other threads:[~2019-07-18 11:04 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-16 16:04 [PATCH] locking/rwsem: use read_acquire in read_slowpath exit when queue is empty Jan Stancek
2019-07-16 16:53 ` Waiman Long
2019-07-16 18:34   ` Jan Stancek
2019-07-16 18:58   ` Peter Zijlstra
2019-07-16 19:09     ` Waiman Long
2019-07-17 12:02     ` [PATCH v2] locking/rwsem: add acquire barrier to " Jan Stancek
2019-07-17 13:13       ` Will Deacon
2019-07-17 14:19         ` Waiman Long
2019-07-17 19:22           ` Jan Stancek
2019-07-17 19:39             ` Waiman Long
2019-07-18  8:51               ` [PATCH v3] " Jan Stancek
2019-07-25 16:00                 ` [tip:locking/core] locking/rwsem: Add missing ACQUIRE " tip-bot for Jan Stancek
2019-07-18  9:26             ` [PATCH v2] locking/rwsem: add acquire barrier " Will Deacon
2019-07-18 10:50               ` Jan Stancek
2019-07-18 11:04                 ` Peter Zijlstra [this message]
2019-07-18 11:09                   ` Peter Zijlstra
2019-07-18 11:36                     ` Jan Stancek
2019-07-18 12:12                 ` Paul E. McKenney
2019-07-18 10:58               ` Peter Zijlstra
2019-07-18 11:45                 ` Will Deacon
2019-07-18 12:23                   ` Peter Zijlstra
2019-07-17 15:33       ` Waiman Long

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=20190718110446.GC3419@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=dbueso@suse.de \
    --cc=jade.alglave@arm.com \
    --cc=jstancek@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=will@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;
as well as URLs for NNTP newsgroup(s).