Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfsd: add controls to set the minimum number of threads per pool

Add a new "min_threads" variable to the nfsd_net, along with the
corresponding netlink interface, to set that value from userland.
Pass that value to svc_set_pool_threads() and svc_set_num_threads().

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

authored by

Jeff Layton and committed by
Chuck Lever
d8316b83 1c87a0c3

+42 -4
+5
Documentation/netlink/specs/nfsd.yaml
··· 78 78 - 79 79 name: scope 80 80 type: string 81 + - 82 + name: min-threads 83 + type: u32 81 84 - 82 85 name: version 83 86 attributes: ··· 162 159 - gracetime 163 160 - leasetime 164 161 - scope 162 + - min-threads 165 163 - 166 164 name: threads-get 167 165 doc: get the number of running threads ··· 174 170 - gracetime 175 171 - leasetime 176 172 - scope 173 + - min-threads 177 174 - 178 175 name: version-set 179 176 doc: set nfs enabled versions
+3 -2
fs/nfsd/netlink.c
··· 24 24 }; 25 25 26 26 /* NFSD_CMD_THREADS_SET - do */ 27 - static const struct nla_policy nfsd_threads_set_nl_policy[NFSD_A_SERVER_SCOPE + 1] = { 27 + static const struct nla_policy nfsd_threads_set_nl_policy[NFSD_A_SERVER_MIN_THREADS + 1] = { 28 28 [NFSD_A_SERVER_THREADS] = { .type = NLA_U32, }, 29 29 [NFSD_A_SERVER_GRACETIME] = { .type = NLA_U32, }, 30 30 [NFSD_A_SERVER_LEASETIME] = { .type = NLA_U32, }, 31 31 [NFSD_A_SERVER_SCOPE] = { .type = NLA_NUL_STRING, }, 32 + [NFSD_A_SERVER_MIN_THREADS] = { .type = NLA_U32, }, 32 33 }; 33 34 34 35 /* NFSD_CMD_VERSION_SET - do */ ··· 58 57 .cmd = NFSD_CMD_THREADS_SET, 59 58 .doit = nfsd_nl_threads_set_doit, 60 59 .policy = nfsd_threads_set_nl_policy, 61 - .maxattr = NFSD_A_SERVER_SCOPE, 60 + .maxattr = NFSD_A_SERVER_MIN_THREADS, 62 61 .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, 63 62 }, 64 63 {
+6
fs/nfsd/netns.h
··· 129 129 seqlock_t writeverf_lock; 130 130 unsigned char writeverf[8]; 131 131 132 + /* 133 + * Minimum number of threads to run per pool. If 0 then the 134 + * min == max requested number of threads. 135 + */ 136 + unsigned int min_threads; 137 + 132 138 u32 clientid_base; 133 139 u32 clientid_counter; 134 140 u32 clverifier_counter;
+6
fs/nfsd/nfsctl.c
··· 1642 1642 scope = nla_data(attr); 1643 1643 } 1644 1644 1645 + attr = info->attrs[NFSD_A_SERVER_MIN_THREADS]; 1646 + if (attr) 1647 + nn->min_threads = nla_get_u32(attr); 1648 + 1645 1649 ret = nfsd_svc(nrpools, nthreads, net, get_current_cred(), scope); 1646 1650 if (ret > 0) 1647 1651 ret = 0; ··· 1685 1681 nn->nfsd4_grace) || 1686 1682 nla_put_u32(skb, NFSD_A_SERVER_LEASETIME, 1687 1683 nn->nfsd4_lease) || 1684 + nla_put_u32(skb, NFSD_A_SERVER_MIN_THREADS, 1685 + nn->min_threads) || 1688 1686 nla_put_string(skb, NFSD_A_SERVER_SCOPE, 1689 1687 nn->nfsd_name); 1690 1688 if (err)
+2 -2
fs/nfsd/nfssvc.c
··· 690 690 691 691 /* Special case: When n == 1, distribute threads equally among pools. */ 692 692 if (n == 1) 693 - return svc_set_num_threads(nn->nfsd_serv, 0, nthreads[0]); 693 + return svc_set_num_threads(nn->nfsd_serv, nn->min_threads, nthreads[0]); 694 694 695 695 if (n > nn->nfsd_serv->sv_nrpools) 696 696 n = nn->nfsd_serv->sv_nrpools; ··· 718 718 for (i = 0; i < n; i++) { 719 719 err = svc_set_pool_threads(nn->nfsd_serv, 720 720 &nn->nfsd_serv->sv_pools[i], 721 - 0, nthreads[i]); 721 + nn->min_threads, nthreads[i]); 722 722 if (err) 723 723 goto out; 724 724 }
+19
fs/nfsd/trace.h
··· 2164 2164 ) 2165 2165 ); 2166 2166 2167 + TRACE_EVENT(nfsd_ctl_minthreads, 2168 + TP_PROTO( 2169 + const struct net *net, 2170 + int minthreads 2171 + ), 2172 + TP_ARGS(net, minthreads), 2173 + TP_STRUCT__entry( 2174 + __field(unsigned int, netns_ino) 2175 + __field(int, minthreads) 2176 + ), 2177 + TP_fast_assign( 2178 + __entry->netns_ino = net->ns.inum; 2179 + __entry->minthreads = minthreads 2180 + ), 2181 + TP_printk("minthreads=%d", 2182 + __entry->minthreads 2183 + ) 2184 + ); 2185 + 2167 2186 TRACE_EVENT(nfsd_ctl_time, 2168 2187 TP_PROTO( 2169 2188 const struct net *net,
+1
include/uapi/linux/nfsd_netlink.h
··· 35 35 NFSD_A_SERVER_GRACETIME, 36 36 NFSD_A_SERVER_LEASETIME, 37 37 NFSD_A_SERVER_SCOPE, 38 + NFSD_A_SERVER_MIN_THREADS, 38 39 39 40 __NFSD_A_SERVER_MAX, 40 41 NFSD_A_SERVER_MAX = (__NFSD_A_SERVER_MAX - 1)