From owner-svn-src-head@FreeBSD.ORG Sun Nov 9 11:11:10 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DA6B61A1; Sun, 9 Nov 2014 11:11:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C7114C9D; Sun, 9 Nov 2014 11:11:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sA9BB9xo010181; Sun, 9 Nov 2014 11:11:09 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sA9BB8uJ010176; Sun, 9 Nov 2014 11:11:08 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201411091111.sA9BB8uJ010176@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Sun, 9 Nov 2014 11:11:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r274306 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Nov 2014 11:11:10 -0000 Author: glebius Date: Sun Nov 9 11:11:08 2014 New Revision: 274306 URL: https://svnweb.freebsd.org/changeset/base/274306 Log: Use standard mtx(9), rwlock(9), sx(9) system initialization macros instead of doing initialization manually. Sponsored by: Nginx, Inc. Sponsored by: Netflix Modified: head/sys/net/if.c head/sys/net/if_clone.c head/sys/net/if_clone.h head/sys/net/if_var.h Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Sun Nov 9 09:44:09 2014 (r274305) +++ head/sys/net/if.c Sun Nov 9 11:11:08 2014 (r274306) @@ -159,7 +159,6 @@ static void if_attachdomain(void *); static void if_attachdomain1(struct ifnet *); static int ifconf(u_long, caddr_t); static void if_freemulti(struct ifmultiaddr *); -static void if_init(void *); static void if_grow(void); static void if_route(struct ifnet *, int flag, int fam); static int if_setflag(struct ifnet *, int, int, int *, int); @@ -207,7 +206,9 @@ VNET_DEFINE(struct ifnet **, ifindex_tab * inversions and deadlocks. */ struct rwlock ifnet_rwlock; +RW_SYSINIT_FLAGS(ifnet_rw, &ifnet_rwlock, "ifnet_rw", RW_RECURSE); struct sx ifnet_sxlock; +SX_SYSINIT_FLAGS(ifnet_sx, &ifnet_sxlock, "ifnet_sx", SX_RECURSE); /* * The allocation of network interfaces is a rather non-atomic affair; we @@ -364,17 +365,6 @@ vnet_if_init(const void *unused __unused VNET_SYSINIT(vnet_if_init, SI_SUB_INIT_IF, SI_ORDER_SECOND, vnet_if_init, NULL); -/* ARGSUSED*/ -static void -if_init(void *dummy __unused) -{ - - IFNET_LOCK_INIT(); - if_clone_init(); -} -SYSINIT(interfaces, SI_SUB_INIT_IF, SI_ORDER_FIRST, if_init, NULL); - - #ifdef VIMAGE static void vnet_if_uninit(const void *unused __unused) Modified: head/sys/net/if_clone.c ============================================================================== --- head/sys/net/if_clone.c Sun Nov 9 09:44:09 2014 (r274305) +++ head/sys/net/if_clone.c Sun Nov 9 11:11:08 2014 (r274306) @@ -103,15 +103,14 @@ static int ifc_simple_match(struct i static int ifc_simple_create(struct if_clone *, char *, size_t, caddr_t); static int ifc_simple_destroy(struct if_clone *, struct ifnet *); -static struct mtx if_cloners_mtx; +static struct mtx if_cloners_mtx; +MTX_SYSINIT(if_cloners_lock, &if_cloners_mtx, "if_cloners lock", MTX_DEF); static VNET_DEFINE(int, if_cloners_count); VNET_DEFINE(LIST_HEAD(, if_clone), if_cloners); #define V_if_cloners_count VNET(if_cloners_count) #define V_if_cloners VNET(if_cloners) -#define IF_CLONERS_LOCK_INIT() \ - mtx_init(&if_cloners_mtx, "if_cloners lock", NULL, MTX_DEF) #define IF_CLONERS_LOCK_ASSERT() mtx_assert(&if_cloners_mtx, MA_OWNED) #define IF_CLONERS_LOCK() mtx_lock(&if_cloners_mtx) #define IF_CLONERS_UNLOCK() mtx_unlock(&if_cloners_mtx) @@ -169,13 +168,6 @@ vnet_if_clone_init(void) LIST_INIT(&V_if_cloners); } -void -if_clone_init(void) -{ - - IF_CLONERS_LOCK_INIT(); -} - /* * Lookup and create a clone network interface. */ Modified: head/sys/net/if_clone.h ============================================================================== --- head/sys/net/if_clone.h Sun Nov 9 09:44:09 2014 (r274305) +++ head/sys/net/if_clone.h Sun Nov 9 11:11:08 2014 (r274306) @@ -65,7 +65,6 @@ EVENTHANDLER_DECLARE(if_clone_event, if_ #endif /* The below interfaces used only by net/if.c. */ -void if_clone_init(void); void vnet_if_clone_init(void); int if_clone_create(char *, size_t, caddr_t); int if_clone_destroy(const char *); Modified: head/sys/net/if_var.h ============================================================================== --- head/sys/net/if_var.h Sun Nov 9 09:44:09 2014 (r274305) +++ head/sys/net/if_var.h Sun Nov 9 11:11:08 2014 (r274306) @@ -421,11 +421,6 @@ struct ifmultiaddr { extern struct rwlock ifnet_rwlock; extern struct sx ifnet_sxlock; -#define IFNET_LOCK_INIT() do { \ - rw_init_flags(&ifnet_rwlock, "ifnet_rw", RW_RECURSE); \ - sx_init_flags(&ifnet_sxlock, "ifnet_sx", SX_RECURSE); \ -} while(0) - #define IFNET_WLOCK() do { \ sx_xlock(&ifnet_sxlock); \ rw_wlock(&ifnet_rwlock); \