From: Saurabh Sengar <ssengar@linux.microsoft.com>
To: kys@microsoft.com, haiyangz@microsoft.com,
sthemmin@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
ssengar@microsoft.com, mikelley@microsoft.com
Subject: [PATCH] Drivers: hv: vmbus: Add cpu read lock
Date: Wed, 8 Jun 2022 22:27:26 -0700 [thread overview]
Message-ID: <1654752446-20113-1-git-send-email-ssengar@linux.microsoft.com> (raw)
Add cpus_read_lock to prevent CPUs from going offline between query and
actual use of cpumask. cpumask_of_node is first queried, and based on it
used later, in case any CPU goes offline between these two events, it can
potentially cause an infinite loop of retries.
Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
---
drivers/hv/channel_mgmt.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 85a2142..6a88b7e 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -749,6 +749,9 @@ static void init_vp_index(struct vmbus_channel *channel)
return;
}
+ /* No CPUs should come up or down during this. */
+ cpus_read_lock();
+
for (i = 1; i <= ncpu + 1; i++) {
while (true) {
numa_node = next_numa_node_id++;
@@ -781,6 +784,7 @@ static void init_vp_index(struct vmbus_channel *channel)
break;
}
+ cpus_read_unlock();
channel->target_cpu = target_cpu;
free_cpumask_var(available_mask);
--
1.8.3.1
next reply other threads:[~2022-06-09 5:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 5:27 Saurabh Sengar [this message]
2022-06-09 13:51 ` [PATCH] Drivers: hv: vmbus: Add cpu read lock Michael Kelley (LINUX)
2022-06-09 13:59 ` Haiyang Zhang
2022-06-09 14:15 ` Saurabh Singh Sengar
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=1654752446-20113-1-git-send-email-ssengar@linux.microsoft.com \
--to=ssengar@linux.microsoft.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikelley@microsoft.com \
--cc=ssengar@microsoft.com \
--cc=sthemmin@microsoft.com \
--cc=wei.liu@kernel.org \
/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).