From owner-svn-src-all@FreeBSD.ORG Tue Apr 1 08:43:56 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 0A9FEB1F; Tue, 1 Apr 2014 08:43:56 +0000 (UTC) Received: from mail-wg0-x22a.google.com (mail-wg0-x22a.google.com [IPv6:2a00:1450:400c:c00::22a]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2802B26D; Tue, 1 Apr 2014 08:43:55 +0000 (UTC) Received: by mail-wg0-f42.google.com with SMTP id y10so6916874wgg.1 for ; Tue, 01 Apr 2014 01:43:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ql9IjHpxv2/y5yoI0snaA4NuNfo2Vj1RglKgg3DPfMg=; b=zmQpSLm/wEe4VMF4pS5KzjVNvoJve8QYqACyYZw1RqCfKvgvuL/bXbg2g5lEoK7vpK E7WrckqG21py5XM4QVjRl9QFw7X/EuQwDBPrncpcvynF3ULAUgb1wSGztcLUcTqfwrpd aMaIQzus/gRmofs5q0GP3WAMFqtOkF2HtS9j8e+7GOE59TJ3EDdL22lKyyP4BHu126xk kFObAgKDM3fjhLAhOP6ElwHSCmauunbHwu4ZNBP3Ql9lXWsIGfiabLd+hO+ULIDAX2hB hKQEL4vEc6IPkpoQD/1pc0Mig/Ahehe4tvqb1HrLEuhtRdAomOw0yNXiolB4sqj4UkAX VWNw== X-Received: by 10.194.86.7 with SMTP id l7mr20501698wjz.37.1396341833374; Tue, 01 Apr 2014 01:43:53 -0700 (PDT) Received: from strashydlo.home (agy254.neoplus.adsl.tpnet.pl. [83.25.180.254]) by mx.google.com with ESMTPSA id y7sm39007989eev.5.2014.04.01.01.43.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 01 Apr 2014 01:43:52 -0700 (PDT) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Subject: Re: svn commit: r263978 - head/sys/cam/ctl Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: text/plain; charset=iso-8859-2 From: =?iso-8859-2?Q?Edward_Tomasz_Napiera=B3a?= In-Reply-To: <533A7416.7030605@FreeBSD.org> Date: Tue, 1 Apr 2014 10:43:50 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201403312049.s2VKnXLr079029@svn.freebsd.org> <533A7416.7030605@FreeBSD.org> To: koobs@FreeBSD.org X-Mailer: Apple Mail (2.1283) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 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, 01 Apr 2014 08:43:56 -0000 Wiadomo=B6=E6 napisana przez Kubilay Kocak w dniu 1 kwi 2014, o godz. = 10:08: > On 1/04/2014 7:49 AM, Edward Tomasz Napierala wrote: >> Author: trasz >> Date: Mon Mar 31 20:49:33 2014 >> New Revision: 263978 >> URL: http://svnweb.freebsd.org/changeset/base/263978 >>=20 >> Log: >> Make it possible to have multiple CTL worker threads. Leave the = default >> of 1 for now. >>=20 >> Sponsored by: The FreeBSD Foundation >>=20 >> Modified: >> head/sys/cam/ctl/ctl.c >>=20 >> Modified: head/sys/cam/ctl/ctl.c >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- head/sys/cam/ctl/ctl.c Mon Mar 31 19:58:08 2014 = (r263977) >> +++ head/sys/cam/ctl/ctl.c Mon Mar 31 20:49:33 2014 = (r263978) >> @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); >> #include >> #include >> #include >> +#include >> #include >> #include >>=20 >> @@ -320,6 +321,10 @@ static int ctl_is_single =3D 1; >> static int index_to_aps_page; >>=20 >> SYSCTL_NODE(_kern_cam, OID_AUTO, ctl, CTLFLAG_RD, 0, "CAM Target = Layer"); >> +static int worker_threads =3D 1; >> +TUNABLE_INT("kern.cam.ctl.worker_threads", &worker_threads); >> +SYSCTL_INT(_kern_cam_ctl, OID_AUTO, worker_threads, CTLFLAG_RDTUN, >> + &worker_threads, 1, "Number of worker threads"); >>=20 >> /* >> * Serial number (0x80), device id (0x83), and supported pages (0x00) >> @@ -950,10 +955,7 @@ ctl_init(void) >> struct ctl_frontend *fe; >> struct ctl_lun *lun; >> uint8_t sc_id =3D0; >> -#if 0 >> - int i; >> -#endif >> - int error, retval; >> + int i, error, retval; >> //int isc_retval; >>=20 >> retval =3D 0; >> @@ -1085,17 +1087,35 @@ ctl_init(void) >> mtx_unlock(&softc->ctl_lock); >> #endif >>=20 >> - error =3D kproc_create(ctl_work_thread, softc, = &softc->work_thread, 0, 0, >> - "ctl_thrd"); >> - if (error !=3D 0) { >> - printf("error creating CTL work thread!\n"); >> - mtx_lock(&softc->ctl_lock); >> - ctl_free_lun(lun); >> - mtx_unlock(&softc->ctl_lock); >> - ctl_pool_free(internal_pool); >> - ctl_pool_free(emergency_pool); >> - ctl_pool_free(other_pool); >> - return (error); >> + if (worker_threads > MAXCPU || worker_threads =3D=3D 0) { >> + printf("invalid kern.cam.ctl.worker_threads value; " >> + "setting to 1"); >> + worker_threads =3D 1; >> + } else if (worker_threads < 0) { >=20 > Why is it that the < 0 case is special enough that it gets the = mp_ncpus > check below, but the =3D=3D 0 and > MAXCPU cases don't? It's to be able to set it to -1 (which will probably become the new = default soon) and let the code figure out the right number by itself. >> + if (mp_ncpus > 2) { >> + /* >> + * Using more than two worker threads actually = hurts >> + * performance due to lock contention. >> + */ >=20 >> + worker_threads =3D 2; >> + } else { >> + worker_threads =3D 1; >> + } >=20 > Are printf("Setting to N")'s worthwhile here as well given > worker_threads is set to a value that wasn't specified by the user, as > above? The warning is to inform the user why the value supplied was ignored as invalid. The -1 setting is always valid.