From 08344b293eab865a57e4629b178f2003dced397e Mon Sep 17 00:00:00 2001 From: Gordon Ross Date: Thu, 15 Sep 2011 11:27:52 -0400 Subject: [PATCH] 1517 smbsrv workers run at excessively high priority Reviewed by: Eric Schrock Reviewed by: Dan McDonald Reviewed by: Robert Mustacchi Approved by: Garrett D'Amore --- usr/src/uts/common/fs/smbsrv/smb_init.c | 18 ++++++++++++++++++ usr/src/uts/common/fs/smbsrv/smb_kshare.c | 2 +- usr/src/uts/common/fs/smbsrv/smb_kutil.c | 6 ++++-- usr/src/uts/common/fs/smbsrv/smb_oplock.c | 3 ++- usr/src/uts/common/fs/smbsrv/smb_server.c | 11 ++++++----- usr/src/uts/common/smbsrv/smb_kproto.h | 11 ++++++++++- usr/src/uts/common/smbsrv/smb_ktypes.h | 2 +- 7 files changed, 42 insertions(+), 11 deletions(-) diff --git a/usr/src/uts/common/fs/smbsrv/smb_init.c b/usr/src/uts/common/fs/smbsrv/smb_init.c index 15ceb53dce..87a53cf9fb 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_init.c +++ b/usr/src/uts/common/fs/smbsrv/smb_init.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -92,6 +93,23 @@ int smb_opipe_timeout = (30 * 1000); int smb_threshold_debug = 0; +/* + * Thread priorities used in smbsrv. Our threads spend most of their time + * blocked on various conditions. However, if the system gets heavy load, + * the scheduler has to choose an order to run these. We want the order: + * (a) timers, (b) notifications, (c) workers, (d) receivers (and etc.) + * where notifications are oplock and change notify work. Aside from this + * relative ordering, smbsrv threads should run with a priority close to + * that of normal user-space threads (thus minclsyspri below), just like + * NFS and other "file service" kinds of processing. + */ +int smbsrv_base_pri = MINCLSYSPRI; +int smbsrv_listen_pri = MINCLSYSPRI; +int smbsrv_receive_pri = MINCLSYSPRI; +int smbsrv_worker_pri = MINCLSYSPRI + 1; +int smbsrv_notify_pri = MINCLSYSPRI + 2; +int smbsrv_timer_pri = MINCLSYSPRI + 5; + /* * ***************************************************************************** diff --git a/usr/src/uts/common/fs/smbsrv/smb_kshare.c b/usr/src/uts/common/fs/smbsrv/smb_kshare.c index 9cf83a0297..a3fe65a424 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_kshare.c +++ b/usr/src/uts/common/fs/smbsrv/smb_kshare.c @@ -311,7 +311,7 @@ smb_kshare_init(void) sizeof (smb_unshare_t), offsetof(smb_unshare_t, us_lnd)); smb_thread_init(&smb_export.e_unexport_thread, "smb_thread_unexport", - smb_kshare_unexport_thread, NULL); + smb_kshare_unexport_thread, NULL, smbsrv_base_pri); if ((rc = smb_thread_start(&smb_export.e_unexport_thread)) != 0) return (rc); diff --git a/usr/src/uts/common/fs/smbsrv/smb_kutil.c b/usr/src/uts/common/fs/smbsrv/smb_kutil.c index abfbdea701..f417ca9db4 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_kutil.c +++ b/usr/src/uts/common/fs/smbsrv/smb_kutil.c @@ -803,7 +803,8 @@ smb_thread_init( smb_thread_t *thread, char *name, smb_thread_ep_t ep, - void *ep_arg) + void *ep_arg, + pri_t pri) { ASSERT(thread->sth_magic != SMB_THREAD_MAGIC); @@ -813,6 +814,7 @@ smb_thread_init( thread->sth_ep = ep; thread->sth_ep_arg = ep_arg; thread->sth_state = SMB_THREAD_STATE_EXITED; + thread->sth_pri = pri; mutex_init(&thread->sth_mtx, NULL, MUTEX_DEFAULT, NULL); cv_init(&thread->sth_cv, NULL, CV_DEFAULT, NULL); thread->sth_magic = SMB_THREAD_MAGIC; @@ -854,7 +856,7 @@ smb_thread_start( thread->sth_state = SMB_THREAD_STATE_STARTING; mutex_exit(&thread->sth_mtx); tmpthread = thread_create(NULL, 0, smb_thread_entry_point, - thread, 0, &p0, TS_RUN, minclsyspri); + thread, 0, &p0, TS_RUN, thread->sth_pri); ASSERT(tmpthread != NULL); mutex_enter(&thread->sth_mtx); while (thread->sth_state == SMB_THREAD_STATE_STARTING) diff --git a/usr/src/uts/common/fs/smbsrv/smb_oplock.c b/usr/src/uts/common/fs/smbsrv/smb_oplock.c index d86c310103..a21f0ddc21 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_oplock.c +++ b/usr/src/uts/common/fs/smbsrv/smb_oplock.c @@ -19,6 +19,7 @@ * CDDL HEADER END */ /* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -98,7 +99,7 @@ smb_oplock_init(void) offsetof(smb_oplock_break_t, ob_lnd)); smb_thread_init(&smb_oplock_thread, "smb_thread_oplock_break", - smb_oplock_break_thread, NULL); + smb_oplock_break_thread, NULL, smbsrv_notify_pri); rc = smb_thread_start(&smb_oplock_thread); if (rc != 0) { diff --git a/usr/src/uts/common/fs/smbsrv/smb_server.c b/usr/src/uts/common/fs/smbsrv/smb_server.c index 8687d42b18..0af7412fc3 100644 --- a/usr/src/uts/common/fs/smbsrv/smb_server.c +++ b/usr/src/uts/common/fs/smbsrv/smb_server.c @@ -397,8 +397,8 @@ smb_server_create(void) sv->si_cache_event = kmem_cache_create("smb_event_cache", sizeof (smb_event_t), 8, NULL, NULL, NULL, NULL, NULL, 0); - smb_thread_init(&sv->si_thread_timers, - "smb_timers", smb_server_timers, sv); + smb_thread_init(&sv->si_thread_timers, "smb_timers", + smb_server_timers, sv, smbsrv_timer_pri); sv->sv_pid = curproc->p_pid; smb_srqueue_init(&sv->sv_srqueue); @@ -576,12 +576,12 @@ smb_server_start(smb_ioc_start_t *ioc) smb_codepage_init(); sv->sv_worker_pool = taskq_create("smb_workers", - sv->sv_cfg.skc_maxworkers, SMB_WORKER_PRIORITY, + sv->sv_cfg.skc_maxworkers, smbsrv_worker_pri, sv->sv_cfg.skc_maxworkers, INT_MAX, TASKQ_DYNAMIC|TASKQ_PREPOPULATE); sv->sv_receiver_pool = taskq_create("smb_receivers", - sv->sv_cfg.skc_maxconnections, SMB_WORKER_PRIORITY, + sv->sv_cfg.skc_maxconnections, smbsrv_receive_pri, sv->sv_cfg.skc_maxconnections, INT_MAX, TASKQ_DYNAMIC); @@ -1468,7 +1468,8 @@ smb_server_listener_init( smb_llist_constructor(&ld->ld_session_list, sizeof (smb_session_t), offsetof(smb_session_t, s_lnd)); - smb_thread_init(&ld->ld_thread, name, smb_server_listener, ld); + smb_thread_init(&ld->ld_thread, name, smb_server_listener, ld, + smbsrv_listen_pri); ld->ld_magic = SMB_LISTENER_MAGIC; } diff --git a/usr/src/uts/common/smbsrv/smb_kproto.h b/usr/src/uts/common/smbsrv/smb_kproto.h index ad7402fd80..0e63be43f1 100644 --- a/usr/src/uts/common/smbsrv/smb_kproto.h +++ b/usr/src/uts/common/smbsrv/smb_kproto.h @@ -72,6 +72,14 @@ extern int smb_opipe_timeout; extern int smb_threshold_debug; extern const uint32_t smb_vop_dosattr_settable; +/* Thread priorities - see smb_init.c */ +extern int smbsrv_base_pri; +extern int smbsrv_listen_pri; +extern int smbsrv_receive_pri; +extern int smbsrv_worker_pri; +extern int smbsrv_notify_pri; +extern int smbsrv_timer_pri; + int fd_dealloc(int); off_t lseek(int fildes, off_t offset, int whence); @@ -732,7 +740,8 @@ int smb_rwx_rwwait(smb_rwx_t *rwx, clock_t timeout); krw_t smb_rwx_rwupgrade(smb_rwx_t *rwx); void smb_rwx_rwdowngrade(smb_rwx_t *rwx, krw_t mode); -void smb_thread_init(smb_thread_t *, char *, smb_thread_ep_t, void *); +void smb_thread_init(smb_thread_t *, char *, smb_thread_ep_t, + void *, pri_t); void smb_thread_destroy(smb_thread_t *); int smb_thread_start(smb_thread_t *); void smb_thread_stop(smb_thread_t *); diff --git a/usr/src/uts/common/smbsrv/smb_ktypes.h b/usr/src/uts/common/smbsrv/smb_ktypes.h index 2c5d102f62..f511223be7 100644 --- a/usr/src/uts/common/smbsrv/smb_ktypes.h +++ b/usr/src/uts/common/smbsrv/smb_ktypes.h @@ -186,7 +186,6 @@ typedef struct { smb_audit_record_node_t anb_records[SMB_AUDIT_BUF_MAX_REC]; } smb_audit_buf_node_t; -#define SMB_WORKER_PRIORITY 99 /* * Thread State Machine * -------------------- @@ -261,6 +260,7 @@ typedef struct _smb_thread { kt_did_t sth_did; smb_thread_ep_t sth_ep; void *sth_ep_arg; + pri_t sth_pri; boolean_t sth_kill; kmutex_t sth_mtx; kcondvar_t sth_cv; -- 2.11.4.GIT