From owner-svn-src-user@FreeBSD.ORG Sun Oct 21 11:52:16 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E76C2BCF; Sun, 21 Oct 2012 11:52:16 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B4D9E8FC12; Sun, 21 Oct 2012 11:52:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9LBqGAL066663; Sun, 21 Oct 2012 11:52:16 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9LBqGZc066660; Sun, 21 Oct 2012 11:52:16 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201210211152.q9LBqGZc066660@svn.freebsd.org> From: Andre Oppermann Date: Sun, 21 Oct 2012 11:52:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r241805 - in user/andre/tcp_workqueue/sys: kern sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Oct 2012 11:52:17 -0000 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