svn commit: r342749 - head/sys/net
Matt Macy
mmacy at FreeBSD.org
Thu Jan 3 23:06:07 UTC 2019
Author: mmacy
Date: Thu Jan 3 23:06:05 2019
New Revision: 342749
URL: https://svnweb.freebsd.org/changeset/base/342749
Log:
mp_ring: avoid items offset difference between iflib and mp_ring
on architectures without 64-bit atomics
Reported by: Augustin Cavalier <waddlesplash at gmail.com>
Modified:
head/sys/net/mp_ring.c
head/sys/net/mp_ring.h
Modified: head/sys/net/mp_ring.c
==============================================================================
--- head/sys/net/mp_ring.c Thu Jan 3 22:51:14 2019 (r342748)
+++ head/sys/net/mp_ring.c Thu Jan 3 23:06:05 2019 (r342749)
@@ -37,10 +37,6 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <machine/cpu.h>
-#if defined(__powerpc__) || defined(__mips__) || defined(__i386__)
-#define NO_64BIT_ATOMICS
-#endif
-
#if defined(__i386__)
#define atomic_cmpset_acq_64 atomic_cmpset_64
#define atomic_cmpset_rel_64 atomic_cmpset_64
@@ -101,7 +97,7 @@ state_to_flags(union ring_state s, int abdicate)
return (BUSY);
}
-#ifdef NO_64BIT_ATOMICS
+#ifdef MP_RING_NO_64BIT_ATOMICS
static void
drain_ring_locked(struct ifmp_ring *r, union ring_state os, uint16_t prev, int budget)
{
@@ -291,7 +287,7 @@ ifmp_ring_alloc(struct ifmp_ring **pr, int size, void
}
*pr = r;
-#ifdef NO_64BIT_ATOMICS
+#ifdef MP_RING_NO_64BIT_ATOMICS
mtx_init(&r->lock, "mp_ring lock", NULL, MTX_DEF);
#endif
return (0);
@@ -325,7 +321,7 @@ ifmp_ring_free(struct ifmp_ring *r)
*
* Returns an errno.
*/
-#ifdef NO_64BIT_ATOMICS
+#ifdef MP_RING_NO_64BIT_ATOMICS
int
ifmp_ring_enqueue(struct ifmp_ring *r, void **items, int n, int budget, int abdicate)
{
@@ -503,7 +499,7 @@ ifmp_ring_check_drainage(struct ifmp_ring *r, int budg
ns.flags = BUSY;
-#ifdef NO_64BIT_ATOMICS
+#ifdef MP_RING_NO_64BIT_ATOMICS
mtx_lock(&r->lock);
if (r->state != os.state) {
mtx_unlock(&r->lock);
Modified: head/sys/net/mp_ring.h
==============================================================================
--- head/sys/net/mp_ring.h Thu Jan 3 22:51:14 2019 (r342748)
+++ head/sys/net/mp_ring.h Thu Jan 3 23:06:05 2019 (r342749)
@@ -40,6 +40,10 @@ typedef u_int (*mp_ring_drain_t)(struct ifmp_ring *, u
typedef u_int (*mp_ring_can_drain_t)(struct ifmp_ring *);
typedef void (*mp_ring_serial_t)(struct ifmp_ring *);
+#if defined(__powerpc__) || defined(__mips__) || defined(__i386__)
+#define MP_RING_NO_64BIT_ATOMICS
+#endif
+
struct ifmp_ring {
volatile uint64_t state __aligned(CACHE_LINE_SIZE);
@@ -54,7 +58,7 @@ struct ifmp_ring {
counter_u64_t stalls;
counter_u64_t restarts; /* recovered after stalling */
counter_u64_t abdications;
-#ifdef NO_64BIT_ATOMICS
+#ifdef MP_RING_NO_64BIT_ATOMICS
struct mtx lock;
#endif
void * volatile items[] __aligned(CACHE_LINE_SIZE);
More information about the svn-src-all
mailing list