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 E80F7418A5B; Sat, 12 Sep 2026 13:38:41 +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=1789220323; cv=none; b=cQT+hDWOstv2uL30BX605KdZ7olVWFX49FXbpwpZqsAATfNEWzS2p2OOrtYud5rNTz5FJWduxrlagr4rRgfKndfX5K8bTSk6pqRXf4nCAQnzB5vjzgqSe7uxt9qFXMVWib8wp7xIQr2yCKzmbGyVoJrZv9DK/OjZZbRfdx8pV6g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789220323; c=relaxed/simple; bh=VcBuwkqQfog+V3GRT/zzsUBq/D0J1o/DKjR2fPdrwFY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uwp27Io/SqpSEqpwqluqC041RpjMr8VpcGJch5CmbK+ITQAbzubMMB1GRUQA8MuRvnaf1Op2MF5eF8OGb7UdLa+BaikFWzhgKXl40k5I++sn3eh/hdlQk73LKiS7K/0+kF74K/UOf4+azRLJ3ruYsw/X3x5OXn5ZMwyyaUgclJo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=YQColaO1; 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="YQColaO1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3CCC1F000FF; Sat, 12 Sep 2026 13:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789220321; bh=FFZ+AOphOZez1h3m8mkAdLYrwNZU2bILhlsBkn5t/AE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YQColaO1/k5iIs5yg58OYwai5NWSYti7SCbWR78IahfBdi+nB+XBxqx8tRBh3M/Fs T4XEgzBDSnkpmPiQyIbAvyP9DP1aMLG/n2+/IeN3oCzO1Xkun3K2c/V16ilREWK6z1 4fhyHvqIKheX/jJebIVtO1vLf+ZgKp4znl96ISNs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jeff Layton , Chuck Lever Subject: [PATCH 6.6 0152/1424] sunrpc: route to a populated pool in svc_pool_for_cpu() Date: Sat, 12 Sep 2026 08:43:04 +0200 Message-ID: <20260912065610.700588622@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.279695368@linuxfoundation.org> References: <20260912065607.279695368@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.6-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)