sunrpc: hardcode pool_mode to pernode, remove other modes
Subsystems (4)
Jeff Layton
maintainerv5 cover sunrpc: hardcode pool_mode to pernode, remove other modes
This has a few small fixes and comment cleanups and also implements Neil's suggestion to remove serv.sv_nrpools:
Patches #1 and #3 address what is a shortcoming of the existing code -- namely that the server can be configured to schedule RPCs to pools with no threads in them.
The first patch addresses this problem: if the chosen pool has no threads, then choose another that does.
The third patch tries to prevent this situation in the auto-thread-placement case by ensuring that each populated node has at least one thread.
The last two patches implement Neil's suggestion to eliminate serv.sv_nrpools. This has the side effect of getting the modulus out of the svc_pool_for_cpu() hotpath as well.
---
Changes in v5:
- Expand patch to eliminate modulus to also eliminate serv.sv_nrpools field
- Revised comments in svc_pool_for_cpu()
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Drop 5/4 RCU patch
- Only let pooled services consult the map
- Comment and commit log fixes
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Add patch to ensure that we don't route requests to empty pools
- When auto-distributing threads, always create at least one thread per populated pool
- Use sysfs_match_string for the module parameter
- Reword deprecation printk to be more vague about removal
- Explicitly set m_count == 0 in svc_pool_map_get()
- Optimize svc_pool_for_cpu() by eliminating modulus ops
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Accept any previously-accepted setting for pool_mode
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Jeff Layton (5):
sunrpc: route to a populated pool in svc_pool_for_cpu()
sunrpc: hardcode pool_mode to pernode, remove other modes
sunrpc: guarantee a thread per pool when auto-distributing
sunrpc: tear down pool counters before dropping the pool map reference
sunrpc: derive the pool count instead of caching it in sv_nrpools
Documentation/admin-guide/kernel-parameters.txt | 20 +- fs/nfsd/nfsctl.c | 2 +- fs/nfsd/nfssvc.c | 10 +- include/linux/sunrpc/svc.h | 2 +- net/sunrpc/svc.c | 355 +++++++++--------------- net/sunrpc/svc_xprt.c | 6 +- 6 files changed, 152 insertions(+), 243 deletions(-)
---
base-commit: ee6ae4a6bf3565b880dfb420017337475dfbc9ea
change-id: 20260423-sunrpc-pool-mode-3e6b56320dc4
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
Jeff Layton
maintainerPATCH v5 1/5 sunrpc: route to a populated pool in svc_pool_for_cpu()
svc_set_num_threads() spreads the requested threads evenly across the service's pools (base = nrservs / sv_nrpools). When a service runs fewer threads than it has pools -- e.g. an nfsd configured with fewer threads than the host has NUMA nodes while running in "pernode" or "percpu" mode -- the trailing pools are left with no threads at all.
svc_xprt_enqueue() selects a pool from the CPU servicing the transport, queues the transport on that pool's sp_xprts, and only wakes a thread from the same pool. Each thread services exclusively its own pool, so a transport that lands on a threadless pool is enqueued on sp_xprts and never picked up: the connection hangs indefinitely.
Have svc_pool_for_cpu() skip pools that currently have no threads, falling back to the next populated pool. This trades NUMA locality for a guarantee that the work is actually serviced. sp_nrthreads is only updated under the service mutex; the lockless read here is a best-effort routing hint, so annotate it with data_race().
--- net/sunrpc/svc.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
net/sunrpc/svc.c +28 -1
@@ -402,6 +402,7 @@ struct svc_pool *svc_pool_for_cpu(struct svc_serv *serv)struct svc_pool_map *m = &svc_pool_map;int cpu =raw_smp_processor_id ();unsigned int pidx =0 ; +unsigned int i;if (serv->sv_nrpools <=1 )return serv->sv_pools;
@@ -414,8 +415,34 @@ struct svc_pool *svc_pool_for_cpu(struct svc_serv *serv) pidx = m->to_pool[cpu_to_node (cpu)];break ; } + pidx %= serv->sv_nrpools; + +/* +* It's possible to have a pool with no threads. Userland can just set +* things up this way directly. Also, when threads are autodistributed +* they are spread evenly across the pools, but when there are fewer +* threads than pools some pools can end up with none. +* +* A transport enqueued on a threadless pool would never be picked up, +* since each thread only services its own pool. Fall back to the next +* populated pool, trading NUMA locality for a guarantee that the +* transport is serviced. +*/ +for (i =0 ; i < serv->sv_nrpools; i++) { +struct svc_pool *pool = &serv->sv_pools[pidx]; + +/* This is set under the sp_mutex and rarely ever changes. A +* data race here is harmless. +*/ +if (data_race (pool->sp_nrthreads)) +return pool; + +if (++pidx >= serv->sv_nrpools) + pidx =0 ; + } -return &serv->sv_pools[pidx % serv->sv_nrpools]; +/* No pool has any threads; nothing can service the transport. */ +return &serv->sv_pools[pidx]; }static int svc_rpcb_setup (struct svc_serv *serv,struct net *net)
Signature · 1 line
2.55.0
Jeff Layton
maintainerPATCH v5 2/5 sunrpc: hardcode pool_mode to pernode, remove other modes
In reply to Jeff LaytonThe SVC_POOL_AUTO/GLOBAL/PERCPU/PERNODE pool mode selection machinery was added when NUMA was new and the right default was unclear. The default has always been "global" (a single pool for the whole service); the other modes were only used when an admin explicitly set the pool_mode parameter or asked for "auto", which then picked a mode from the host topology. Today, pernode is the right choice everywhere:
- On multi-NUMA hosts, it gives one pool per node with proper thread affinity and NUMA-local memory allocation.
- On single-node hosts, pernode degenerates to exactly one pool, identical to the old "global" mode -- svc_pool_for_cpu() short- circuits when sv_nrpools <= 1, no CPU affinity is set, and memory is allocated from the single node.
The percpu mode (one pool per CPU) created excessive pools relative to the number of threads most deployments run, and was only auto-selected in a narrow case (single node, >2 CPUs).
Note that this changes the default behaviour on multi-NUMA hosts: a service that previously ran with a single global pool now gets one pool per NUMA node by default. This in turn means a host running fewer threads than it has NUMA nodes can end up with pools that have no threads. svc_pool_for_cpu() already falls back to a populated pool in that case, so transports are still serviced.
Remove the SVC_POOL_* enum, mode selection heuristic, svc_pool_map_init_percpu(), and all mode-based switch statements. Simplify pool map functions to always use the pernode path. If pool map allocation fails, svc_pool_map_get() now returns 0 and service creation fails, rather than silently falling back to a single global pool.
With the mode check gone, svc_pool_map_get_node() would dereference the shared pool_to[] for every service that starts a thread. Only services created via svc_create_pooled() hold a map reference that keeps that array allocated, so gate the lookup in svc_new_thread() on sv_is_pooled:
unpooled services (e.g. lockd, the NFS callback) use NUMA_NO_NODE and never consult the map. The kmalloc_node() callers in svc_prepare_thread() already accept NUMA_NO_NODE, but __folio_alloc_node() requires a valid node id, so resolve NUMA_NO_NODE to numa_mem_id() for the scratch folio allocation.
The module parameter and netlink interfaces are preserved for backward compatibility:
- Writing any of the four documented mode names still succeeds silently
- Reading always returns "pernode"
- Writing to the module parameter emits a deprecation notice
Update Documentation/admin-guide/kernel-parameters.txt to mark the pool_mode parameter deprecated and describe the new behaviour.
--- Documentation/admin-guide/kernel-parameters.txt | 20 +- net/sunrpc/svc.c | 265 ++++++------------------ 2 files changed, 65 insertions(+), 220 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +7 -13
@@ -7441,19 +7441,13 @@ Kernel parameters sunrpc.pool_mode= [NFS] - Control how the NFS server code allocates CPUs to - service thread pools. Depending on how many NICs - you have and where their interrupts are bound, this - option will affect which CPUs will do NFS serving. - Note: this parameter cannot be changed while the - NFS server is running. - - auto the server chooses an appropriate mode - automatically using heuristics - global a single global pool contains all CPUs - percpu one pool for each CPU - pernode one pool for each NUMA node (equivalent - to global on non-NUMA machines) + Deprecated. The NFS server now always uses one + service thread pool per NUMA node (equivalent to a + single global pool on non-NUMA machines). All of + the previously accepted values (auto, global, + percpu, pernode) are still accepted for backward + compatibility but are ignored: the mode is always + pernode, and reads always return "pernode". sunrpc.tcp_slot_table_entries= sunrpc.udp_slot_table_entries=
net/sunrpc/svc.c +58 -207
388 lines not on this page · raw message
Signature · 1 line
2.55.0
Jeff Layton
maintainerPATCH v5 3/5 sunrpc: guarantee a thread per pool when auto-distributing
In reply to Jeff Laytonsvc_set_num_threads() spreads the requested thread count evenly across the service's pools. In pernode mode each pool maps to a NUMA node, and svc_pool_for_cpu() steers an incoming transport to the pool for the node it arrived on. When fewer threads than pools are requested, even distribution leaves some pools empty, and a transport steered to an empty pool has no thread to service it.
Floor each pool at one thread when auto-distributing a non-zero count, so no pool is left empty. Every pool maps to a node that had CPUs when the pool map was built (svc_pool_map_init_pernode() only creates pools for nodes returned by for_each_node_with_cpus()), so there is no pool that should be left threadless. The resulting total may exceed the requested count. This only affects the auto-distribute path (a single-value array, i.e. svc_set_num_threads()); callers that set per-pool counts explicitly via svc_set_pool_threads() are unchanged and may still set a pool to zero.
--- net/sunrpc/svc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
net/sunrpc/svc.c +16 -0
@@ -840,6 +840,12 @@ EXPORT_SYMBOL_GPL(svc_set_pool_threads);* are multiple pools then the new threads or victims will be distributed * evenly among them. * +* When @nrservs is non-zero but smaller than the number of pools, even +* distribution would leave some pools empty. Since each pool maps to a +* NUMA node and only services transports steered to that node, every +* pool is instead guaranteed at least one thread. The resulting total +* may therefore exceed @nrservs. +* * Caller must ensure mutual exclusion between this and server startup or * shutdown. *
@@ -855,6 +861,16 @@ svc_set_num_threads(struct svc_serv *serv, unsigned int min_threads,unsigned int remain = nrservs % serv->sv_nrpools;int i, err =0 ; +/* +* Don't let a pool sit empty while threads are being +* auto-distributed: a transport steered to its node would have +* nothing to service it. Every pool maps to a CPU-bearing node, +* so hand each one a thread. This may push the total above +* @nrservs. +*/ +if (base ==0 && nrservs !=0 ) + remain = serv->sv_nrpools; +for (i =0 ; i < serv->sv_nrpools; ++i) {struct svc_pool *pool = &serv->sv_pools[i];int threads = base;
Signature · 1 line
2.55.0
Jeff Layton
maintainerPATCH v5 4/5 sunrpc: tear down pool counters before dropping the pool map reference
In reply to Jeff Laytonsvc_destroy() drops the service's reference to the global svc_pool_map before iterating serv->sv_pools[] to destroy each pool's percpu counters. That ordering happens to be fine today because the loop is bounded by the per-service sv_nrpools field.
A following patch removes sv_nrpools and derives the pool count from the pool map instead. svc_pool_map_put() zeroes svc_pool_map.npools when the last reference is dropped, so a derived loop bound would read as zero for the last pooled service and skip svc_pool_destroy_counters() entirely, leaking the percpu counters (which remain linked on the global percpu_counters list while the svc_serv is freed).
Reorder svc_destroy() to destroy the pool counters while the map is still referenced, then drop the reference. No functional change.
--- net/sunrpc/svc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/sunrpc/svc.c +4 -3
@@ -520,14 +520,15 @@ svc_destroy(struct svc_serv **servp)cache_clean_deferred (serv); -if (serv->sv_is_pooled) -svc_pool_map_put (); -for (i =0 ; i < serv->sv_nrpools; i++) {struct svc_pool *pool = &serv->sv_pools[i];svc_pool_destroy_counters (pool); } + +if (serv->sv_is_pooled) +svc_pool_map_put (); +kfree (serv->sv_pools);kfree (serv); }
Signature · 1 line
2.55.0
Jeff Layton
maintainerPATCH v5 5/5 sunrpc: derive the pool count instead of caching it in sv_nrpools
In reply to Jeff LaytonNow that the pool mode is always pernode, svc_serv.sv_nrpools is redundant with sv_is_pooled: an unpooled service always has a single pool, and a pooled service has svc_pool_map.npools pools (which is one on a single-node host). sv_nrpools cannot distinguish an unpooled service from a pooled service that happens to have one pool, so it is sv_nrpools, not sv_is_pooled, that carries no unique information.
Replace the cached field with a svc_serv_nrpools() helper that derives the count from sv_is_pooled and the pool map, and convert all readers to it. svc_pool_map is file-local to svc.c, so export the helper for the svc_xprt.c and nfsd callers.
Reading svc_pool_map.npools without svc_pool_map_mutex is safe: the mutex protects only svc_pool_map.count, and npools is already read locklessly in svc_pool_for_cpu().
A pooled service holds a map reference for its whole lifetime, so npools is stable while any reader could observe it. The hot path (svc_pool_for_cpu()) already dereferences svc_pool_map for to_pool, and npools shares that cacheline, so there is no new locking or coherence cost.
__svc_create() keeps using its local npools argument for the sv_pools[] allocation, since sv_is_pooled is not set until svc_create_pooled() has returned from it.
Doing this also removes a modulus operation from svc_pool_for_cpu(), which should make for more efficient RPC queueing.
--- fs/nfsd/nfsctl.c | 2 +- fs/nfsd/nfssvc.c | 10 ++++----- include/linux/sunrpc/svc.h | 2 +- net/sunrpc/svc.c | 52 ++++++++++++++++++++++++++++++++-------------- net/sunrpc/svc_xprt.c | 6 +++--- 5 files changed, 46 insertions(+), 26 deletions(-)
fs/nfsd/nfsctl.c +1 -1
@@ -1526,7 +1526,7 @@ int nfsd_nl_rpc_status_get_dumpit(struct sk_buff *skb,rcu_read_lock (); -for (i =0 ; i < nn->nfsd_serv->sv_nrpools; i++) { +for (i =0 ; i <svc_serv_nrpools (nn->nfsd_serv); i++) {struct svc_rqst *rqstp;long thread_skip =0 ;
fs/nfsd/nfssvc.c +5 -5
@@ -655,7 +655,7 @@ int nfsd_nrpools(struct net *net)if (nn->nfsd_serv ==NULL )return 0 ;else -return nn->nfsd_serv->sv_nrpools; +return svc_serv_nrpools (nn->nfsd_serv); }int nfsd_get_nrthreads (int n,int *nthreads,struct net *net)
@@ -665,7 +665,7 @@ int nfsd_get_nrthreads(int n, int *nthreads, struct net *net)int i;if (serv) -for (i =0 ; i < serv->sv_nrpools && i < n; i++) +for (i =0 ; i <svc_serv_nrpools (serv) && i < n; i++) nthreads[i] = serv->sv_pools[i].sp_nrthrmax;return 0 ; }
@@ -699,8 +699,8 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net)if (n ==1 )return svc_set_num_threads (nn->nfsd_serv, nn->min_threads, nthreads[0 ]); -if (n > nn->nfsd_serv->sv_nrpools) - n = nn->nfsd_serv->sv_nrpools; +if (n >svc_serv_nrpools (nn->nfsd_serv)) + n =svc_serv_nrpools (nn->nfsd_serv);/* enforce a global maximum number of threads */ tot =0 ;
@@ -731,7 +731,7 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net) }/* Anything undefined in array is considered to be 0 */ -for (i = n; i < nn->nfsd_serv->sv_nrpools; ++i) { +for (i = n; i <svc_serv_nrpools (nn->nfsd_serv); ++i) { err =svc_set_pool_threads (nn->nfsd_serv, &nn->nfsd_serv->sv_pools[i],0 ,0 );
include/linux/sunrpc/svc.h +1 -1
@@ -85,7 +85,6 @@ struct svc_serv {char * sv_name;/* service name */ -unsigned int sv_nrpools;/* number of thread pools */ bool sv_is_pooled;/* is this a pooled service? */ struct svc_pool * sv_pools;/* array of thread pools */ int (*sv_threadfn)(void *data);
@@ -480,6 +479,7 @@ void svc_wake_up(struct svc_serv *);void svc_reserve (struct svc_rqst *rqstp,int space);void svc_pool_wake_idle_thread (struct svc_pool *pool);struct svc_pool *svc_pool_for_cpu (struct svc_serv *serv); +unsigned int svc_serv_nrpools (const struct svc_serv *serv);char *svc_print_addr (struct svc_rqst *,char *,size_t );const char *svc_proc_name (const struct svc_rqst *rqstp); int svc_encode_result_payload(struct svc_rqst *rqstp,
net/sunrpc/svc.c +36 -16
128 lines not on this page · raw message
net/sunrpc/svc_xprt.c +3 -3
@@ -1188,7 +1188,7 @@ static void svc_clean_up_xprts(struct svc_serv *serv, struct net *net)struct svc_xprt *xprt;int i; -for (i =0 ; i < serv->sv_nrpools; i++) { +for (i =0 ; i <svc_serv_nrpools (serv); i++) {struct svc_pool *pool = &serv->sv_pools[i];struct llist_node *q, **t1, *t2;
@@ -1517,7 +1517,7 @@ static void *svc_pool_stats_start(struct seq_file *m, loff_t *pos)return SEQ_START_TOKEN ;if (!si->serv)return NULL ; -return pidx > si->serv->sv_nrpools ?NULL +return pidx >svc_serv_nrpools (si->serv) ?NULL : &si->serv->sv_pools[pidx -1 ]; }
@@ -1535,7 +1535,7 @@ static void *svc_pool_stats_next(struct seq_file *m, void *p, loff_t *pos) pool = &serv->sv_pools[0 ]; }else {unsigned int pidx = (pool - &serv->sv_pools[0 ]); -if (pidx < serv->sv_nrpools-1 ) +if (pidx <svc_serv_nrpools (serv) -1 ) pool = &serv->sv_pools[pidx+1 ];else pool =NULL ;
Signature · 1 line
2.55.0
Re: [PATCH v5 5/5] sunrpc: derive the pool count instead of caching it in sv_nrpools
Quoted 139 lines · Jeff Layton
Now that the pool mode is always pernode, svc_serv.sv_nrpools is redundant with
sv_is_pooled: an unpooled service always has a single pool, and a pooled service has svc_pool_map.npools pools (which is one on a single-node host).sv_nrpoolscannot distinguish an unpooled service from a pooled service that happens to have one pool, so it issv_nrpools, notsv_is_pooled, that carries no unique information.Replace the cached field with a
svc_serv_nrpools()helper that derives the count fromsv_is_pooledand the pool map, and convert all readers to it.svc_pool_mapis file-local tosvc.c, so export the helper for thesvc_xprt.cand nfsd callers.Reading svc_pool_map.npools without
svc_pool_map_mutexis safe: the mutex protects only svc_pool_map.count, and npools is already read locklessly insvc_pool_for_cpu().A pooled service holds a map reference for its whole lifetime, so npools is stable while any reader could observe it. The hot path (
svc_pool_for_cpu()) already dereferencessvc_pool_mapforto_pool, and npools shares that cacheline, so there is no new locking or coherence cost.
__svc_create()keeps using its local npools argument for the sv_pools[] allocation, sincesv_is_pooledis not set untilsvc_create_pooled()has returned from it.Doing this also removes a modulus operation from
svc_pool_for_cpu(), which should make for more efficient RPC queueing.Assisted-by Claude:claude-opus-4-8Suggested-by NeilBrown <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/nfsd/nfsctl.c | 2 +- fs/nfsd/nfssvc.c | 10 ++++----- include/linux/sunrpc/svc.h | 2 +- net/sunrpc/svc.c | 52 ++++++++++++++++++++++++++++++++-------------- net/sunrpc/svc_xprt.c | 6 +++--- 5 files changed, 46 insertions(+), 26 deletions(-)fs/nfsd/nfsctl.c +1
-1@@ -1526,7 +1526,7 @@ int nfsd_nl_rpc_status_get_dumpit(struct sk_buff *skb,rcu_read_lock (); -for (i =0 ; i < nn->nfsd_serv->sv_nrpools; i++) { +for (i =0 ; i <svc_serv_nrpools (nn->nfsd_serv); i++) {struct svc_rqst *rqstp;long thread_skip =0 ;fs/nfsd/nfssvc.c +5
-5@@ -655,7 +655,7 @@ int nfsd_nrpools(struct net *net)if (nn->nfsd_serv ==NULL )return 0 ;else -return nn->nfsd_serv->sv_nrpools; +return svc_serv_nrpools (nn->nfsd_serv); }int nfsd_get_nrthreads (int n,int *nthreads,struct net *net)@@ -665,7 +665,7 @@ int nfsd_get_nrthreads(int n, int *nthreads, struct net *net)int i;if (serv) -for (i =0 ; i < serv->sv_nrpools && i < n; i++) +for (i =0 ; i <svc_serv_nrpools (serv) && i < n; i++) nthreads[i] = serv->sv_pools[i].sp_nrthrmax;return 0 ; }@@ -699,8 +699,8 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net)if (n ==1 )return svc_set_num_threads (nn->nfsd_serv, nn->min_threads, nthreads[0 ]); -if (n > nn->nfsd_serv->sv_nrpools) - n = nn->nfsd_serv->sv_nrpools; +if (n >svc_serv_nrpools (nn->nfsd_serv)) + n =svc_serv_nrpools (nn->nfsd_serv);/* enforce a global maximum number of threads */ tot =0 ;@@ -731,7 +731,7 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net) }/* Anything undefined in array is considered to be 0 */ -for (i = n; i < nn->nfsd_serv->sv_nrpools; ++i) { +for (i = n; i <svc_serv_nrpools (nn->nfsd_serv); ++i) { err =svc_set_pool_threads (nn->nfsd_serv, &nn->nfsd_serv->sv_pools[i],0 ,0 );include/linux/sunrpc/svc.h +1
-1@@ -85,7 +85,6 @@ struct svc_serv {char * sv_name;/* service name */ -unsigned int sv_nrpools;/* number of thread pools */ bool sv_is_pooled;/* is this a pooled service? */ struct svc_pool * sv_pools;/* array of thread pools */ int (*sv_threadfn)(void *data);@@ -480,6 +479,7 @@ void svc_wake_up(struct svc_serv *);void svc_reserve (struct svc_rqst *rqstp,int space);void svc_pool_wake_idle_thread (struct svc_pool *pool);struct svc_pool *svc_pool_for_cpu (struct svc_serv *serv); +unsigned int svc_serv_nrpools (const struct svc_serv *serv);char *svc_print_addr (struct svc_rqst *,char *,size_t );const char *svc_proc_name (const struct svc_rqst *rqstp); int svc_encode_result_payload(struct svc_rqst *rqstp,net/sunrpc/svc.c +8
-1@@ -224,7 +224,7 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)unsigned int node = m->pool_to[pidx];/* -* The caller checks for sv_nrpools > 1, which +* The caller checks for more than one pool, which * implies that we've been initialized. */ WARN_ON_ONCE (m->count ==0 );@@ -234,6 +234,24 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)set_cpus_allowed_ptr (task,cpumask_of_node (node)); } +/** +* svc_serv_nrpools - number of thread pools backing a service +* @serv: An RPC service +* +* Pooled services all share the global svc_pool_map, so their pool count +* is svc_pool_map.npools. Unpooled services have a single pool. Reading +* npools without svc_pool_map_mutex is safe: a pooled service holds a map
net/sunrpc/svc.c svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx) · line 253
Quoted 10 lines
net/sunrpc/svc.c +10
-0+* reference for its whole lifetime, so npools is stable once set. +* +* Return value: +* The number of pools in @serv +*/ +unsigned int svc_serv_nrpools (const struct svc_serv *serv) +{ +return serv->sv_is_pooled ? svc_pool_map.npools :1 ; +} +EXPORT_SYMBOL_GPL (svc_serv_nrpools);
I would make this a static-inline.
Quoted 9 lines
net/sunrpc/svc.c +2
-0+/** * svc_pool_for_cpu - Select pool to run a thread on this cpu * @serv: An RPC service @@ -247,12 +265,15 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)struct svc_pool *svc_pool_for_cpu (struct svc_serv *serv) {struct svc_pool_map *m = &svc_pool_map; +unsigned int nrpools =svc_serv_nrpools (serv);
net/sunrpc/svc.c svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx) · line 276
Quoted 10 lines
net/sunrpc/svc.c +4
-2unsigned int pidx, i; -if (serv->sv_nrpools <=1 ) +if (nrpools <=1 )return serv->sv_pools; - pidx = m->to_pool[cpu_to_node (raw_smp_processor_id ())] % serv->sv_nrpools; + pidx = m->to_pool[cpu_to_node (raw_smp_processor_id ())]; +if (pidx >= nrpools) + pidx =0 ;
The values stored in svc_pool_map.to_pool are all less than svc_pool_map.npools.
So that if() condition cannot be true.
But those two things don't reduce the correctness of the patch.
Thanks for doing this.
NeilBrown
Quoted 126 lines
net/sunrpc/svc.c +12
-13/* * It's possible to have a pool with no threads. Userland can just set @@ -265,7 +286,7 @@ struct svc_pool *svc_pool_for_cpu(struct svc_serv *serv)* populated pool, trading NUMA locality for a guarantee that the * transport is serviced. */ -for (i =0 ; i < serv->sv_nrpools; i++) { +for (i =0 ; i < nrpools; i++) {struct svc_pool *pool = &serv->sv_pools[pidx];/* This is set under the sp_mutex and rarely ever changes. A @@ -274,7 +295,7 @@ struct svc_pool *svc_pool_for_cpu(struct svc_serv *serv)if (data_race (pool->sp_nrthreads))return pool; -if (++pidx >= serv->sv_nrpools) +if (++pidx >= nrpools) pidx =0 ; }@@ -414,15 +435,13 @@ __svc_create(struct svc_program *prog, int nprogs, struct svc_stat *stats,__svc_init_bc (serv); - serv->sv_nrpools = npools; - serv->sv_pools = - kzalloc_objs(struct svc_pool, serv->sv_nrpools); + serv->sv_pools = kzalloc_objs(struct svc_pool, npools);if (!serv->sv_pools) {kfree (serv);return NULL ; } -for (i =0 ; i < serv->sv_nrpools; i++) { +for (i =0 ; i < npools; i++) {struct svc_pool *pool = &serv->sv_pools[i]; dprintk("svc: initialising pool %u for %s\n",@@ -520,7 +539,7 @@ svc_destroy(struct svc_serv **servp)cache_clean_deferred (serv); -for (i =0 ; i < serv->sv_nrpools; i++) { +for (i =0 ; i <svc_serv_nrpools (serv); i++) {struct svc_pool *pool = &serv->sv_pools[i];svc_pool_destroy_counters (pool);@@ -732,7 +751,7 @@ int svc_new_thread(struct svc_serv *serv, struct svc_pool *pool) } rqstp->rq_task = task; -if (serv->sv_nrpools >1 ) +if (svc_serv_nrpools (serv) >1 )svc_pool_map_set_cpumask (task, pool->sp_id);svc_sock_update_bufs (serv);@@ -858,8 +877,9 @@ int svc_set_num_threads(struct svc_serv *serv, unsigned int min_threads, unsigned int nrservs) { - unsigned int base = nrservs / serv->sv_nrpools; -unsigned int remain = nrservs % serv->sv_nrpools; + unsigned int nrpools = svc_serv_nrpools(serv); +unsigned int base = nrservs / nrpools; +unsigned int remain = nrservs % nrpools;int i, err =0 ;/* @@ -870,9 +890,9 @@ svc_set_num_threads(struct svc_serv *serv, unsigned int min_threads,* @nrservs. */ if (base ==0 && nrservs !=0 ) - remain = serv->sv_nrpools; + remain = nrpools; -for (i =0 ; i < serv->sv_nrpools; ++i) { +for (i =0 ; i < nrpools; ++i) {struct svc_pool *pool = &serv->sv_pools[i];int threads = base;@@ -906,7 +926,7 @@ unsigned int svc_serv_maxthreads(const struct svc_serv *serv) {unsigned int i, max =0 ; -for (i =0 ; i < serv->sv_nrpools; i++) +for (i =0 ; i <svc_serv_nrpools (serv); i++) max +=data_race (serv->sv_pools[i].sp_nrthrmax);return max; }net/sunrpc/svc_xprt.c +3
-3@@ -1188,7 +1188,7 @@ static void svc_clean_up_xprts(struct svc_serv *serv, struct net *net)struct svc_xprt *xprt;int i; -for (i =0 ; i < serv->sv_nrpools; i++) { +for (i =0 ; i <svc_serv_nrpools (serv); i++) {struct svc_pool *pool = &serv->sv_pools[i];struct llist_node *q, **t1, *t2;@@ -1517,7 +1517,7 @@ static void *svc_pool_stats_start(struct seq_file *m, loff_t *pos)return SEQ_START_TOKEN ;if (!si->serv)return NULL ; -return pidx > si->serv->sv_nrpools ?NULL +return pidx >svc_serv_nrpools (si->serv) ?NULL : &si->serv->sv_pools[pidx -1 ]; }@@ -1535,7 +1535,7 @@ static void *svc_pool_stats_next(struct seq_file *m, void *p, loff_t *pos) pool = &serv->sv_pools[0 ]; }else {unsigned int pidx = (pool - &serv->sv_pools[0 ]); -if (pidx < serv->sv_nrpools-1 ) +if (pidx <svc_serv_nrpools (serv) -1 ) pool = &serv->sv_pools[pidx+1 ];else pool =NULL ;Signature · 2 lines
-- 2.55.0
Jeff Layton
maintainerRe: [PATCH v5 5/5] sunrpc: derive the pool count instead of caching it in sv_nrpools
Quoted 144 lines · NeilBrown
Quoted 143 lines · Jeff Layton
Now that the pool mode is always pernode, svc_serv.sv_nrpools is redundant with
sv_is_pooled: an unpooled service always has a single pool, and a pooled service has svc_pool_map.npools pools (which is one on a single-node host).sv_nrpoolscannot distinguish an unpooled service from a pooled service that happens to have one pool, so it issv_nrpools, notsv_is_pooled, that carries no unique information.Replace the cached field with a
svc_serv_nrpools()helper that derives the count fromsv_is_pooledand the pool map, and convert all readers to it.svc_pool_mapis file-local tosvc.c, so export the helper for thesvc_xprt.cand nfsd callers.Reading svc_pool_map.npools without
svc_pool_map_mutexis safe: the mutex protects only svc_pool_map.count, and npools is already read locklessly insvc_pool_for_cpu().A pooled service holds a map reference for its whole lifetime, so npools is stable while any reader could observe it. The hot path (
svc_pool_for_cpu()) already dereferencessvc_pool_mapforto_pool, and npools shares that cacheline, so there is no new locking or coherence cost.
__svc_create()keeps using its local npools argument for the sv_pools[] allocation, sincesv_is_pooledis not set untilsvc_create_pooled()has returned from it.Doing this also removes a modulus operation from
svc_pool_for_cpu(), which should make for more efficient RPC queueing.Assisted-by Claude:claude-opus-4-8Suggested-by NeilBrown <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/nfsd/nfsctl.c | 2 +- fs/nfsd/nfssvc.c | 10 ++++----- include/linux/sunrpc/svc.h | 2 +- net/sunrpc/svc.c | 52 ++++++++++++++++++++++++++++++++-------------- net/sunrpc/svc_xprt.c | 6 +++--- 5 files changed, 46 insertions(+), 26 deletions(-)fs/nfsd/nfsctl.c +1
-1@@ -1526,7 +1526,7 @@ int nfsd_nl_rpc_status_get_dumpit(struct sk_buff *skb,rcu_read_lock (); -for (i =0 ; i < nn->nfsd_serv->sv_nrpools; i++) { +for (i =0 ; i <svc_serv_nrpools (nn->nfsd_serv); i++) {struct svc_rqst *rqstp;long thread_skip =0 ;fs/nfsd/nfssvc.c +5
-5@@ -655,7 +655,7 @@ int nfsd_nrpools(struct net *net)if (nn->nfsd_serv ==NULL )return 0 ;else -return nn->nfsd_serv->sv_nrpools; +return svc_serv_nrpools (nn->nfsd_serv); }int nfsd_get_nrthreads (int n,int *nthreads,struct net *net)@@ -665,7 +665,7 @@ int nfsd_get_nrthreads(int n, int *nthreads, struct net *net)int i;if (serv) -for (i =0 ; i < serv->sv_nrpools && i < n; i++) +for (i =0 ; i <svc_serv_nrpools (serv) && i < n; i++) nthreads[i] = serv->sv_pools[i].sp_nrthrmax;return 0 ; }@@ -699,8 +699,8 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net)if (n ==1 )return svc_set_num_threads (nn->nfsd_serv, nn->min_threads, nthreads[0 ]); -if (n > nn->nfsd_serv->sv_nrpools) - n = nn->nfsd_serv->sv_nrpools; +if (n >svc_serv_nrpools (nn->nfsd_serv)) + n =svc_serv_nrpools (nn->nfsd_serv);/* enforce a global maximum number of threads */ tot =0 ;@@ -731,7 +731,7 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net) }/* Anything undefined in array is considered to be 0 */ -for (i = n; i < nn->nfsd_serv->sv_nrpools; ++i) { +for (i = n; i <svc_serv_nrpools (nn->nfsd_serv); ++i) { err =svc_set_pool_threads (nn->nfsd_serv, &nn->nfsd_serv->sv_pools[i],0 ,0 );include/linux/sunrpc/svc.h +1
-1@@ -85,7 +85,6 @@ struct svc_serv {char * sv_name;/* service name */ -unsigned int sv_nrpools;/* number of thread pools */ bool sv_is_pooled;/* is this a pooled service? */ struct svc_pool * sv_pools;/* array of thread pools */ int (*sv_threadfn)(void *data);@@ -480,6 +479,7 @@ void svc_wake_up(struct svc_serv *);void svc_reserve (struct svc_rqst *rqstp,int space);void svc_pool_wake_idle_thread (struct svc_pool *pool);struct svc_pool *svc_pool_for_cpu (struct svc_serv *serv); +unsigned int svc_serv_nrpools (const struct svc_serv *serv);char *svc_print_addr (struct svc_rqst *,char *,size_t );const char *svc_proc_name (const struct svc_rqst *rqstp); int svc_encode_result_payload(struct svc_rqst *rqstp,net/sunrpc/svc.c +12
-1@@ -224,7 +224,7 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)unsigned int node = m->pool_to[pidx];/* -* The caller checks for sv_nrpools > 1, which +* The caller checks for more than one pool, which * implies that we've been initialized. */ WARN_ON_ONCE (m->count ==0 );@@ -234,6 +234,24 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)set_cpus_allowed_ptr (task,cpumask_of_node (node)); } +/** +* svc_serv_nrpools - number of thread pools backing a service +* @serv: An RPC service +* +* Pooled services all share the global svc_pool_map, so their pool count +* is svc_pool_map.npools. Unpooled services have a single pool. Reading +* npools without svc_pool_map_mutex is safe: a pooled service holds a map +* reference for its whole lifetime, so npools is stable once set. +* +* Return value: +* The number of pools in @serv
Quoted 9 lines
net/sunrpc/svc.c svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx) · line 253
Quoted 6 lines
net/sunrpc/svc.c +6
-0+*/ +unsigned int svc_serv_nrpools (const struct svc_serv *serv) +{ +return serv->sv_is_pooled ? svc_pool_map.npools :1 ; +} +EXPORT_SYMBOL_GPL (svc_serv_nrpools);I would make this a static-inline.
That would mean that we would have to export svc_pool_map, which is currently private to svc.c.
Quoted 24 lines
Quoted 9 lines
net/sunrpc/svc.c +2
-0+/** * svc_pool_for_cpu - Select pool to run a thread on this cpu * @serv: An RPC service @@ -247,12 +265,15 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)struct svc_pool *svc_pool_for_cpu (struct svc_serv *serv) {struct svc_pool_map *m = &svc_pool_map; +unsigned int nrpools =svc_serv_nrpools (serv);net/sunrpc/svc.c svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx) · line 276
Quoted 10 lines
net/sunrpc/svc.c +4
-2unsigned int pidx, i; -if (serv->sv_nrpools <=1 ) +if (nrpools <=1 )return serv->sv_pools; - pidx = m->to_pool[cpu_to_node (raw_smp_processor_id ())] % serv->sv_nrpools; + pidx = m->to_pool[cpu_to_node (raw_smp_processor_id ())]; +if (pidx >= nrpools) + pidx =0 ;The values stored in svc_pool_map.to_pool are all less than svc_pool_map.npools.
So thatif()condition cannot be true.
Quoted 7 lines
But those two things don't reduce the correctness of the patch.
Reviewed-by NeilBrown <[email protected]>Thanks for doing this.
NeilBrown
Ahh good point. I guess we can remove that if statement. I can send Chuck a follow-on patch. Thanks for the R-b!
Quoted 127 lines
Quoted 127 lines
net/sunrpc/svc.c +12
-13/* * It's possible to have a pool with no threads. Userland can just set @@ -265,7 +286,7 @@ struct svc_pool *svc_pool_for_cpu(struct svc_serv *serv)* populated pool, trading NUMA locality for a guarantee that the * transport is serviced. */ -for (i =0 ; i < serv->sv_nrpools; i++) { +for (i =0 ; i < nrpools; i++) {struct svc_pool *pool = &serv->sv_pools[pidx];/* This is set under the sp_mutex and rarely ever changes. A @@ -274,7 +295,7 @@ struct svc_pool *svc_pool_for_cpu(struct svc_serv *serv)if (data_race (pool->sp_nrthreads))return pool; -if (++pidx >= serv->sv_nrpools) +if (++pidx >= nrpools) pidx =0 ; }@@ -414,15 +435,13 @@ __svc_create(struct svc_program *prog, int nprogs, struct svc_stat *stats,__svc_init_bc (serv); - serv->sv_nrpools = npools; - serv->sv_pools = - kzalloc_objs(struct svc_pool, serv->sv_nrpools); + serv->sv_pools = kzalloc_objs(struct svc_pool, npools);if (!serv->sv_pools) {kfree (serv);return NULL ; } -for (i =0 ; i < serv->sv_nrpools; i++) { +for (i =0 ; i < npools; i++) {struct svc_pool *pool = &serv->sv_pools[i]; dprintk("svc: initialising pool %u for %s\n",@@ -520,7 +539,7 @@ svc_destroy(struct svc_serv **servp)cache_clean_deferred (serv); -for (i =0 ; i < serv->sv_nrpools; i++) { +for (i =0 ; i <svc_serv_nrpools (serv); i++) {struct svc_pool *pool = &serv->sv_pools[i];svc_pool_destroy_counters (pool);@@ -732,7 +751,7 @@ int svc_new_thread(struct svc_serv *serv, struct svc_pool *pool) } rqstp->rq_task = task; -if (serv->sv_nrpools >1 ) +if (svc_serv_nrpools (serv) >1 )svc_pool_map_set_cpumask (task, pool->sp_id);svc_sock_update_bufs (serv);@@ -858,8 +877,9 @@ int svc_set_num_threads(struct svc_serv *serv, unsigned int min_threads, unsigned int nrservs) { - unsigned int base = nrservs / serv->sv_nrpools; -unsigned int remain = nrservs % serv->sv_nrpools; + unsigned int nrpools = svc_serv_nrpools(serv); +unsigned int base = nrservs / nrpools; +unsigned int remain = nrservs % nrpools;int i, err =0 ;/* @@ -870,9 +890,9 @@ svc_set_num_threads(struct svc_serv *serv, unsigned int min_threads,* @nrservs. */ if (base ==0 && nrservs !=0 ) - remain = serv->sv_nrpools; + remain = nrpools; -for (i =0 ; i < serv->sv_nrpools; ++i) { +for (i =0 ; i < nrpools; ++i) {struct svc_pool *pool = &serv->sv_pools[i];int threads = base;@@ -906,7 +926,7 @@ unsigned int svc_serv_maxthreads(const struct svc_serv *serv) {unsigned int i, max =0 ; -for (i =0 ; i < serv->sv_nrpools; i++) +for (i =0 ; i <svc_serv_nrpools (serv); i++) max +=data_race (serv->sv_pools[i].sp_nrthrmax);return max; }net/sunrpc/svc_xprt.c +3
-3@@ -1188,7 +1188,7 @@ static void svc_clean_up_xprts(struct svc_serv *serv, struct net *net)struct svc_xprt *xprt;int i; -for (i =0 ; i < serv->sv_nrpools; i++) { +for (i =0 ; i <svc_serv_nrpools (serv); i++) {struct svc_pool *pool = &serv->sv_pools[i];struct llist_node *q, **t1, *t2;@@ -1517,7 +1517,7 @@ static void *svc_pool_stats_start(struct seq_file *m, loff_t *pos)return SEQ_START_TOKEN ;if (!si->serv)return NULL ; -return pidx > si->serv->sv_nrpools ?NULL +return pidx >svc_serv_nrpools (si->serv) ?NULL : &si->serv->sv_pools[pidx -1 ]; }@@ -1535,7 +1535,7 @@ static void *svc_pool_stats_next(struct seq_file *m, void *p, loff_t *pos) pool = &serv->sv_pools[0 ]; }else {unsigned int pidx = (pool - &serv->sv_pools[0 ]); -if (pidx < serv->sv_nrpools-1 ) +if (pidx <svc_serv_nrpools (serv) -1 ) pool = &serv->sv_pools[pidx+1 ];else pool =NULL ;Signature · 2 lines
-- 2.55.0
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH v5 5/5] sunrpc: derive the pool count instead of caching it in sv_nrpools
Quoted 155 lines · Jeff Layton
Quoted 144 lines · NeilBrown
Quoted 143 lines · Jeff Layton
Now that the pool mode is always pernode, svc_serv.sv_nrpools is redundant with
sv_is_pooled: an unpooled service always has a single pool, and a pooled service has svc_pool_map.npools pools (which is one on a single-node host).sv_nrpoolscannot distinguish an unpooled service from a pooled service that happens to have one pool, so it issv_nrpools, notsv_is_pooled, that carries no unique information.Replace the cached field with a
svc_serv_nrpools()helper that derives the count fromsv_is_pooledand the pool map, and convert all readers to it.svc_pool_mapis file-local tosvc.c, so export the helper for thesvc_xprt.cand nfsd callers.Reading svc_pool_map.npools without
svc_pool_map_mutexis safe: the mutex protects only svc_pool_map.count, and npools is already read locklessly insvc_pool_for_cpu().A pooled service holds a map reference for its whole lifetime, so npools is stable while any reader could observe it. The hot path (
svc_pool_for_cpu()) already dereferencessvc_pool_mapforto_pool, and npools shares that cacheline, so there is no new locking or coherence cost.
__svc_create()keeps using its local npools argument for the sv_pools[] allocation, sincesv_is_pooledis not set untilsvc_create_pooled()has returned from it.Doing this also removes a modulus operation from
svc_pool_for_cpu(), which should make for more efficient RPC queueing.Assisted-by Claude:claude-opus-4-8Suggested-by NeilBrown <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/nfsd/nfsctl.c | 2 +- fs/nfsd/nfssvc.c | 10 ++++----- include/linux/sunrpc/svc.h | 2 +- net/sunrpc/svc.c | 52 ++++++++++++++++++++++++++++++++-------------- net/sunrpc/svc_xprt.c | 6 +++--- 5 files changed, 46 insertions(+), 26 deletions(-)fs/nfsd/nfsctl.c +1
-1@@ -1526,7 +1526,7 @@ int nfsd_nl_rpc_status_get_dumpit(struct sk_buff *skb,rcu_read_lock (); -for (i =0 ; i < nn->nfsd_serv->sv_nrpools; i++) { +for (i =0 ; i <svc_serv_nrpools (nn->nfsd_serv); i++) {struct svc_rqst *rqstp;long thread_skip =0 ;fs/nfsd/nfssvc.c +5
-5@@ -655,7 +655,7 @@ int nfsd_nrpools(struct net *net)if (nn->nfsd_serv ==NULL )return 0 ;else -return nn->nfsd_serv->sv_nrpools; +return svc_serv_nrpools (nn->nfsd_serv); }int nfsd_get_nrthreads (int n,int *nthreads,struct net *net)@@ -665,7 +665,7 @@ int nfsd_get_nrthreads(int n, int *nthreads, struct net *net)int i;if (serv) -for (i =0 ; i < serv->sv_nrpools && i < n; i++) +for (i =0 ; i <svc_serv_nrpools (serv) && i < n; i++) nthreads[i] = serv->sv_pools[i].sp_nrthrmax;return 0 ; }@@ -699,8 +699,8 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net)if (n ==1 )return svc_set_num_threads (nn->nfsd_serv, nn->min_threads, nthreads[0 ]); -if (n > nn->nfsd_serv->sv_nrpools) - n = nn->nfsd_serv->sv_nrpools; +if (n >svc_serv_nrpools (nn->nfsd_serv)) + n =svc_serv_nrpools (nn->nfsd_serv);/* enforce a global maximum number of threads */ tot =0 ;@@ -731,7 +731,7 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net) }/* Anything undefined in array is considered to be 0 */ -for (i = n; i < nn->nfsd_serv->sv_nrpools; ++i) { +for (i = n; i <svc_serv_nrpools (nn->nfsd_serv); ++i) { err =svc_set_pool_threads (nn->nfsd_serv, &nn->nfsd_serv->sv_pools[i],0 ,0 );include/linux/sunrpc/svc.h +1
-1@@ -85,7 +85,6 @@ struct svc_serv {char * sv_name;/* service name */ -unsigned int sv_nrpools;/* number of thread pools */ bool sv_is_pooled;/* is this a pooled service? */ struct svc_pool * sv_pools;/* array of thread pools */ int (*sv_threadfn)(void *data);@@ -480,6 +479,7 @@ void svc_wake_up(struct svc_serv *);void svc_reserve (struct svc_rqst *rqstp,int space);void svc_pool_wake_idle_thread (struct svc_pool *pool);struct svc_pool *svc_pool_for_cpu (struct svc_serv *serv); +unsigned int svc_serv_nrpools (const struct svc_serv *serv);char *svc_print_addr (struct svc_rqst *,char *,size_t );const char *svc_proc_name (const struct svc_rqst *rqstp); int svc_encode_result_payload(struct svc_rqst *rqstp,net/sunrpc/svc.c +12
-1@@ -224,7 +224,7 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)unsigned int node = m->pool_to[pidx];/* -* The caller checks for sv_nrpools > 1, which +* The caller checks for more than one pool, which * implies that we've been initialized. */ WARN_ON_ONCE (m->count ==0 );@@ -234,6 +234,24 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)set_cpus_allowed_ptr (task,cpumask_of_node (node)); } +/** +* svc_serv_nrpools - number of thread pools backing a service +* @serv: An RPC service +* +* Pooled services all share the global svc_pool_map, so their pool count +* is svc_pool_map.npools. Unpooled services have a single pool. Reading +* npools without svc_pool_map_mutex is safe: a pooled service holds a map +* reference for its whole lifetime, so npools is stable once set. +* +* Return value: +* The number of pools in @serv Quoted 9 lines
net/sunrpc/svc.c svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx) · line 253
Quoted 6 lines
net/sunrpc/svc.c +6
-0+*/ +unsigned int svc_serv_nrpools (const struct svc_serv *serv) +{ +return serv->sv_is_pooled ? svc_pool_map.npools :1 ; +} +EXPORT_SYMBOL_GPL (svc_serv_nrpools);I would make this a static-inline.
Quoted 2 lines
That would mean that we would have to export
svc_pool_map, which is currently private tosvc.c.
Why is exporting svc_pool_map more problematic than exporting svc_serv_nrpools? I think it would be good for at least the code in svc_pool_for_cpu() to inline the function. Maybe it already does? Or maybe marking it "inline" but still exporting it would work.
Thanks,
NeilBrown
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
net/sunrpc/svc.c +6
-2+/** * svc_pool_for_cpu - Select pool to run a thread on this cpu * @serv: An RPC service @@ -247,12 +265,15 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)struct svc_pool *svc_pool_for_cpu (struct svc_serv *serv) {struct svc_pool_map *m = &svc_pool_map; +unsigned int nrpools =svc_serv_nrpools (serv);unsigned int pidx, i; -if (serv->sv_nrpools <=1 ) +if (nrpools <=1 )return serv->sv_pools; - pidx = m->to_pool[cpu_to_node (raw_smp_processor_id ())] % serv->sv_nrpools; + pidx = m->to_pool[cpu_to_node (raw_smp_processor_id ())]; +if (pidx >= nrpools) + pidx =0 ;
Jeff Layton
maintainerRe: [PATCH v5 5/5] sunrpc: derive the pool count instead of caching it in sv_nrpools
Quoted 159 lines · NeilBrown
Quoted 155 lines · Jeff Layton
Quoted 144 lines · NeilBrown
Quoted 143 lines · Jeff Layton
Now that the pool mode is always pernode, svc_serv.sv_nrpools is redundant with
sv_is_pooled: an unpooled service always has a single pool, and a pooled service has svc_pool_map.npools pools (which is one on a single-node host).sv_nrpoolscannot distinguish an unpooled service from a pooled service that happens to have one pool, so it issv_nrpools, notsv_is_pooled, that carries no unique information.Replace the cached field with a
svc_serv_nrpools()helper that derives the count fromsv_is_pooledand the pool map, and convert all readers to it.svc_pool_mapis file-local tosvc.c, so export the helper for thesvc_xprt.cand nfsd callers.Reading svc_pool_map.npools without
svc_pool_map_mutexis safe: the mutex protects only svc_pool_map.count, and npools is already read locklessly insvc_pool_for_cpu().A pooled service holds a map reference for its whole lifetime, so npools is stable while any reader could observe it. The hot path (
svc_pool_for_cpu()) already dereferencessvc_pool_mapforto_pool, and npools shares that cacheline, so there is no new locking or coherence cost.
__svc_create()keeps using its local npools argument for the sv_pools[] allocation, sincesv_is_pooledis not set untilsvc_create_pooled()has returned from it.Doing this also removes a modulus operation from
svc_pool_for_cpu(), which should make for more efficient RPC queueing.Assisted-by Claude:claude-opus-4-8Suggested-by NeilBrown <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/nfsd/nfsctl.c | 2 +- fs/nfsd/nfssvc.c | 10 ++++----- include/linux/sunrpc/svc.h | 2 +- net/sunrpc/svc.c | 52 ++++++++++++++++++++++++++++++++-------------- net/sunrpc/svc_xprt.c | 6 +++--- 5 files changed, 46 insertions(+), 26 deletions(-)fs/nfsd/nfsctl.c +1
-1@@ -1526,7 +1526,7 @@ int nfsd_nl_rpc_status_get_dumpit(struct sk_buff *skb,rcu_read_lock (); -for (i =0 ; i < nn->nfsd_serv->sv_nrpools; i++) { +for (i =0 ; i <svc_serv_nrpools (nn->nfsd_serv); i++) {struct svc_rqst *rqstp;long thread_skip =0 ;fs/nfsd/nfssvc.c +5
-5@@ -655,7 +655,7 @@ int nfsd_nrpools(struct net *net)if (nn->nfsd_serv ==NULL )return 0 ;else -return nn->nfsd_serv->sv_nrpools; +return svc_serv_nrpools (nn->nfsd_serv); }int nfsd_get_nrthreads (int n,int *nthreads,struct net *net)@@ -665,7 +665,7 @@ int nfsd_get_nrthreads(int n, int *nthreads, struct net *net)int i;if (serv) -for (i =0 ; i < serv->sv_nrpools && i < n; i++) +for (i =0 ; i <svc_serv_nrpools (serv) && i < n; i++) nthreads[i] = serv->sv_pools[i].sp_nrthrmax;return 0 ; }@@ -699,8 +699,8 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net)if (n ==1 )return svc_set_num_threads (nn->nfsd_serv, nn->min_threads, nthreads[0 ]); -if (n > nn->nfsd_serv->sv_nrpools) - n = nn->nfsd_serv->sv_nrpools; +if (n >svc_serv_nrpools (nn->nfsd_serv)) + n =svc_serv_nrpools (nn->nfsd_serv);/* enforce a global maximum number of threads */ tot =0 ;@@ -731,7 +731,7 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net) }/* Anything undefined in array is considered to be 0 */ -for (i = n; i < nn->nfsd_serv->sv_nrpools; ++i) { +for (i = n; i <svc_serv_nrpools (nn->nfsd_serv); ++i) { err =svc_set_pool_threads (nn->nfsd_serv, &nn->nfsd_serv->sv_pools[i],0 ,0 );include/linux/sunrpc/svc.h +1
-1@@ -85,7 +85,6 @@ struct svc_serv {char * sv_name;/* service name */ -unsigned int sv_nrpools;/* number of thread pools */ bool sv_is_pooled;/* is this a pooled service? */ struct svc_pool * sv_pools;/* array of thread pools */ int (*sv_threadfn)(void *data);@@ -480,6 +479,7 @@ void svc_wake_up(struct svc_serv *);void svc_reserve (struct svc_rqst *rqstp,int space);void svc_pool_wake_idle_thread (struct svc_pool *pool);struct svc_pool *svc_pool_for_cpu (struct svc_serv *serv); +unsigned int svc_serv_nrpools (const struct svc_serv *serv);char *svc_print_addr (struct svc_rqst *,char *,size_t );const char *svc_proc_name (const struct svc_rqst *rqstp); int svc_encode_result_payload(struct svc_rqst *rqstp,net/sunrpc/svc.c +12
-1@@ -224,7 +224,7 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)unsigned int node = m->pool_to[pidx];/* -* The caller checks for sv_nrpools > 1, which +* The caller checks for more than one pool, which * implies that we've been initialized. */ WARN_ON_ONCE (m->count ==0 );@@ -234,6 +234,24 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)set_cpus_allowed_ptr (task,cpumask_of_node (node)); } +/** +* svc_serv_nrpools - number of thread pools backing a service +* @serv: An RPC service +* +* Pooled services all share the global svc_pool_map, so their pool count +* is svc_pool_map.npools. Unpooled services have a single pool. Reading +* npools without svc_pool_map_mutex is safe: a pooled service holds a map +* reference for its whole lifetime, so npools is stable once set. +* +* Return value: +* The number of pools in @serv Quoted 9 lines
net/sunrpc/svc.c svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx) · line 253
Quoted 6 lines
net/sunrpc/svc.c +6
-0+*/ +unsigned int svc_serv_nrpools (const struct svc_serv *serv) +{ +return serv->sv_is_pooled ? svc_pool_map.npools :1 ; +} +EXPORT_SYMBOL_GPL (svc_serv_nrpools);I would make this a static-inline.
Quoted 2 lines
That would mean that we would have to export
svc_pool_map, which is currently private tosvc.c.
Quoted 8 lines
Why is exporting
svc_pool_mapmore problematic than exportingsvc_serv_nrpools? I think it would be good for at least the code insvc_pool_for_cpu()to inline the function. Maybe it already does? Or maybe marking it "inline" but still exporting it would work.Thanks,
NeilBrown
Doing what you suggest would increase the interface "surface" between sunrpc.ko and nfsd.ko.
Currently struct svc_pool_map is only defined in net/sunrpc/svc.c, so we'd not only need to export the symbol, but also we'd have to make that definition public.
Why expose so many internal details to other modules when all we need is this one accessor? I think keeping this interface small is preferable.
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH v5 5/5] sunrpc: derive the pool count instead of caching it in sv_nrpools
Quoted 172 lines · Jeff Layton
Quoted 159 lines · NeilBrown
Quoted 155 lines · Jeff Layton
Quoted 144 lines · NeilBrown
Quoted 143 lines · Jeff Layton
Now that the pool mode is always pernode, svc_serv.sv_nrpools is redundant with
sv_is_pooled: an unpooled service always has a single pool, and a pooled service has svc_pool_map.npools pools (which is one on a single-node host).sv_nrpoolscannot distinguish an unpooled service from a pooled service that happens to have one pool, so it issv_nrpools, notsv_is_pooled, that carries no unique information.Replace the cached field with a
svc_serv_nrpools()helper that derives the count fromsv_is_pooledand the pool map, and convert all readers to it.svc_pool_mapis file-local tosvc.c, so export the helper for thesvc_xprt.cand nfsd callers.Reading svc_pool_map.npools without
svc_pool_map_mutexis safe: the mutex protects only svc_pool_map.count, and npools is already read locklessly insvc_pool_for_cpu().A pooled service holds a map reference for its whole lifetime, so npools is stable while any reader could observe it. The hot path (
svc_pool_for_cpu()) already dereferencessvc_pool_mapforto_pool, and npools shares that cacheline, so there is no new locking or coherence cost.
__svc_create()keeps using its local npools argument for the sv_pools[] allocation, sincesv_is_pooledis not set untilsvc_create_pooled()has returned from it.Doing this also removes a modulus operation from
svc_pool_for_cpu(), which should make for more efficient RPC queueing.Assisted-by Claude:claude-opus-4-8Suggested-by NeilBrown <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/nfsd/nfsctl.c | 2 +- fs/nfsd/nfssvc.c | 10 ++++----- include/linux/sunrpc/svc.h | 2 +- net/sunrpc/svc.c | 52 ++++++++++++++++++++++++++++++++-------------- net/sunrpc/svc_xprt.c | 6 +++--- 5 files changed, 46 insertions(+), 26 deletions(-)fs/nfsd/nfsctl.c +1
-1@@ -1526,7 +1526,7 @@ int nfsd_nl_rpc_status_get_dumpit(struct sk_buff *skb,rcu_read_lock (); -for (i =0 ; i < nn->nfsd_serv->sv_nrpools; i++) { +for (i =0 ; i <svc_serv_nrpools (nn->nfsd_serv); i++) {struct svc_rqst *rqstp;long thread_skip =0 ;fs/nfsd/nfssvc.c +5
-5@@ -655,7 +655,7 @@ int nfsd_nrpools(struct net *net)if (nn->nfsd_serv ==NULL )return 0 ;else -return nn->nfsd_serv->sv_nrpools; +return svc_serv_nrpools (nn->nfsd_serv); }int nfsd_get_nrthreads (int n,int *nthreads,struct net *net)@@ -665,7 +665,7 @@ int nfsd_get_nrthreads(int n, int *nthreads, struct net *net)int i;if (serv) -for (i =0 ; i < serv->sv_nrpools && i < n; i++) +for (i =0 ; i <svc_serv_nrpools (serv) && i < n; i++) nthreads[i] = serv->sv_pools[i].sp_nrthrmax;return 0 ; }@@ -699,8 +699,8 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net)if (n ==1 )return svc_set_num_threads (nn->nfsd_serv, nn->min_threads, nthreads[0 ]); -if (n > nn->nfsd_serv->sv_nrpools) - n = nn->nfsd_serv->sv_nrpools; +if (n >svc_serv_nrpools (nn->nfsd_serv)) + n =svc_serv_nrpools (nn->nfsd_serv);/* enforce a global maximum number of threads */ tot =0 ;@@ -731,7 +731,7 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net) }/* Anything undefined in array is considered to be 0 */ -for (i = n; i < nn->nfsd_serv->sv_nrpools; ++i) { +for (i = n; i <svc_serv_nrpools (nn->nfsd_serv); ++i) { err =svc_set_pool_threads (nn->nfsd_serv, &nn->nfsd_serv->sv_pools[i],0 ,0 );include/linux/sunrpc/svc.h +1
-1@@ -85,7 +85,6 @@ struct svc_serv {char * sv_name;/* service name */ -unsigned int sv_nrpools;/* number of thread pools */ bool sv_is_pooled;/* is this a pooled service? */ struct svc_pool * sv_pools;/* array of thread pools */ int (*sv_threadfn)(void *data);@@ -480,6 +479,7 @@ void svc_wake_up(struct svc_serv *);void svc_reserve (struct svc_rqst *rqstp,int space);void svc_pool_wake_idle_thread (struct svc_pool *pool);struct svc_pool *svc_pool_for_cpu (struct svc_serv *serv); +unsigned int svc_serv_nrpools (const struct svc_serv *serv);char *svc_print_addr (struct svc_rqst *,char *,size_t );const char *svc_proc_name (const struct svc_rqst *rqstp); int svc_encode_result_payload(struct svc_rqst *rqstp,net/sunrpc/svc.c +12
-1@@ -224,7 +224,7 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)unsigned int node = m->pool_to[pidx];/* -* The caller checks for sv_nrpools > 1, which +* The caller checks for more than one pool, which * implies that we've been initialized. */ WARN_ON_ONCE (m->count ==0 );@@ -234,6 +234,24 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)set_cpus_allowed_ptr (task,cpumask_of_node (node)); } +/** +* svc_serv_nrpools - number of thread pools backing a service +* @serv: An RPC service +* +* Pooled services all share the global svc_pool_map, so their pool count +* is svc_pool_map.npools. Unpooled services have a single pool. Reading +* npools without svc_pool_map_mutex is safe: a pooled service holds a map +* reference for its whole lifetime, so npools is stable once set. +* +* Return value: +* The number of pools in @serv Quoted 9 lines
net/sunrpc/svc.c svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx) · line 253
Quoted 6 lines
net/sunrpc/svc.c +6
-0+*/ +unsigned int svc_serv_nrpools (const struct svc_serv *serv) +{ +return serv->sv_is_pooled ? svc_pool_map.npools :1 ; +} +EXPORT_SYMBOL_GPL (svc_serv_nrpools);I would make this a static-inline.
Quoted 2 lines
That would mean that we would have to export
svc_pool_map, which is currently private tosvc.c.Quoted 8 lines
Why is exporting
svc_pool_mapmore problematic than exportingsvc_serv_nrpools? I think it would be good for at least the code insvc_pool_for_cpu()to inline the function. Maybe it already does? Or maybe marking it "inline" but still exporting it would work.Thanks,
NeilBrownDoing what you suggest would increase the interface "surface" between sunrpc.ko and nfsd.ko.
Quoted 7 lines
Currently struct
svc_pool_mapis only defined innet/sunrpc/svc.c, so we'd not only need to export the symbol, but also we'd have to make that definition public.Why expose so many internal details to other modules when all we need is this one accessor? I think keeping this interface small is preferable.
In general, yes. But it is not without cost. Sometimes the cost matters.
Interface size has an abstract value. Code size can have concrete value. Comparing them is subjective I guess.
I have no concrete evidence that there is a problem, so I'll stop objecting.
Thanks,
NeilBrown
Jeff Layton
maintainerRe: [PATCH v5 5/5] sunrpc: derive the pool count instead of caching it in sv_nrpools
Quoted 181 lines · NeilBrown
Quoted 172 lines · Jeff Layton
Quoted 159 lines · NeilBrown
Quoted 155 lines · Jeff Layton
Quoted 144 lines · NeilBrown
Quoted 143 lines · Jeff Layton
Now that the pool mode is always pernode, svc_serv.sv_nrpools is redundant with
sv_is_pooled: an unpooled service always has a single pool, and a pooled service has svc_pool_map.npools pools (which is one on a single-node host).sv_nrpoolscannot distinguish an unpooled service from a pooled service that happens to have one pool, so it issv_nrpools, notsv_is_pooled, that carries no unique information.Replace the cached field with a
svc_serv_nrpools()helper that derives the count fromsv_is_pooledand the pool map, and convert all readers to it.svc_pool_mapis file-local tosvc.c, so export the helper for thesvc_xprt.cand nfsd callers.Reading svc_pool_map.npools without
svc_pool_map_mutexis safe: the mutex protects only svc_pool_map.count, and npools is already read locklessly insvc_pool_for_cpu().A pooled service holds a map reference for its whole lifetime, so npools is stable while any reader could observe it. The hot path (
svc_pool_for_cpu()) already dereferencessvc_pool_mapforto_pool, and npools shares that cacheline, so there is no new locking or coherence cost.
__svc_create()keeps using its local npools argument for the sv_pools[] allocation, sincesv_is_pooledis not set untilsvc_create_pooled()has returned from it.Doing this also removes a modulus operation from
svc_pool_for_cpu(), which should make for more efficient RPC queueing.Assisted-by Claude:claude-opus-4-8Suggested-by NeilBrown <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/nfsd/nfsctl.c | 2 +- fs/nfsd/nfssvc.c | 10 ++++----- include/linux/sunrpc/svc.h | 2 +- net/sunrpc/svc.c | 52 ++++++++++++++++++++++++++++++++-------------- net/sunrpc/svc_xprt.c | 6 +++--- 5 files changed, 46 insertions(+), 26 deletions(-)fs/nfsd/nfsctl.c +1
-1@@ -1526,7 +1526,7 @@ int nfsd_nl_rpc_status_get_dumpit(struct sk_buff *skb,rcu_read_lock (); -for (i =0 ; i < nn->nfsd_serv->sv_nrpools; i++) { +for (i =0 ; i <svc_serv_nrpools (nn->nfsd_serv); i++) {struct svc_rqst *rqstp;long thread_skip =0 ;fs/nfsd/nfssvc.c +5
-5@@ -655,7 +655,7 @@ int nfsd_nrpools(struct net *net)if (nn->nfsd_serv ==NULL )return 0 ;else -return nn->nfsd_serv->sv_nrpools; +return svc_serv_nrpools (nn->nfsd_serv); }int nfsd_get_nrthreads (int n,int *nthreads,struct net *net)@@ -665,7 +665,7 @@ int nfsd_get_nrthreads(int n, int *nthreads, struct net *net)int i;if (serv) -for (i =0 ; i < serv->sv_nrpools && i < n; i++) +for (i =0 ; i <svc_serv_nrpools (serv) && i < n; i++) nthreads[i] = serv->sv_pools[i].sp_nrthrmax;return 0 ; }@@ -699,8 +699,8 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net)if (n ==1 )return svc_set_num_threads (nn->nfsd_serv, nn->min_threads, nthreads[0 ]); -if (n > nn->nfsd_serv->sv_nrpools) - n = nn->nfsd_serv->sv_nrpools; +if (n >svc_serv_nrpools (nn->nfsd_serv)) + n =svc_serv_nrpools (nn->nfsd_serv);/* enforce a global maximum number of threads */ tot =0 ;@@ -731,7 +731,7 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net) }/* Anything undefined in array is considered to be 0 */ -for (i = n; i < nn->nfsd_serv->sv_nrpools; ++i) { +for (i = n; i <svc_serv_nrpools (nn->nfsd_serv); ++i) { err =svc_set_pool_threads (nn->nfsd_serv, &nn->nfsd_serv->sv_pools[i],0 ,0 );include/linux/sunrpc/svc.h +1
-1@@ -85,7 +85,6 @@ struct svc_serv {char * sv_name;/* service name */ -unsigned int sv_nrpools;/* number of thread pools */ bool sv_is_pooled;/* is this a pooled service? */ struct svc_pool * sv_pools;/* array of thread pools */ int (*sv_threadfn)(void *data);@@ -480,6 +479,7 @@ void svc_wake_up(struct svc_serv *);void svc_reserve (struct svc_rqst *rqstp,int space);void svc_pool_wake_idle_thread (struct svc_pool *pool);struct svc_pool *svc_pool_for_cpu (struct svc_serv *serv); +unsigned int svc_serv_nrpools (const struct svc_serv *serv);char *svc_print_addr (struct svc_rqst *,char *,size_t );const char *svc_proc_name (const struct svc_rqst *rqstp); int svc_encode_result_payload(struct svc_rqst *rqstp,net/sunrpc/svc.c +12
-1@@ -224,7 +224,7 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)unsigned int node = m->pool_to[pidx];/* -* The caller checks for sv_nrpools > 1, which +* The caller checks for more than one pool, which * implies that we've been initialized. */ WARN_ON_ONCE (m->count ==0 );@@ -234,6 +234,24 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)set_cpus_allowed_ptr (task,cpumask_of_node (node)); } +/** +* svc_serv_nrpools - number of thread pools backing a service +* @serv: An RPC service +* +* Pooled services all share the global svc_pool_map, so their pool count +* is svc_pool_map.npools. Unpooled services have a single pool. Reading +* npools without svc_pool_map_mutex is safe: a pooled service holds a map +* reference for its whole lifetime, so npools is stable once set. +* +* Return value: +* The number of pools in @serv Quoted 9 lines
net/sunrpc/svc.c svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx) · line 253
Quoted 6 lines
net/sunrpc/svc.c +6
-0+*/ +unsigned int svc_serv_nrpools (const struct svc_serv *serv) +{ +return serv->sv_is_pooled ? svc_pool_map.npools :1 ; +} +EXPORT_SYMBOL_GPL (svc_serv_nrpools);I would make this a static-inline.
Quoted 2 lines
That would mean that we would have to export
svc_pool_map, which is currently private tosvc.c.Quoted 8 lines
Why is exporting
svc_pool_mapmore problematic than exportingsvc_serv_nrpools? I think it would be good for at least the code insvc_pool_for_cpu()to inline the function. Maybe it already does? Or maybe marking it "inline" but still exporting it would work.Thanks,
NeilBrownDoing what you suggest would increase the interface "surface" between sunrpc.ko and nfsd.ko.
Quoted 7 lines
Currently struct
svc_pool_mapis only defined innet/sunrpc/svc.c, so we'd not only need to export the symbol, but also we'd have to make that definition public.Why expose so many internal details to other modules when all we need is this one accessor? I think keeping this interface small is preferable.
Quoted 7 lines
In general, yes. But it is not without cost. Sometimes the cost matters.
Interface size has an abstract value. Code size can have concrete value. Comparing them is subjective I guess.
I have no concrete evidence that there is a problem, so I'll stop objecting.
Your point is certainly valid, and this _is_ a hot path. If we can demonstrate that this matters, then I'd be happy to revisit the idea. I don't have the cycles to do so at the moment though.
Signature · 1 line
Jeff Layton <[email protected]>
Chuck Lever
maintainerQuoted 8 lines · Jeff Layton
This has a few small fixes and comment cleanups and also implements Neil's suggestion to remove serv.sv_nrpools:
Patches #1 and #3 address what is a shortcoming of the existing code -- namely that the server can be configured to schedule RPCs to pools with no threads in them.
[...]
Applied to nfsd-testing, thanks!
[1/5] sunrpc: route to a populated pool in svc_pool_for_cpu()
commit: abf002b5412b282ce825cf0ada22f0278ae7f408
[2/5] sunrpc: hardcode pool_mode to pernode, remove other modes
commit: cb4ab2c71e09f8c958ecc7bf07270ae78584f85a
[3/5] sunrpc: guarantee a thread per pool when auto-distributing
commit: c972bef38717f27c282592bca22890f49233ec0a
[4/5] sunrpc: tear down pool counters before dropping the pool map reference
commit: 9b6f69571d09627b8b4303be0f257c0e36d9d3fd
[5/5] sunrpc: derive the pool count instead of caching it in sv_nrpools
commit: 9435623ac560654825a62ee4b628ae4bbaa87920--
Chuck Lever