svn commit: r241805 - in user/andre/tcp_workqueue/sys: kern sys
Andre Oppermann
andre at FreeBSD.org
Sun Oct 21 11:52:17 UTC 2012
Author: andre
Date: Sun Oct 21 11:52:16 2012
New Revision: 241805
URL: http://svn.freebsd.org/changeset/base/241805
Log:
Add MTX_DEF_SYSINIT() macro which combines defining a global mutex
with initializing it and ensuring the cache line alignment.
Suggested by: ed
Modified:
user/andre/tcp_workqueue/sys/kern/uipc_socket.c
user/andre/tcp_workqueue/sys/sys/mutex.h
Modified: user/andre/tcp_workqueue/sys/kern/uipc_socket.c
==============================================================================
--- user/andre/tcp_workqueue/sys/kern/uipc_socket.c Sun Oct 21 11:43:47 2012 (r241804)
+++ user/andre/tcp_workqueue/sys/kern/uipc_socket.c Sun Oct 21 11:52:16 2012 (r241805)
@@ -208,15 +208,13 @@ SYSCTL_INT(_kern_ipc_zero_copy, OID_AUTO
* accept_mtx locks down per-socket fields relating to accept queues. See
* socketvar.h for an annotation of the protected fields of struct socket.
*/
-struct mtx accept_mtx;
-MTX_SYSINIT(accept_mtx, &accept_mtx, "accept", MTX_DEF);
+MTX_DEF_SYSINIT(accept_mtx, &accept_mtx, "accept", MTX_DEF);
/*
* so_global_mtx protects so_gencnt, numopensockets, and the per-socket
* so_gencnt field.
*/
-static MTX_GLOBAL(so_global_mtx);
-MTX_SYSINIT(so_global_mtx, &so_global_mtx, "so_glabel", MTX_DEF);
+static MTX_DEF_SYSINIT(so_global_mtx, &so_global_mtx, "so_glabel", MTX_DEF);
/*
* General IPC sysctl name space, used by sockets and a variety of other IPC
Modified: user/andre/tcp_workqueue/sys/sys/mutex.h
==============================================================================
--- user/andre/tcp_workqueue/sys/sys/mutex.h Sun Oct 21 11:43:47 2012 (r241804)
+++ user/andre/tcp_workqueue/sys/sys/mutex.h Sun Oct 21 11:52:16 2012 (r241805)
@@ -394,12 +394,28 @@ do { \
return (_val); \
} while (0)
+/*
+ * Helper macros to prevent global mutexes to share a cache line
+ * on SMP systems.
+ */
+#ifdef SMP
+#define MTX_GLOBAL(name) \
+ struct mtx __aligned(CACHE_LINE_SIZE) (name)
+#else /* SMP */
+#define MTX_GLOBAL(name) \
+ struct mtx (name)
+#endif /* SMP */
+
struct mtx_args {
struct mtx *ma_mtx;
const char *ma_desc;
int ma_opts;
};
+#define MTX_DEF_SYSINIT(name, mtx, desc, opts) \
+ MTX_GLOBAL(name); \
+ MTX_SYSINIT(name, mtx, desc, opts)
+
#define MTX_SYSINIT(name, mtx, desc, opts) \
static struct mtx_args name##_args = { \
(mtx), \
@@ -412,19 +428,6 @@ struct mtx_args {
mtx_destroy, (mtx))
/*
- * Helper macros to prevent global mutexes to share a cache line
- * on SMP systems.
- */
-#ifdef SMP
-#define MTX_GLOBAL(name) \
- struct mtx __aligned(CACHE_LINE_SIZE) (name)
-
-#else /* SMP */
-#define MTX_GLOBAL(name) \
- struct mtx (name)
-#endif /* SMP */
-
-/*
* The INVARIANTS-enabled mtx_assert() functionality.
*
* The constants need to be defined for INVARIANT_SUPPORT infrastructure
More information about the svn-src-user
mailing list