Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Feb 2019 13:09:16 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r344092 - stable/12/sys/net
Message-ID:  <201902131309.x1DD9GDf094033@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Wed Feb 13 13:09:16 2019
New Revision: 344092
URL: https://svnweb.freebsd.org/changeset/base/344092

Log:
  MFC: r342749
  
  mp_ring: avoid items offset difference between iflib and mp_ring
  on architectures without 64-bit atomics
  
  Reported by:	Augustin Cavalier <waddlesplash@gmail.com>

Modified:
  stable/12/sys/net/mp_ring.c
  stable/12/sys/net/mp_ring.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/net/mp_ring.c
==============================================================================
--- stable/12/sys/net/mp_ring.c	Wed Feb 13 09:28:48 2019	(r344091)
+++ stable/12/sys/net/mp_ring.c	Wed Feb 13 13:09:16 2019	(r344092)
@@ -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: stable/12/sys/net/mp_ring.h
==============================================================================
--- stable/12/sys/net/mp_ring.h	Wed Feb 13 09:28:48 2019	(r344091)
+++ stable/12/sys/net/mp_ring.h	Wed Feb 13 13:09:16 2019	(r344092)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902131309.x1DD9GDf094033>