svn commit: r241800 - user/andre/tcp_workqueue/sys/sys

Andre Oppermann andre at FreeBSD.org
Sun Oct 21 09:46:03 UTC 2012


Author: andre
Date: Sun Oct 21 09:46:02 2012
New Revision: 241800
URL: http://svn.freebsd.org/changeset/base/241800

Log:
  Make the cache line alignment conditional on SMP as it is not
  needed on UP systems.  This saves a few bytes on embedded platforms.
  
  Remove the semicolons at the end of the structure definitions.

Modified:
  user/andre/tcp_workqueue/sys/sys/mutex.h

Modified: user/andre/tcp_workqueue/sys/sys/mutex.h
==============================================================================
--- user/andre/tcp_workqueue/sys/sys/mutex.h	Sun Oct 21 09:31:48 2012	(r241799)
+++ user/andre/tcp_workqueue/sys/sys/mutex.h	Sun Oct 21 09:46:02 2012	(r241800)
@@ -411,16 +411,32 @@ struct mtx_args {
 	SYSUNINIT(name##_mtx_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE,	\
 	    mtx_destroy, (mtx))
 
+/*
+ * Helper macros to prevent global mutexes to share a cache line
+ * on SMP systems.
+ * MTX_GLB(name) abstracts the access to the structure encapsulated
+ * mutexes.
+ */
+#ifdef SMP
 #define	MTX_GLOBAL(name)						\
 	struct {							\
         	struct mtx (name);					\
-	} __aligned(CACHE_LINE_SIZE) (name);
+	} __aligned(CACHE_LINE_SIZE) (name)
 
 #define	MTX_GLOBAL_STATIC(name)						\
 	static struct {							\
 		struct mtx (name);					\
-	} __aligned(CACHE_LINE_SIZE) (name);
-
+	} __aligned(CACHE_LINE_SIZE) (name)
+#else /* SMP */
+#define	MTX_GLOBAL(name)						\
+	struct {							\
+		struct mtx (name);					\
+	} (name)
+#define MTX_GLOBAL_STATIC(name)						\
+	static struct {							\
+		struct mtx (name);					\
+	} (name)
+#endif /* SMP */
 #define	MTX_GLB(name)	(&(name.name))
 
 /*


More information about the svn-src-user mailing list