public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Manfred Spraul <manfred@colorfullife.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	LKML <linux-kernel@vger.kernel.org>,
	1vier1@web.de, Peter Zijlstra <peterz@infradead.org>,
	Kirill Tkhai <ktkhai@parallels.com>,
	Ingo Molnar <mingo@redhat.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>
Subject: Re: [RFC PATCH] ipc/sem.c: Add one more memory barrier to sem_lock().
Date: Thu, 26 Feb 2015 20:29:29 +0100	[thread overview]
Message-ID: <20150226192929.GA975@redhat.com> (raw)
In-Reply-To: <1424893009-27191-1-git-send-email-manfred@colorfullife.com>

Sorry Manfred, I initiated this discussion and then disappeared. Currently
I am buried in the ancient 2.16.18 bugs ;)

On 02/25, Manfred Spraul wrote:
> Hi,
>
> What do you think about the following patch for sem_lock()?
>
> Other options:
>
> 1) I don't like
>
> 	#define smp_mb__after_unlock_wait()	smp_rmb()
>
> 	I think it is too specific: the last block in sem_lock uses
>
> 		if (sma->complex_count == 0) {
> 			smp_rmb();
> 			return;
> 		}

See below.

>
> 2) What about
>
> 	#define smp_aquire__after_control_barrier()	smp_rmb()


I agree with any naming. The only point of the new helper is that we can
factor out the comment, otherwise we would need to repeat it again and again.


> @@ -341,7 +359,13 @@ static inline int sem_lock(struct sem_array *sma, struct sembuf *sops,
>  			 * Thus: if is now 0, then it will stay 0.
>  			 */
>  			if (sma->complex_count == 0) {
> -				/* fast path successful! */
> +				/*
> +				 * Fast path successful!
> +				 * We only need a final memory barrier.
> +				 * (see sem_wait_array() for details).
> +				 */
> +				smp_rmb();
> +

I'll try to read this again tomorrow, but so far I am confused.

Most probably I missed something, but this looks unneeded at first glance.

We already have another smp_rmb() above this check. And it should act as
a "final" barrier, or we can not trust this ->complex_count check ?

And (if I am right) this means that the comment above that rmb() should
be updated. And that is why I think the helper makes sense, the comment
should be almost the same as in sem_wait_array().

If not, could you please spell to explain why do we need another rmb() ?

Oleg.


  reply	other threads:[~2015-02-26 19:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-25 19:36 [RFC PATCH] ipc/sem.c: Add one more memory barrier to sem_lock() Manfred Spraul
2015-02-26 19:29 ` Oleg Nesterov [this message]
2015-02-26 19:46   ` Manfred Spraul

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=20150226192929.GA975@redhat.com \
    --to=oleg@redhat.com \
    --cc=1vier1@web.de \
    --cc=jpoimboe@redhat.com \
    --cc=ktkhai@parallels.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=mingo@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.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