4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
33 #include <sys/priocntl.h>
34 #include <sys/fxpriocntl.h>
36 #include <nfs/nfssys.h>
39 extern int _nfssys(int, void *);
42 * Thread to call into the kernel and do work on behalf of NFS.
50 * Create a kernel worker thread to service
51 * new incoming requests on a pool.
53 _nfssys(SVCPOOL_RUN
, &id
);
56 * Returned from the kernel, this thread's work is done,
57 * and it should exit. For new incoming requests,
58 * svcblock() will spawn another worker thread by
59 * calling svcstart() again.
66 svc_rdma_creator(void *arg
)
68 struct rdma_svc_args
*rsap
= (struct rdma_svc_args
*)arg
;
70 if (_nfssys(RDMA_SVC_INIT
, rsap
) < 0) {
71 if (errno
!= ENODEV
) {
72 (void) syslog(LOG_INFO
, "RDMA transport startup "
82 * User-space "creator" thread. This thread blocks in the kernel
83 * until new worker threads need to be created for the service
84 * pool. On return to userspace, if there is no error, create a
85 * new thread for the service pool.
97 * Call into the kernel, and hang out there
98 * until a thread needs to be created.
100 if (_nfssys(SVCPOOL_WAIT
, &id
) < 0) {
101 if (errno
== ECANCELED
|| errno
== EINTR
||
104 * If we get back ECANCELED or EINTR,
105 * the service pool is exiting, and we
106 * may as well clean up this thread. If
107 * EBUSY is returned, there's already a
108 * thread looping on this pool, so we
117 * User portion of the thread does no real work since
118 * the svcpool threads actually spend their entire
119 * lives in the kernel. So, user portion of the thread
120 * should have the smallest stack possible.
122 (void) thr_create(NULL
, THR_MIN_STACK
, svcstart
, (void *)id
,
123 THR_BOUND
| THR_DETACHED
, &tid
);
137 * By default, all threads should be part of the FX scheduler
138 * class. As nfsd/lockd server threads used to be part of the
139 * kernel, they're used to being scheduled in the SYS class.
140 * Userland threads shouldn't be in SYS, but they can be given a
141 * higher priority by default. This change still renders nfsd/lockd
142 * managable by an admin by utilizing commands to change scheduling
143 * manually, or by using resource management tools such as pools
144 * to associate them with a different scheduling class and segregate
147 * We set the threads' priority to the upper bound for priorities
148 * in FX. This should be 60, but since the desired action is to
149 * make nfsd/lockd more important than TS threads, we bow to the
150 * system's knowledge rather than setting it manually. Furthermore,
151 * since the SYS class doesn't timeslice, use an "infinite" quantum.
152 * If anything fails, just log the failure and let the daemon
155 * The change of scheduling class is expected to fail in a non-global
156 * zone, so we avoid worrying the zone administrator unnecessarily.
158 (void) strcpy(pcinfo
.pc_clname
, "FX");
159 if (priocntl(0, 0, PC_GETCID
, (caddr_t
)&pcinfo
) != -1) {
160 maxupri
= ((fxinfo_t
*)pcinfo
.pc_clinfo
)->fx_maxupri
;
161 if (priocntl(P_LWPID
, P_MYID
, PC_SETXPARMS
, "FX",
162 FX_KY_UPRILIM
, maxupri
, FX_KY_UPRI
, maxupri
,
163 FX_KY_TQNSECS
, FX_TQINF
, NULL
) != 0 &&
164 getzoneid() == GLOBAL_ZONEID
)
165 (void) syslog(LOG_ERR
, "Unable to use FX scheduler: "
166 "%m. Using system default scheduler.");
168 (void) syslog(LOG_ERR
, "Unable to determine parameters "
169 "for FX scheduler. Using system default scheduler.");
173 svcrdma(int id
, int versmin
, int versmax
, int delegation
)
176 struct rdma_svc_args
*rsa
;
178 rsa
= (struct rdma_svc_args
*)malloc(sizeof (struct rdma_svc_args
));
179 rsa
->poolid
= (uint32_t)id
;
181 rsa
->nfs_versmin
= versmin
;
182 rsa
->nfs_versmax
= versmax
;
183 rsa
->delegation
= delegation
;
186 * Create a thread to handle RDMA start and stop.
188 if (thr_create(NULL
, THR_MIN_STACK
* 2, svc_rdma_creator
, (void *)rsa
,
189 THR_BOUND
| THR_DETACHED
, &tid
))
201 * Create a bound thread to wait for kernel LWPs that
202 * need to be created. This thread also has little need
203 * of stackspace, so should be created with that in mind.
205 if (thr_create(NULL
, THR_MIN_STACK
* 2, svcblock
, (void *)id
,
206 THR_BOUND
| THR_DETACHED
, &tid
))