mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-27 19:53:15 -04:00
The 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. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Jeff Layton <jlayton@kernel.org> Link: https://patch.msgid.link/20260706-sunrpc-pool-mode-v5-2-6c4ee7cd89aa@kernel.org Signed-off-by: Chuck Lever <cel@kernel.org>