From owner-svn-src-stable-9@FreeBSD.ORG Thu Jan 23 00:26:25 2014 Return-Path: Delivered-To: svn-src-stable-9@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 17D9C953; Thu, 23 Jan 2014 00:26:25 +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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DDCEC14DC; Thu, 23 Jan 2014 00:26:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0N0QOB3042416; Thu, 23 Jan 2014 00:26:24 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0N0QOS1042415; Thu, 23 Jan 2014 00:26:24 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201401230026.s0N0QOS1042415@svn.freebsd.org> From: Alexander Motin Date: Thu, 23 Jan 2014 00:26:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r261056 - stable/9/sys/rpc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2014 00:26:25 -0000 Author: mav Date: Thu Jan 23 00:26:24 2014 New Revision: 261056 URL: http://svnweb.freebsd.org/changeset/base/261056 Log: MFC r258132: Some minor tuning to rpc/svc.c: - close cosmetic race in svc_exit(); - do not set wait timeout for idle threads if we have no use for wakeups; - create new requested thread sooner, not only after some another thread wakeup, that may happen later under constant load. Modified: stable/9/sys/rpc/svc.c Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/sys/rpc/svc.c ============================================================================== --- stable/9/sys/rpc/svc.c Wed Jan 22 23:55:25 2014 (r261055) +++ stable/9/sys/rpc/svc.c Thu Jan 23 00:26:24 2014 (r261056) @@ -1013,6 +1013,18 @@ svc_run_internal(SVCPOOL *pool, bool_t i while (pool->sp_state != SVCPOOL_CLOSING) { /* + * Create new thread if requested. + */ + if (pool->sp_state == SVCPOOL_THREADWANTED) { + pool->sp_state = SVCPOOL_THREADSTARTING; + pool->sp_lastcreatetime = time_uptime; + mtx_unlock(&pool->sp_lock); + svc_new_thread(pool); + mtx_lock(&pool->sp_lock); + continue; + } + + /* * Check for idle transports once per second. */ if (time_uptime > pool->sp_lastidlecheck) { @@ -1048,8 +1060,13 @@ svc_run_internal(SVCPOOL *pool, bool_t i continue; LIST_INSERT_HEAD(&pool->sp_idlethreads, st, st_ilink); - error = cv_timedwait_sig(&st->st_cond, &pool->sp_lock, - 5 * hz); + if (ismaster || (!ismaster && + pool->sp_threadcount > pool->sp_minthreads)) + error = cv_timedwait_sig(&st->st_cond, + &pool->sp_lock, 5 * hz); + else + error = cv_wait_sig(&st->st_cond, + &pool->sp_lock); LIST_REMOVE(st, st_ilink); /* @@ -1062,24 +1079,11 @@ svc_run_internal(SVCPOOL *pool, bool_t i && !st->st_xprt && STAILQ_EMPTY(&st->st_reqs)) break; - } - if (error == EWOULDBLOCK) - continue; - if (error) { - if (pool->sp_state != SVCPOOL_CLOSING) { - mtx_unlock(&pool->sp_lock); - svc_exit(pool); - mtx_lock(&pool->sp_lock); - } - break; - } - - if (pool->sp_state == SVCPOOL_THREADWANTED) { - pool->sp_state = SVCPOOL_THREADSTARTING; - pool->sp_lastcreatetime = time_uptime; + } else if (error) { mtx_unlock(&pool->sp_lock); - svc_new_thread(pool); + svc_exit(pool); mtx_lock(&pool->sp_lock); + break; } continue; } @@ -1247,9 +1251,11 @@ svc_exit(SVCPOOL *pool) mtx_lock(&pool->sp_lock); - pool->sp_state = SVCPOOL_CLOSING; - LIST_FOREACH(st, &pool->sp_idlethreads, st_ilink) - cv_signal(&st->st_cond); + if (pool->sp_state != SVCPOOL_CLOSING) { + pool->sp_state = SVCPOOL_CLOSING; + LIST_FOREACH(st, &pool->sp_idlethreads, st_ilink) + cv_signal(&st->st_cond); + } mtx_unlock(&pool->sp_lock); }