diff options
| author | Ingo Molnar <mingo@kernel.org> | 2018-01-10 10:52:40 +0100 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2018-01-10 10:52:40 +0100 |
| commit | cb1f34ddccb46f7c1bb61e98b7d44751a20c7e49 (patch) | |
| tree | 6cbcf7e9d87bc571b80ec1f75b5cb21a8e34b937 /include/linux/ptr_ring.h | |
| parent | a555e9d86ee384d9d3cb3310a57aed33f7e053d4 (diff) | |
| parent | 541676078b52f365f53d46ee5517d305cd1b6350 (diff) | |
| download | talos-op-linux-cb1f34ddccb46f7c1bb61e98b7d44751a20c7e49.tar.gz talos-op-linux-cb1f34ddccb46f7c1bb61e98b7d44751a20c7e49.zip | |
Merge branch 'sched/urgent' into sched/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux/ptr_ring.h')
| -rw-r--r-- | include/linux/ptr_ring.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h index 37b4bb2545b3..6866df4f31b5 100644 --- a/include/linux/ptr_ring.h +++ b/include/linux/ptr_ring.h @@ -101,12 +101,18 @@ static inline bool ptr_ring_full_bh(struct ptr_ring *r) /* Note: callers invoking this in a loop must use a compiler barrier, * for example cpu_relax(). Callers must hold producer_lock. + * Callers are responsible for making sure pointer that is being queued + * points to a valid data. */ static inline int __ptr_ring_produce(struct ptr_ring *r, void *ptr) { if (unlikely(!r->size) || r->queue[r->producer]) return -ENOSPC; + /* Make sure the pointer we are storing points to a valid data. */ + /* Pairs with smp_read_barrier_depends in __ptr_ring_consume. */ + smp_wmb(); + r->queue[r->producer++] = ptr; if (unlikely(r->producer >= r->size)) r->producer = 0; @@ -275,6 +281,9 @@ static inline void *__ptr_ring_consume(struct ptr_ring *r) if (ptr) __ptr_ring_discard_one(r); + /* Make sure anyone accessing data through the pointer is up to date. */ + /* Pairs with smp_wmb in __ptr_ring_produce. */ + smp_read_barrier_depends(); return ptr; } |

