Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Nov 2008 02:02:13 +0000 (UTC)
From:      Kip Macy <kmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r184759 - user/kmacy/HEAD_fast_multi_xmit/sys/net
Message-ID:  <200811080202.mA822D0W098283@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kmacy
Date: Sat Nov  8 02:02:13 2008
New Revision: 184759
URL: http://svn.freebsd.org/changeset/base/184759

Log:
  add memory barrier before critical_exit to ensure that all buffered updates are
  committed to main memory before a preemption is permitted

Modified:
  user/kmacy/HEAD_fast_multi_xmit/sys/net/flowtable.c

Modified: user/kmacy/HEAD_fast_multi_xmit/sys/net/flowtable.c
==============================================================================
--- user/kmacy/HEAD_fast_multi_xmit/sys/net/flowtable.c	Fri Nov  7 23:50:57 2008	(r184758)
+++ user/kmacy/HEAD_fast_multi_xmit/sys/net/flowtable.c	Sat Nov  8 02:02:13 2008	(r184759)
@@ -35,6 +35,21 @@
 #define calloc(count, size) malloc((count)*(size), M_DEVBUF, M_WAITOK|M_ZERO)
 	
 
+
+#if defined (__GNUC__)
+  #if #cpu(i386) || defined __i386 || defined i386 || defined __i386__ || #cpu(x86_64) || defined __x86_64__
+    #define mb()  __asm__ __volatile__ ("sfence;": : :"memory")
+  #elif #cpu(sparc64) || defined sparc64 || defined __sparcv9 
+    #define mb()  __asm__ __volatile__ ("membar #MemIssue": : :"memory")
+  #elif #cpu(sparc) || defined sparc || defined __sparc__
+    #define mb()  __asm__ __volatile__ ("stbar;": : :"memory")
+  #else
+    #define mb() 	/* XXX just to make this compile */
+  #endif
+#else
+  #error "unknown compiler"
+#endif
+
 /*
  * Taken from http://burtleburtle.net/bob/c/lookup3.c
  */
@@ -317,6 +332,7 @@ static void
 flowtable_pcpu_unlock(struct flowtable *table, uint32_t hash)
 {
 
+	mb();
 	critical_exit();
 }
 



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