svn commit: r241802 - in user/andre/tcp_workqueue/sys: kern sys
Andre Oppermann
andre at FreeBSD.org
Sun Oct 21 11:16:18 UTC 2012
Author: andre
Date: Sun Oct 21 11:16:16 2012
New Revision: 241802
URL: http://svn.freebsd.org/changeset/base/241802
Log:
Simplify cache line alignment of global mutexes and remove
the unnecessary MTX_GLB() accessor macro again.
Suggested by: glebius
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 10:19:07 2012 (r241801)
+++ user/andre/tcp_workqueue/sys/kern/uipc_socket.c Sun Oct 21 11:16:16 2012 (r241802)
@@ -215,8 +215,8 @@ MTX_SYSINIT(accept_mtx, &accept_mtx, "ac
* so_global_mtx protects so_gencnt, numopensockets, and the per-socket
* so_gencnt field.
*/
-MTX_GLOBAL_STATIC(so_global_mtx);
-MTX_SYSINIT(so_global_mtx, MTX_GLB(so_global_mtx), "so_glabel", MTX_DEF);
+static MTX_GLOBAL(so_global_mtx);
+MTX_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
@@ -324,7 +324,7 @@ soalloc(struct vnet *vnet)
sx_init(&so->so_snd.sb_sx, "so_snd_sx");
sx_init(&so->so_rcv.sb_sx, "so_rcv_sx");
TAILQ_INIT(&so->so_aiojobq);
- mtx_lock(MTX_GLB(so_global_mtx));
+ mtx_lock(&so_global_mtx);
so->so_gencnt = ++so_gencnt;
++numopensockets;
#ifdef VIMAGE
@@ -333,7 +333,7 @@ soalloc(struct vnet *vnet)
vnet->vnet_sockcnt++;
so->so_vnet = vnet;
#endif
- mtx_unlock(MTX_GLB(so_global_mtx));
+ mtx_unlock(&so_global_mtx);
return (so);
}
@@ -349,7 +349,7 @@ sodealloc(struct socket *so)
KASSERT(so->so_count == 0, ("sodealloc(): so_count %d", so->so_count));
KASSERT(so->so_pcb == NULL, ("sodealloc(): so_pcb != NULL"));
- mtx_lock(MTX_GLB(so_global_mtx));
+ mtx_lock(&so_global_mtx);
so->so_gencnt = ++so_gencnt;
--numopensockets; /* Could be below, but faster here. */
#ifdef VIMAGE
@@ -357,7 +357,7 @@ sodealloc(struct socket *so)
__func__, __LINE__, so));
so->so_vnet->vnet_sockcnt--;
#endif
- mtx_unlock(MTX_GLB(so_global_mtx));
+ mtx_unlock(&so_global_mtx);
if (so->so_rcv.sb_hiwat)
(void)chgsbsize(so->so_cred->cr_uidinfo,
&so->so_rcv.sb_hiwat, 0, RLIM_INFINITY);
Modified: user/andre/tcp_workqueue/sys/sys/mutex.h
==============================================================================
--- user/andre/tcp_workqueue/sys/sys/mutex.h Sun Oct 21 10:19:07 2012 (r241801)
+++ user/andre/tcp_workqueue/sys/sys/mutex.h Sun Oct 21 11:16:16 2012 (r241802)
@@ -414,30 +414,15 @@ struct mtx_args {
/*
* 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)
+ struct mtx __aligned(CACHE_LINE_SIZE) (name)
-#define MTX_GLOBAL_STATIC(name) \
- static struct { \
- struct mtx (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)
+ struct mtx (name)
#endif /* SMP */
-#define MTX_GLB(name) (&(name.name))
/*
* The INVARIANTS-enabled mtx_assert() functionality.
More information about the svn-src-user
mailing list