Date: Sun, 21 Oct 2012 11:52:16 +0000 (UTC) From: Andre Oppermann <andre@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r241805 - in user/andre/tcp_workqueue/sys: kern sys Message-ID: <201210211152.q9LBqGZc066660@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210211152.q9LBqGZc066660>