From owner-svn-src-all@FreeBSD.ORG Tue Jun 24 15:16:55 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EFBDA2F2; Tue, 24 Jun 2014 15:16:55 +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 C247F251A; Tue, 24 Jun 2014 15:16:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5OFGtCO072623; Tue, 24 Jun 2014 15:16:55 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5OFGt9J072622; Tue, 24 Jun 2014 15:16:55 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201406241516.s5OFGt9J072622@svn.freebsd.org> From: Attilio Rao Date: Tue, 24 Jun 2014 15:16:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267820 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jun 2014 15:16:56 -0000 Author: attilio Date: Tue Jun 24 15:16:55 2014 New Revision: 267820 URL: http://svnweb.freebsd.org/changeset/base/267820 Log: sysctl subsystem uses sxlocks so avoid to setup dynamic sysctl nodes before sleepinit() has been fully executed in the SLEEPQUEUE_PROFILING case. Sponsored by: EMC / Isilon storage division Modified: head/sys/kern/subr_sleepqueue.c Modified: head/sys/kern/subr_sleepqueue.c ============================================================================== --- head/sys/kern/subr_sleepqueue.c Tue Jun 24 15:03:00 2014 (r267819) +++ head/sys/kern/subr_sleepqueue.c Tue Jun 24 15:16:55 2014 (r267820) @@ -166,24 +166,20 @@ SDT_PROBE_DECLARE(sched, , , sleep); SDT_PROBE_DECLARE(sched, , , wakeup); /* - * Early initialization of sleep queues that is called from the sleepinit() - * SYSINIT. + * Initialize SLEEPQUEUE_PROFILING specific sysctl nodes. + * Note that it must happen after sleepinit() has been fully executed, so + * it must happen after SI_SUB_KMEM SYSINIT() subsystem setup. */ -void -init_sleepqueues(void) -{ #ifdef SLEEPQUEUE_PROFILING - struct sysctl_oid *chain_oid; +static void +init_sleepqueue_profiling(void) +{ char chain_name[10]; -#endif - int i; + struct sysctl_oid *chain_oid; + u_int i; for (i = 0; i < SC_TABLESIZE; i++) { - LIST_INIT(&sleepq_chains[i].sc_queues); - mtx_init(&sleepq_chains[i].sc_lock, "sleepq chain", NULL, - MTX_SPIN | MTX_RECURSE); -#ifdef SLEEPQUEUE_PROFILING - snprintf(chain_name, sizeof(chain_name), "%d", i); + snprintf(chain_name, sizeof(chain_name), "%u", i); chain_oid = SYSCTL_ADD_NODE(NULL, SYSCTL_STATIC_CHILDREN(_debug_sleepq_chains), OID_AUTO, chain_name, CTLFLAG_RD, NULL, "sleepq chain stats"); @@ -192,7 +188,26 @@ init_sleepqueues(void) SYSCTL_ADD_UINT(NULL, SYSCTL_CHILDREN(chain_oid), OID_AUTO, "max_depth", CTLFLAG_RD, &sleepq_chains[i].sc_max_depth, 0, NULL); + } +} + +SYSINIT(sleepqueue_profiling, SI_SUB_LOCK, SI_ORDER_ANY, + init_sleepqueue_profiling, NULL); #endif + +/* + * Early initialization of sleep queues that is called from the sleepinit() + * SYSINIT. + */ +void +init_sleepqueues(void) +{ + int i; + + for (i = 0; i < SC_TABLESIZE; i++) { + LIST_INIT(&sleepq_chains[i].sc_queues); + mtx_init(&sleepq_chains[i].sc_lock, "sleepq chain", NULL, + MTX_SPIN | MTX_RECURSE); } sleepq_zone = uma_zcreate("SLEEPQUEUE", sizeof(struct sleepqueue), #ifdef INVARIANTS