mp_ring: avoid items offset difference between iflib and mp_ring
on architectures without 64-bit atomics Reported by: Augustin Cavalier <waddlesplash@gmail.com>
This commit is contained in:
parent
27e05a1902
commit
5881181d8c
@ -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 *cookie, mp_ring_drain_t d
|
||||
}
|
||||
|
||||
*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 budget)
|
||||
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);
|
||||
|
@ -40,6 +40,10 @@ typedef u_int (*mp_ring_drain_t)(struct ifmp_ring *, u_int, u_int);
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user