From 7e14a4851e099c5ee577b2eca50eebac7d7fbf00 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 22 Apr 2020 14:50:40 -0600 Subject: compat: don't assume READ_ONCE barriers on old kernels 76ebbe78f7390aee075a7f3768af197ded1bdfbb didn't come until 4.15. Signed-off-by: Jason A. Donenfeld --- src/compat/ptr_ring/include/linux/ptr_ring.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/compat/ptr_ring/include') diff --git a/src/compat/ptr_ring/include/linux/ptr_ring.h b/src/compat/ptr_ring/include/linux/ptr_ring.h index 417db0a..32aed2b 100644 --- a/src/compat/ptr_ring/include/linux/ptr_ring.h +++ b/src/compat/ptr_ring/include/linux/ptr_ring.h @@ -292,13 +292,13 @@ static inline void *__ptr_ring_consume(struct ptr_ring *r) { void *ptr; - /* The READ_ONCE in __ptr_ring_peek guarantees that anyone - * accessing data through the pointer is up to date. Pairs - * with smp_wmb in __ptr_ring_produce. - */ ptr = __ptr_ring_peek(r); if (ptr) __ptr_ring_discard_one(r); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + /* The READ_ONCE in __ptr_ring_peek doesn't imply a barrier on old kernels. */ + smp_read_barrier_depends(); +#endif return ptr; } -- cgit v1.2.3