From: Mitchell Levy via B4 Relay <devnull+levymitchell0.gmail.com@kernel.org>
To: "K. Y. Srinivasan" <kys@microsoft.com>,
"Haiyang Zhang" <haiyangz@microsoft.com>,
"Wei Liu" <wei.liu@kernel.org>,
"Dexuan Cui" <decui@microsoft.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>
Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org,
Mitchell Levy <levymitchell0@gmail.com>
Subject: [PATCH RFC 1/2] Use raw_spinlock_t for vmbus_channel.sched_lock
Date: Wed, 09 Aug 2023 22:36:32 +0000 [thread overview]
Message-ID: <20230809-b4-rt_preempt-fix-v1-1-7283bbdc8b14@gmail.com> (raw)
In-Reply-To: <20230809-b4-rt_preempt-fix-v1-0-7283bbdc8b14@gmail.com>
From: Mitchell Levy <levymitchell0@gmail.com>
In vmbus_drv.c, vmbus_channel.sched_lock is acquired while holding an
rcu_read_lock. Since this is not a sleepable context, change sched_lock
to be a raw_spinlock_t to avoid sleeping when PREEMPT_RT is enabled.
---
drivers/hv/channel.c | 4 ++--
drivers/hv/channel_mgmt.c | 2 +-
drivers/hv/vmbus_drv.c | 4 ++--
drivers/pci/controller/pci-hyperv.c | 6 +++---
include/linux/hyperv.h | 2 +-
5 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 56f7e06c673e..00d73ec060ed 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -910,9 +910,9 @@ void vmbus_reset_channel_cb(struct vmbus_channel *channel)
tasklet_disable(&channel->callback_event);
/* See the inline comments in vmbus_chan_sched(). */
- spin_lock_irqsave(&channel->sched_lock, flags);
+ raw_spin_lock_irqsave(&channel->sched_lock, flags);
channel->onchannel_callback = NULL;
- spin_unlock_irqrestore(&channel->sched_lock, flags);
+ raw_spin_unlock_irqrestore(&channel->sched_lock, flags);
channel->sc_creation_callback = NULL;
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 2f4d09ce027a..7679e6a3a645 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -348,7 +348,7 @@ static struct vmbus_channel *alloc_channel(void)
if (!channel)
return NULL;
- spin_lock_init(&channel->sched_lock);
+ raw_spin_lock_init(&channel->sched_lock);
init_completion(&channel->rescind_event);
INIT_LIST_HEAD(&channel->sc_list);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 67f95a29aeca..b865d00c46dc 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1257,7 +1257,7 @@ static void vmbus_chan_sched(struct hv_per_cpu_context *hv_cpu)
* sched_lock critical section. See also the inline comments
* in vmbus_reset_channel_cb().
*/
- spin_lock(&channel->sched_lock);
+ raw_spin_lock(&channel->sched_lock);
callback_fn = channel->onchannel_callback;
if (unlikely(callback_fn == NULL))
@@ -1280,7 +1280,7 @@ static void vmbus_chan_sched(struct hv_per_cpu_context *hv_cpu)
}
sched_unlock:
- spin_unlock(&channel->sched_lock);
+ raw_spin_unlock(&channel->sched_lock);
sched_unlock_rcu:
rcu_read_unlock();
}
diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index 2d93d0c4f10d..9ede3be05782 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -1995,13 +1995,13 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
* sched_lock critical section. See also the inline comments
* in vmbus_reset_channel_cb().
*/
- spin_lock_irqsave(&channel->sched_lock, flags);
+ raw_spin_lock_irqsave(&channel->sched_lock, flags);
if (unlikely(channel->onchannel_callback == NULL)) {
- spin_unlock_irqrestore(&channel->sched_lock, flags);
+ raw_spin_unlock_irqrestore(&channel->sched_lock, flags);
goto enable_tasklet;
}
hv_pci_onchannelcallback(hbus);
- spin_unlock_irqrestore(&channel->sched_lock, flags);
+ raw_spin_unlock_irqrestore(&channel->sched_lock, flags);
udelay(100);
}
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 3ac3974b3c78..56a1fb1647a4 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -873,7 +873,7 @@ struct vmbus_channel {
* Synchronize channel scheduling and channel removal; see the inline
* comments in vmbus_chan_sched() and vmbus_reset_channel_cb().
*/
- spinlock_t sched_lock;
+ raw_spinlock_t sched_lock;
/*
* A channel can be marked for one of three modes of reading:
--
2.25.1
next prev parent reply other threads:[~2023-08-09 22:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 22:36 [PATCH RFC 0/2] hyperv: Use raw_spinlock_t when not sleepable Mitchell Levy via B4 Relay
2023-08-09 22:36 ` Mitchell Levy via B4 Relay [this message]
2023-08-09 22:36 ` [PATCH RFC 2/2] Use raw_spinlock_t in vmbus_requestor Mitchell Levy via B4 Relay
2023-08-15 18:44 ` [PATCH RFC 0/2] hyperv: Use raw_spinlock_t when not sleepable Michael Kelley (LINUX)
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=20230809-b4-rt_preempt-fix-v1-1-7283bbdc8b14@gmail.com \
--to=devnull+levymitchell0.gmail.com@kernel.org \
--cc=bhelgaas@google.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kw@linux.com \
--cc=kys@microsoft.com \
--cc=levymitchell0@gmail.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=robh@kernel.org \
--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).