svn commit: r263978 - head/sys/cam/ctl
Edward Tomasz Napierała
trasz at FreeBSD.org
Tue Apr 1 08:43:56 UTC 2014
Wiadomość 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
>>
>> 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 <sys/ioccom.h>
>> #include <sys/queue.h>
>> #include <sys/sbuf.h>
>> +#include <sys/smp.h>
>> #include <sys/endian.h>
>> #include <sys/sysctl.h>
>>
>> @@ -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?
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.
>> + */
>
>> + 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?
The warning is to inform the user why the value supplied was ignored
as invalid. The -1 setting is always valid.
More information about the svn-src-all
mailing list