From owner-svn-src-all@FreeBSD.ORG Tue Apr 1 08:09:02 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 94225D41; Tue, 1 Apr 2014 08:09:02 +0000 (UTC) Received: from mail-pa0-x22f.google.com (mail-pa0-x22f.google.com [IPv6:2607:f8b0:400e:c03::22f]) (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 56924E12; Tue, 1 Apr 2014 08:09:02 +0000 (UTC) Received: by mail-pa0-f47.google.com with SMTP id lj1so9380067pab.6 for ; Tue, 01 Apr 2014 01:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:reply-to:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=bAaaZVmgE8TwyOik6eG1FZCGuiGyGpyiDVyglSXeyQM=; b=DgLEuUqAoR49Rl5OFdIRTDP4agy1ANWLAIy8+54WC+F1CvLW+3z8rWX+mYGI5fXjMV OpFTpudqBdArXkvFKvOpFiiNhi5cslXerWcf5nvI7DJ9RiV2wxtYF0RRq6+wAM52/vLt x8QfKVnbdewzr6k/ahHnv7qK6hoBNVhODEZCCPaZrr0MLx4CGXefJ5kKvHdJWJOMgoEs oz1xxcdrYX6OWI/a7HbVgnhDB+coq8h2lwru3WnuEC0tRQJ1tu1i7ctKotpFf7x7SP4g Nx6HcbVKqk8fJchNLZJPcNxE9+7iQloOjL3X9jk/VRJdzUBOKaoZfH/nEDgQKqIsiqmH 5UHA== X-Received: by 10.68.217.234 with SMTP id pb10mr8254085pbc.142.1396339741831; Tue, 01 Apr 2014 01:09:01 -0700 (PDT) Received: from [192.168.1.7] (ppp59-167-128-11.static.internode.on.net. [59.167.128.11]) by mx.google.com with ESMTPSA id qq5sm48224891pbb.24.2014.04.01.01.08.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Apr 2014 01:09:01 -0700 (PDT) Message-ID: <533A7416.7030605@FreeBSD.org> Date: Tue, 01 Apr 2014 19:08:54 +1100 From: Kubilay Kocak User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Thunderbird/28.0 MIME-Version: 1.0 To: Edward Tomasz Napierala , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r263978 - head/sys/cam/ctl References: <201403312049.s2VKnXLr079029@svn.freebsd.org> In-Reply-To: <201403312049.s2VKnXLr079029@svn.freebsd.org> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: koobs@FreeBSD.org 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:09:02 -0000 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 > > Log: > Make it possible to have multiple CTL worker threads. Leave the default > of 1 for now. > > Sponsored by: The FreeBSD Foundation > > Modified: > head/sys/cam/ctl/ctl.c > > Modified: head/sys/cam/ctl/ctl.c > ============================================================================== > --- 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 > > @@ -320,6 +321,10 @@ static int ctl_is_single = 1; > static int index_to_aps_page; > > SYSCTL_NODE(_kern_cam, OID_AUTO, ctl, CTLFLAG_RD, 0, "CAM Target Layer"); > +static int worker_threads = 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"); > > /* > * 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 =0; > -#if 0 > - int i; > -#endif > - int error, retval; > + int i, error, retval; > //int isc_retval; > > retval = 0; > @@ -1085,17 +1087,35 @@ ctl_init(void) > mtx_unlock(&softc->ctl_lock); > #endif > > - error = kproc_create(ctl_work_thread, softc, &softc->work_thread, 0, 0, > - "ctl_thrd"); > - if (error != 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 == 0) { > + printf("invalid kern.cam.ctl.worker_threads value; " > + "setting to 1"); > + worker_threads = 1; > + } else if (worker_threads < 0) { Why is it that the < 0 case is special enough that it gets the mp_ncpus check below, but the == 0 and > MAXCPU cases don't? > + if (mp_ncpus > 2) { > + /* > + * Using more than two worker threads actually hurts > + * performance due to lock contention. > + */ > + worker_threads = 2; > + } else { > + worker_threads = 1; > + } 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? > + } > + > + for (i = 0; i < worker_threads; i++) { > + error = kproc_create(ctl_work_thread, softc, &softc->work_thread, 0, 0, > + "ctl_thrd%d", i); > + if (error != 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 (bootverbose) > printf("ctl: CAM Target Layer loaded\n"); > @@ -12991,7 +13011,11 @@ ctl_work_thread(void *arg) > if (io != NULL) { > STAILQ_REMOVE_HEAD(&softc->rtr_queue, links); > mtx_unlock(&softc->ctl_lock); > - goto execute; > + retval = ctl_scsiio(&io->scsiio); > + if (retval != CTL_RETVAL_COMPLETE) > + CTL_DEBUG_PRINT(("ctl_scsiio failed\n")); > + mtx_lock(&softc->ctl_lock); > + continue; > } > } > io = (union ctl_io *)STAILQ_FIRST(&softc->incoming_queue); > @@ -13022,19 +13046,6 @@ ctl_work_thread(void *arg) > > /* Back to the top of the loop to see what woke us up. */ > continue; > - > -execute: > - retval = ctl_scsiio(&io->scsiio); > - switch (retval) { > - case CTL_RETVAL_COMPLETE: > - break; > - default: > - /* > - * Probably need to make sure this doesn't happen. > - */ > - break; > - } > - mtx_lock(&softc->ctl_lock); > } > } > > _______________________________________________ > svn-src-head@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org" >