From: Manfred Spraul <manfred@colorfullife.com>
To: LKML <linux-kernel@vger.kernel.org>,
Davidlohr Bueso <dave@stgolabs.net>,
Waiman Long <longman@redhat.com>
Cc: 1vier1@web.de, Andrew Morton <akpm@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Jonathan Corbet <corbet@lwn.net>,
Manfred Spraul <manfred@colorfullife.com>
Subject: [PATCH 0/6] V2: Clarify/standardize memory barriers for ipc
Date: Sat, 12 Oct 2019 07:49:52 +0200 [thread overview]
Message-ID: <20191012054958.3624-1-manfred@colorfullife.com> (raw)
Hi,
Updated series, based on input from Davidlohr:
- Mixing WRITE_ONCE(), when not holding a lock, and "normal" writes,
when holding a lock, makes the code less readable.
Thus use _ONCE() everywhere, for both WRITE_ONCE() and READ_ONCE().
- According to my understanding, wake_q_add() does not contain a barrier
that protects the refount increase. Document that, and add the barrier
to the ipc code
- and, based on patch review: The V1 patch for ipc/sem.c is incorrect,
->state must be set to "-EINTR", not EINTR.
From V1:
The memory barriers in ipc are not properly documented, and at least
for some architectures insufficient:
Reading the xyz->status is only a control barrier, thus
smp_acquire__after_ctrl_dep() was missing in mqueue.c and msg.c
sem.c contained a full smp_mb(), which is not required.
Patches:
Patch 1: Document the barrier rules for wake_q_add().
Patch 2: remove code duplication
@Davidlohr: There is no "Signed-off-by" in your mail, otherwise I would
list you as author.
Patch 3-5: Update the ipc code, especially add missing
smp_mb__after_ctrl_dep().
Clarify that smp_mb__{before,after}_atomic() are compatible with all
RMW atomic operations, not just the operations that do not return a value.
Patch 6: Documentation for smp_mb__{before,after}_atomic().
Open issues:
- Is my analysis regarding the refcount correct?
- Review other users of wake_q_add().
- More testing. I did some tests, but doubt that the tests would be
sufficient to show issues with regards to incorrect memory barriers.
- Should I add a "Fixes:" or "Cc:stable"? The issues that I see are
the missing smp_mb__after_ctrl_dep(), and WRITE_ONCE() vs.
"ptr = NULL", and a risk regarding the refcount that I can't evaluate.
What do you think?
--
Manfred
next reply other threads:[~2019-10-12 5:50 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-12 5:49 Manfred Spraul [this message]
2019-10-12 5:49 ` [PATCH 1/6] wake_q: Cleanup + Documentation update Manfred Spraul
2019-10-14 6:34 ` Davidlohr Bueso
2019-10-14 12:04 ` Peter Zijlstra
2019-10-12 5:49 ` [PATCH 2/6] ipc/mqueue.c: Remove duplicated code Manfred Spraul
2019-10-14 6:35 ` Davidlohr Bueso
2019-10-14 12:37 ` Peter Zijlstra
2019-10-12 5:49 ` [PATCH 3/6] ipc/mqueue.c: Update/document memory barriers Manfred Spraul
2019-10-14 6:38 ` Davidlohr Bueso
2019-10-14 12:59 ` Peter Zijlstra
2019-10-14 13:58 ` Peter Zijlstra
2019-10-14 18:06 ` Manfred Spraul
2019-10-12 5:49 ` [PATCH 4/6] ipc/msg.c: Update and document " Manfred Spraul
2019-10-12 5:49 ` [PATCH 5/6] ipc/sem.c: Document and update " Manfred Spraul
2019-10-12 5:49 ` [PATCH 6/6] Documentation/memory-barriers.txt: Clarify cmpxchg() Manfred Spraul
2019-10-14 13:03 ` Peter Zijlstra
2019-10-14 17:49 ` Manfred Spraul
2019-10-14 19:03 ` Davidlohr Bueso
2019-10-15 7:45 ` Peter Zijlstra
2019-10-15 20:31 ` Waiman Long
2019-10-15 1:26 ` Davidlohr Bueso
2019-10-15 7:19 ` Peter Zijlstra
2019-10-15 16:26 ` 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=20191012054958.3624-1-manfred@colorfullife.com \
--to=manfred@colorfullife.com \
--cc=1vier1@web.de \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=dave@stgolabs.net \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.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
all inboxes | Powered by JetHome®