From: sashiko-bot@kernel.org
To: "Waiman Long" <longman@redhat.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH v2] Drivers: hv: Avoid infinite retry loop in init_vp_index()
Date: Wed, 26 Aug 2026 19:40:11 +0000 [thread overview]
Message-ID: <20260826194012.0B7351F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260826192509.529838-1-longman@redhat.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Incrementing the bounded loop counter when skipping empty NUMA nodes causes premature search termination, falling back to CPU 0.
- [Medium] When the loop falls back to VMBUS_CONNECT_CPU, it fails to register this allocation in the hv_numa_map, breaking the round-robin distribution tracker.
--
commit 5b552e920b17d64534cf7a69fd8a78145809498a
Author: Waiman Long <longman@redhat.com>
Drivers: hv: Avoid infinite retry loop in init_vp_index()
This commit fixes an infinite retry loop in init_vp_index() that occurs when
the housekeeping cpumask for managed IRQs contains no CPUs in a particular
NUMA node. It resolves this by skipping to the next node if the allocated
cpumask is already cleared, and falling back to VMBUS_CONNECT_CPU if the loop
is about to end.
Link: https://sashiko.dev/#/message/20260422030903.E1BFCC2BCB0%40smtp.kernel.org
> diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
> --- a/drivers/hv/channel_mgmt.c
> +++ b/drivers/hv/channel_mgmt.c
> @@ -793,10 +793,20 @@ static void init_vp_index(struct vmbus_channel *channel)
> if (cpumask_empty(available_mask)) {
> /*
> * We have cycled through all the CPUs in the node;
> - * reset the allocated map.
> + * reset the allocated map. If the allocated map
> + * has already been cleared, we will try the next numa
> + * node. Set target_cpu to the default VMBUS_CONNECT_CPU
> + * instead if the for loop is going to end.
> */
> - cpumask_clear(allocated_mask);
> - goto retry;
> + if (!cpumask_empty(allocated_mask)) {
> + cpumask_clear(allocated_mask);
> + goto retry;
> + }
> + if (i > ncpu) {
> + target_cpu = VMBUS_CONNECT_CPU;
> + break;
[Severity: Medium]
When the loop falls back to VMBUS_CONNECT_CPU here, does this bypass updating
the round-robin allocation tracker?
The fallback block earlier in init_vp_index() correctly calls
hv_set_allocated_cpu(VMBUS_CONNECT_CPU) to maintain the global allocation
state:
channel->target_cpu = VMBUS_CONNECT_CPU;
if (perf_chn)
hv_set_allocated_cpu(VMBUS_CONNECT_CPU);
return;
Could breaking out directly here without making the corresponding state update
cause a load imbalance by stacking extra channels on CPU 0 without the
balancer knowing?
> + }
> + continue; /* Try next numa node */
[Severity: High]
Does this continue statement prematurely exhaust the loop iterations when
encountering nodes with no housekeeping CPUs?
Since the loop counter i limits the total search across ncpu + 1 iterations,
incrementing it while skipping an empty NUMA node burns through the search
budget without actually evaluating any CPUs.
For example, in a topology with several isolated NUMA nodes, could skipping
these empty nodes cause the loop budget to run out early, incorrectly forcing
a fallback to VMBUS_CONNECT_CPU before checking all valid housekeeping CPUs?
> }
>
> target_cpu = cpumask_first(available_mask);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260826192509.529838-1-longman@redhat.com?part=1
next prev parent reply other threads:[~2026-08-26 19:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 19:25 [PATCH v2] Drivers: hv: Avoid infinite retry loop in init_vp_index() Waiman Long
2026-08-26 19:40 ` sashiko-bot [this message]
2026-08-27 1:27 ` Michael Kelley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260826194012.0B7351F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=longman@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).