The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 0/3] Clarify/standardize memory barriers for ipc
@ 2019-10-11 11:20 Manfred Spraul
  2019-10-11 11:20 ` [PATCH 1/5] wake_q: Cleanup + Documentation update Manfred Spraul
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Manfred Spraul @ 2019-10-11 11:20 UTC (permalink / raw)
  To: LKML, Davidlohr Bueso, Waiman Long
  Cc: 1vier1, Andrew Morton, Peter Zijlstra, Jonathan Corbet,
	Manfred Spraul

Hi,

Partially based on the findings from Waiman Long:

a) 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.

Patch 1: Document that wake_q_add() contains a barrier.

b) wake_q_add() provides a memory barrier, ipc/mqueue.c relies on this.
Move the documentation to wake_q_add(), instead writing it in ipc/mqueue.c

Patch 2-4: Update the ipc code, especially add missing
           smp_mb__after_ctrl_dep().

c) [optional]
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 5: Documentation for smp_mb__{before,after}_atomic().

From my point of view, patch 1 is a prerequisite for patches 2-4:
If the barrier is not part of the documented API, then ipc should not rely
on it, i.e. then I would propose to replace the WRITE_ONCE with
smp_store_release().

Open issues:
- 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 only issues that I see are
  the missing smp_mb__after_ctrl_dep(), and WRITE_ONCE() vs.
  "ptr = NULL".

What do you think?

--
	Manfred

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-10-23 18:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-11 11:20 [PATCH 0/3] Clarify/standardize memory barriers for ipc Manfred Spraul
2019-10-11 11:20 ` [PATCH 1/5] wake_q: Cleanup + Documentation update Manfred Spraul
2019-10-11 11:20 ` [PATCH 2/5] ipc/mqueue.c: Update/document memory barriers Manfred Spraul
2019-10-11 16:55   ` Davidlohr Bueso
2019-10-11 18:53     ` Manfred Spraul
2019-10-14  6:29       ` Davidlohr Bueso
2019-10-11 11:20 ` [PATCH 3/5] ipc/msg.c: Update and document " Manfred Spraul
2019-10-11 11:20 ` [PATCH 4/5] ipc/sem.c: Document and update " Manfred Spraul
2019-10-21  8:35   ` [ipc/sem.c] 6394de3b86: BUG:kernel_NULL_pointer_dereference,address kernel test robot
2019-10-23 18:28     ` Manfred Spraul
2019-10-11 11:20 ` [PATCH 5/5] Documentation/memory-barriers.txt: Clarify cmpxchg() Manfred Spraul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox