* [RHEL7.6 PATCH 22/37] Drivers: hv: vmbus: Fix a rescind issue
[not found] <1524241783-22489-1-git-send-email-mgamal@redhat.com>
@ 2018-04-20 16:29 ` Mohammed Gamal
2018-04-23 22:00 ` Bruno E. O. Meneguele
2018-04-20 16:29 ` [RHEL7.6 PATCH 35/37] Drivers: hv: vmbus: do not mark HV_PCIE as perf_device Mohammed Gamal
1 sibling, 1 reply; 4+ messages in thread
From: Mohammed Gamal @ 2018-04-20 16:29 UTC (permalink / raw)
To: rhkernel-list
Cc: rhvirt-patches, vkuznets, otubo, cavery, jasowang, Mohammed Gamal,
stable
The current rescind processing code will not correctly handle
the case where the host immediately rescinds a channel that has
been offerred. In this case, we could be blocked in the open call and
since the channel is rescinded, the host will not respond and we could
be blocked forever in the vmbus open call.i Fix this problem.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 7fa32e5ec28b1609abc0b797b58267f725fc3964)
Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
---
drivers/hv/channel.c | 10 ++++++++--
drivers/hv/channel_mgmt.c | 7 ++++---
include/linux/hyperv.h | 1 +
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 1c967f5..1d58986 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -659,22 +659,28 @@ void vmbus_close(struct vmbus_channel *channel)
*/
return;
}
- mutex_lock(&vmbus_connection.channel_mutex);
/*
* Close all the sub-channels first and then close the
* primary channel.
*/
list_for_each_safe(cur, tmp, &channel->sc_list) {
cur_channel = list_entry(cur, struct vmbus_channel, sc_list);
- vmbus_close_internal(cur_channel);
if (cur_channel->rescind) {
+ wait_for_completion(&cur_channel->rescind_event);
+ mutex_lock(&vmbus_connection.channel_mutex);
+ vmbus_close_internal(cur_channel);
hv_process_channel_removal(
cur_channel->offermsg.child_relid);
+ } else {
+ mutex_lock(&vmbus_connection.channel_mutex);
+ vmbus_close_internal(cur_channel);
}
+ mutex_unlock(&vmbus_connection.channel_mutex);
}
/*
* Now close the primary.
*/
+ mutex_lock(&vmbus_connection.channel_mutex);
vmbus_close_internal(channel);
mutex_unlock(&vmbus_connection.channel_mutex);
}
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index ec5454f..c21020b 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -333,6 +333,7 @@ static struct vmbus_channel *alloc_channel(void)
return NULL;
spin_lock_init(&channel->lock);
+ init_completion(&channel->rescind_event);
INIT_LIST_HEAD(&channel->sc_list);
INIT_LIST_HEAD(&channel->percpu_list);
@@ -898,6 +899,7 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
/*
* Now wait for offer handling to complete.
*/
+ vmbus_rescind_cleanup(channel);
while (READ_ONCE(channel->probe_done) == false) {
/*
* We wait here until any channel offer is currently
@@ -913,7 +915,6 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
if (channel->device_obj) {
if (channel->chn_rescind_callback) {
channel->chn_rescind_callback(channel);
- vmbus_rescind_cleanup(channel);
return;
}
/*
@@ -922,7 +923,6 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
*/
dev = get_device(&channel->device_obj->device);
if (dev) {
- vmbus_rescind_cleanup(channel);
vmbus_device_unregister(channel->device_obj);
put_device(dev);
}
@@ -936,13 +936,14 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
* 2. Then close the primary channel.
*/
mutex_lock(&vmbus_connection.channel_mutex);
- vmbus_rescind_cleanup(channel);
if (channel->state == CHANNEL_OPEN_STATE) {
/*
* The channel is currently not open;
* it is safe for us to cleanup the channel.
*/
hv_process_channel_removal(rescind->child_relid);
+ } else {
+ complete(&channel->rescind_event);
}
mutex_unlock(&vmbus_connection.channel_mutex);
}
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 1552a5f..465d5db 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -724,6 +724,7 @@ struct vmbus_channel {
u8 monitor_bit;
bool rescind; /* got rescind msg */
+ struct completion rescind_event;
u32 ringbuffer_gpadlhandle;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [RHEL7.6 PATCH 35/37] Drivers: hv: vmbus: do not mark HV_PCIE as perf_device
[not found] <1524241783-22489-1-git-send-email-mgamal@redhat.com>
2018-04-20 16:29 ` [RHEL7.6 PATCH 22/37] Drivers: hv: vmbus: Fix a rescind issue Mohammed Gamal
@ 2018-04-20 16:29 ` Mohammed Gamal
2018-04-20 16:55 ` Mohammed Gamal
1 sibling, 1 reply; 4+ messages in thread
From: Mohammed Gamal @ 2018-04-20 16:29 UTC (permalink / raw)
To: rhkernel-list
Cc: rhvirt-patches, vkuznets, otubo, cavery, jasowang, Mohammed Gamal,
stable, Stephen Hemminger, K. Y. Srinivasan
The pci-hyperv driver's channel callback hv_pci_onchannelcallback() is not
really a hot path, so we don't need to mark it as a perf_device, meaning
with this patch all HV_PCIE channels' target_cpu will be CPU0.
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Cc: stable@vger.kernel.org
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 238064f13d057390a8c5e1a6a80f4f0a0ec46499)
Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
---
drivers/hv/channel_mgmt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index c6d9d19..ecc2bd2 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -71,7 +71,7 @@ static const struct vmbus_device vmbus_devs[] = {
/* PCIE */
{ .dev_type = HV_PCIE,
HV_PCIE_GUID,
- .perf_device = true,
+ .perf_device = false,
},
/* Synthetic Frame Buffer */
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RHEL7.6 PATCH 35/37] Drivers: hv: vmbus: do not mark HV_PCIE as perf_device
2018-04-20 16:29 ` [RHEL7.6 PATCH 35/37] Drivers: hv: vmbus: do not mark HV_PCIE as perf_device Mohammed Gamal
@ 2018-04-20 16:55 ` Mohammed Gamal
0 siblings, 0 replies; 4+ messages in thread
From: Mohammed Gamal @ 2018-04-20 16:55 UTC (permalink / raw)
To: K. Y. Srinivasan, Stephen Hemminger, stable
On Fri, 2018-04-20 at 18:29 +0200, Mohammed Gamal wrote:
> The pci-hyperv driver's channel callback hv_pci_onchannelcallback()
> is not
> really a hot path, so we don't need to mark it as a perf_device,
> meaning
> with this patch all HV_PCIE channels' target_cpu will be CPU0.
>
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
> Cc: stable@vger.kernel.org
> Cc: Stephen Hemminger <sthemmin@microsoft.com>
> Cc: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> (cherry picked from commit 238064f13d057390a8c5e1a6a80f4f0a0ec46499)
>
> Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
> ---
> drivers/hv/channel_mgmt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
> index c6d9d19..ecc2bd2 100644
> --- a/drivers/hv/channel_mgmt.c
> +++ b/drivers/hv/channel_mgmt.c
> @@ -71,7 +71,7 @@ static const struct vmbus_device vmbus_devs[] = {
> /* PCIE */
> { .dev_type = HV_PCIE,
> HV_PCIE_GUID,
> - .perf_device = true,
> + .perf_device = false,
> },
>
> /* Synthetic Frame Buffer */
Please ignore this and the other patches I sent to stable@vger.kernel.o
rg. This was a mistake when setting git send-email flags.
Sorry.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RHEL7.6 PATCH 22/37] Drivers: hv: vmbus: Fix a rescind issue
2018-04-20 16:29 ` [RHEL7.6 PATCH 22/37] Drivers: hv: vmbus: Fix a rescind issue Mohammed Gamal
@ 2018-04-23 22:00 ` Bruno E. O. Meneguele
0 siblings, 0 replies; 4+ messages in thread
From: Bruno E. O. Meneguele @ 2018-04-23 22:00 UTC (permalink / raw)
To: Mohammed Gamal; +Cc: rhkernel-list, stable, rhvirt-patches
[-- Attachment #1: Type: text/plain, Size: 4583 bytes --]
On 20-04, Mohammed Gamal wrote:
> The current rescind processing code will not correctly handle
> the case where the host immediately rescinds a channel that has
> been offerred. In this case, we could be blocked in the open call and
> since the channel is rescinded, the host will not respond and we could
> be blocked forever in the vmbus open call.i Fix this problem.
>
> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> (cherry picked from commit 7fa32e5ec28b1609abc0b797b58267f725fc3964)
>
> Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
Just fyi, this patch was already applied by:
http://patchwork.lab.bos.redhat.com/patch/207318/
thus I'll drop it during this patchset integration to rhel tree.
Thanks!
> ---
> drivers/hv/channel.c | 10 ++++++++--
> drivers/hv/channel_mgmt.c | 7 ++++---
> include/linux/hyperv.h | 1 +
> 3 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
> index 1c967f5..1d58986 100644
> --- a/drivers/hv/channel.c
> +++ b/drivers/hv/channel.c
> @@ -659,22 +659,28 @@ void vmbus_close(struct vmbus_channel *channel)
> */
> return;
> }
> - mutex_lock(&vmbus_connection.channel_mutex);
> /*
> * Close all the sub-channels first and then close the
> * primary channel.
> */
> list_for_each_safe(cur, tmp, &channel->sc_list) {
> cur_channel = list_entry(cur, struct vmbus_channel, sc_list);
> - vmbus_close_internal(cur_channel);
> if (cur_channel->rescind) {
> + wait_for_completion(&cur_channel->rescind_event);
> + mutex_lock(&vmbus_connection.channel_mutex);
> + vmbus_close_internal(cur_channel);
> hv_process_channel_removal(
> cur_channel->offermsg.child_relid);
> + } else {
> + mutex_lock(&vmbus_connection.channel_mutex);
> + vmbus_close_internal(cur_channel);
> }
> + mutex_unlock(&vmbus_connection.channel_mutex);
> }
> /*
> * Now close the primary.
> */
> + mutex_lock(&vmbus_connection.channel_mutex);
> vmbus_close_internal(channel);
> mutex_unlock(&vmbus_connection.channel_mutex);
> }
> diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
> index ec5454f..c21020b 100644
> --- a/drivers/hv/channel_mgmt.c
> +++ b/drivers/hv/channel_mgmt.c
> @@ -333,6 +333,7 @@ static struct vmbus_channel *alloc_channel(void)
> return NULL;
>
> spin_lock_init(&channel->lock);
> + init_completion(&channel->rescind_event);
>
> INIT_LIST_HEAD(&channel->sc_list);
> INIT_LIST_HEAD(&channel->percpu_list);
> @@ -898,6 +899,7 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
> /*
> * Now wait for offer handling to complete.
> */
> + vmbus_rescind_cleanup(channel);
> while (READ_ONCE(channel->probe_done) == false) {
> /*
> * We wait here until any channel offer is currently
> @@ -913,7 +915,6 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
> if (channel->device_obj) {
> if (channel->chn_rescind_callback) {
> channel->chn_rescind_callback(channel);
> - vmbus_rescind_cleanup(channel);
> return;
> }
> /*
> @@ -922,7 +923,6 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
> */
> dev = get_device(&channel->device_obj->device);
> if (dev) {
> - vmbus_rescind_cleanup(channel);
> vmbus_device_unregister(channel->device_obj);
> put_device(dev);
> }
> @@ -936,13 +936,14 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
> * 2. Then close the primary channel.
> */
> mutex_lock(&vmbus_connection.channel_mutex);
> - vmbus_rescind_cleanup(channel);
> if (channel->state == CHANNEL_OPEN_STATE) {
> /*
> * The channel is currently not open;
> * it is safe for us to cleanup the channel.
> */
> hv_process_channel_removal(rescind->child_relid);
> + } else {
> + complete(&channel->rescind_event);
> }
> mutex_unlock(&vmbus_connection.channel_mutex);
> }
> diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
> index 1552a5f..465d5db 100644
> --- a/include/linux/hyperv.h
> +++ b/include/linux/hyperv.h
> @@ -724,6 +724,7 @@ struct vmbus_channel {
> u8 monitor_bit;
>
> bool rescind; /* got rescind msg */
> + struct completion rescind_event;
>
> u32 ringbuffer_gpadlhandle;
>
> --
> 1.8.3.1
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-04-23 22:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1524241783-22489-1-git-send-email-mgamal@redhat.com>
2018-04-20 16:29 ` [RHEL7.6 PATCH 22/37] Drivers: hv: vmbus: Fix a rescind issue Mohammed Gamal
2018-04-23 22:00 ` Bruno E. O. Meneguele
2018-04-20 16:29 ` [RHEL7.6 PATCH 35/37] Drivers: hv: vmbus: do not mark HV_PCIE as perf_device Mohammed Gamal
2018-04-20 16:55 ` Mohammed Gamal
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).