From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F1C42C237E; Sat, 12 Sep 2026 15:32:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789227176; cv=none; b=m8RstLTJiZFgBoy8CUEYLO5kJ7YkSPghRm0Q9Rt4uNELAwU+K+HzSDTaeq2JU396uKmEi1P//bWJmmZ9pxDuNA2zGDl3zqZc+S9nAIx9anR3KwVLIhD28xk5+8qbbDdn56tAlTDtzl26RBplwZ8AmdYPI3z7b6dOAL9Cp+CZ3Zc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789227176; c=relaxed/simple; bh=CjO3N9mQT8Zumtef+gnm/VUl5vwpwpyLeMI+yzugYqM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kzVd7E5myKvrQqGBUDYo6vJzfMmfE/Kr8I+qfrEzssS2HruRMxhEzfHRXR5YPBvy8uKz4PA4FHcVXIL0bzYy3uqfTnG4bFUdGo/VW/vM6w3EzlrMd2yDshc29JQsLzf3g1vb7rc916rWgBMd8CVWAMbSlSu34vB0ULEAaQP0W6o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UZvR20tU; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="UZvR20tU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFCCA1F000FF; Sat, 12 Sep 2026 15:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789227174; bh=DxNhZCGoeF4KbygHi1iOtLFqcNkoDxI+wBwrONJMmbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UZvR20tUdigzHOJkRUoFPlSb91Rf4NRDCQTtF6bGdy907fo5xfMwcWIWl5o3tZ2Xn w3ZhU+n1IV9EufXWv4381UdBDQ4RB5ySZXhifKyVngjhhepR9B52HzBEuTt5862cmm oPq2QRZHY64geE4e8RKMJh3OJAcij9QhNbfQ9wbw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jeff Layton , Chuck Lever Subject: [PATCH 6.1 0127/1191] sunrpc: route to a populated pool in svc_pool_for_cpu() Date: Sat, 12 Sep 2026 08:47:35 +0200 Message-ID: <20260912065551.046406147@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065548.086904252@linuxfoundation.org> References: <20260912065548.086904252@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jeff Layton commit f6310491c4cdb88af73aa551ec9df1f10a90c709 upstream. 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(). Fixes: bfd241600a3b ("[PATCH] knfsd: make rpc threads pools numa aware") Cc: stable@vger.kernel.org Signed-off-by: Jeff Layton Link: https://patch.msgid.link/20260706-sunrpc-pool-mode-v5-1-6c4ee7cd89aa@kernel.org Signed-off-by: Chuck Lever Signed-off-by: Greg Kroah-Hartman --- net/sunrpc/svc.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -372,6 +372,7 @@ struct svc_pool *svc_pool_for_cpu(struct 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; @@ -384,8 +385,34 @@ struct svc_pool *svc_pool_for_cpu(struct pidx = m->to_pool[cpu_to_node(cpu)]; break; } + pidx %= serv->sv_nrpools; - return &serv->sv_pools[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 service 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; + } + + /* No pool has any threads; nothing can service the transport. */ + return &serv->sv_pools[pidx]; } int svc_rpcb_setup(struct svc_serv *serv, struct net *net)