From: Manfred Spraul <manfred@colorfullife.com>
To: Davidlohr Bueso <dave@stgolabs.net>,
Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>, Darren Hart <darren@dvhart.com>,
Steven Rostedt <rostedt@goodmis.org>,
fredrik.markstrom@windriver.com,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: Re: [PATCH v2] ipc/mqueue: remove STATE_PENDING
Date: Wed, 29 Apr 2015 21:44:28 +0200 [thread overview]
Message-ID: <5541349C.5060000@colorfullife.com> (raw)
In-Reply-To: <1430240361.2004.13.camel@stgolabs.net>
Hi Davidlohr,
On 04/28/2015 06:59 PM, Davidlohr Bueso wrote:
> On Tue, 2015-04-28 at 18:43 +0200, Peter Zijlstra wrote:
>> Well, if you can 'guarantee' the cmpxchg will not fail, you can then
>> rely on the fact that cmpxchg implies a full barrier, which would
>> obviate the need for the wmb.
> Yes, assuming it implies barriers on both sides. And we could obviously
> remove the need for pairing. With wake_q being local to wq_sleep() I
> cannot see duplicate tasks trying to add themselves in the list. Failed
> cmpxchg should only occur when users start misusing the wake_q.
>
> Manfred, do you have any objections to this? Perhaps I've missed the
> real purpose of the barriers.
I don't remember the details either, so let's check what should happen:
CPU1: sender copies message to kernel memory
aaaa
CPU1: sender does receiver->msg = message;
** barrier 1
CPU1: sender does receiver->state = STATE_READY;
CPU2: receiver notices receiver->state = STATE_READY;
** barrier 2
CPU2: receiver reads receiver->msg
bbbb
CPU2: receiver reads *receiver->msg
Failures would be:
- write to receiver->state is visible before the write to receiver->msg
or to *receiver->msg
** barrier 1 needs to be an smp_wmb()
- cpu 2 reads receiver->msg before receiver->state
** barrier 2 needs to be an smp_rmb().
As far as I can see, no barrier is needed in pos aaaa or bbbb.
With regards to failed cmpxchg():
I don't see that mqueue could cause it by itself.
Who is allowed to use wake_q?
If it is permitted to use wake_q for e.g. timeout/signal delivery
wakeup, then that user might have a pending wakeup stored in the task
struct.
--
Manfred
next prev parent reply other threads:[~2015-04-29 19:44 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-07 15:03 improve futex on -RT by avoiding the double wake-up Sebastian Andrzej Siewior
2015-04-07 15:03 ` [PATCH 1/3] futex: avoid double wake up in PI futex wait / wake on -RT Sebastian Andrzej Siewior
2015-04-07 18:41 ` Thomas Gleixner
2015-04-10 14:42 ` [PATCH 1/3 v2] " Sebastian Andrzej Siewior
2015-04-07 15:03 ` [PATCH 2/3] futex: avoid double wake up in futex_wake() " Sebastian Andrzej Siewior
2015-04-07 19:47 ` Thomas Gleixner
2015-04-10 16:11 ` [PATCH 2/3 v2] " Sebastian Andrzej Siewior
2015-04-13 3:02 ` Davidlohr Bueso
2015-04-16 5:09 ` Davidlohr Bueso
2015-04-16 9:19 ` Thomas Gleixner
2015-04-16 10:16 ` Peter Zijlstra
2015-04-16 10:49 ` Thomas Gleixner
2015-04-16 14:42 ` Davidlohr Bueso
2015-04-16 15:54 ` Peter Zijlstra
2015-04-16 16:22 ` Davidlohr Bueso
2015-04-07 15:03 ` [PATCH 3/3] ipc/mqueue: remove STATE_PENDING Sebastian Andrzej Siewior
2015-04-07 17:48 ` Manfred Spraul
2015-04-07 18:28 ` Thomas Gleixner
2015-04-10 14:37 ` [PATCH v2] " Sebastian Andrzej Siewior
2015-04-23 22:18 ` Thomas Gleixner
2015-04-28 3:24 ` Davidlohr Bueso
2015-04-28 12:37 ` Peter Zijlstra
2015-04-28 16:36 ` Davidlohr Bueso
2015-04-28 16:43 ` Peter Zijlstra
2015-04-28 16:59 ` Davidlohr Bueso
2015-04-29 19:44 ` Manfred Spraul [this message]
2015-04-30 18:46 ` Davidlohr Bueso
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=5541349C.5060000@colorfullife.com \
--to=manfred@colorfullife.com \
--cc=bigeasy@linutronix.de \
--cc=darren@dvhart.com \
--cc=dave@stgolabs.net \
--cc=fredrik.markstrom@windriver.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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
Powered by JetHome