* [PATCH 0/3] Drivers: hv: fix kdump (again) and more
@ 2016-01-18 17:18 Vitaly Kuznetsov
2016-01-18 17:18 ` [PATCH 1/3] Drivers: hv: vmbus: avoid infinite loop in init_vp_index() Vitaly Kuznetsov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Vitaly Kuznetsov @ 2016-01-18 17:18 UTC (permalink / raw)
To: K. Y. Srinivasan; +Cc: Haiyang Zhang, devel, linux-kernel
Kdump on crash is reportedly broken for Hyper-V guests and I was able to
find two reasons:
1) Inability to boot with nr_cpus=1 (PATCH 1)
2) Sleeping in interrupt context on crash (PATCH 2 and 3)
Vitaly Kuznetsov (3):
Drivers: hv: vmbus: avoid infinite loop in init_vp_index()
Drivers: hv: vmbus: avoid scheduling in interrupt context in
vmbus_initiate_unload()
Drivers: hv: vmbus: don't manipulate with clocksources on crash
drivers/hv/channel_mgmt.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++-
drivers/hv/hv.c | 10 +++++++--
2 files changed, 62 insertions(+), 3 deletions(-)
--
2.5.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/3] Drivers: hv: vmbus: avoid infinite loop in init_vp_index()
2016-01-18 17:18 [PATCH 0/3] Drivers: hv: fix kdump (again) and more Vitaly Kuznetsov
@ 2016-01-18 17:18 ` Vitaly Kuznetsov
2016-01-18 17:18 ` [PATCH 2/3] Drivers: hv: vmbus: avoid scheduling in interrupt context in vmbus_initiate_unload() Vitaly Kuznetsov
2016-01-18 17:18 ` [PATCH 3/3] Drivers: hv: vmbus: don't manipulate with clocksources on crash Vitaly Kuznetsov
2 siblings, 0 replies; 4+ messages in thread
From: Vitaly Kuznetsov @ 2016-01-18 17:18 UTC (permalink / raw)
To: K. Y. Srinivasan; +Cc: Haiyang Zhang, devel, linux-kernel
When we pick a CPU to use for a new subchannel we try find a non-used one
on the appropriate NUMA node, we keep track of them with the
primary->alloced_cpus_in_node mask. Under normal circumstances we don't run
out of available CPUs but it is possible when we we don't initialize some
cpus in Linux, e.g. when we boot with 'nr_cpus=' limitation.
Avoid the infinite loop in init_vp_index() by checking that we still have
non-used CPUs in the alloced_cpus_in_node mask and resetting it in case
we don't.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
drivers/hv/channel_mgmt.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 1c1ad47..82c6860 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -469,6 +469,17 @@ static void init_vp_index(struct vmbus_channel *channel, const uuid_le *type_gui
cpumask_of_node(primary->numa_node));
cur_cpu = -1;
+
+ /*
+ * Normally Hyper-V host doesn't create more subchannels than there
+ * are VCPUs on the node but it is possible when not all present VCPUs
+ * on the node are initialized by guest. Clear the alloced_cpus_in_node
+ * to start over.
+ */
+ if (cpumask_equal(&primary->alloced_cpus_in_node,
+ cpumask_of_node(primary->numa_node)))
+ cpumask_clear(&primary->alloced_cpus_in_node);
+
while (true) {
cur_cpu = cpumask_next(cur_cpu, &available_mask);
if (cur_cpu >= nr_cpu_ids) {
--
2.5.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/3] Drivers: hv: vmbus: avoid scheduling in interrupt context in vmbus_initiate_unload()
2016-01-18 17:18 [PATCH 0/3] Drivers: hv: fix kdump (again) and more Vitaly Kuznetsov
2016-01-18 17:18 ` [PATCH 1/3] Drivers: hv: vmbus: avoid infinite loop in init_vp_index() Vitaly Kuznetsov
@ 2016-01-18 17:18 ` Vitaly Kuznetsov
2016-01-18 17:18 ` [PATCH 3/3] Drivers: hv: vmbus: don't manipulate with clocksources on crash Vitaly Kuznetsov
2 siblings, 0 replies; 4+ messages in thread
From: Vitaly Kuznetsov @ 2016-01-18 17:18 UTC (permalink / raw)
To: K. Y. Srinivasan; +Cc: Haiyang Zhang, devel, linux-kernel
We have to call vmbus_initiate_unload() on crash to make kdump work but
the crash can also be happening in interrupt (e.g. Sysrq + c results in
such) where we can't schedule or the following will happen:
[ 314.905786] bad: scheduling from the idle thread!
Just skipping the wait (and even adding some random wait here) won't help:
to make host-side magic working we're supposed to receive CHANNELMSG_UNLOAD
(and actually confirm the fact that we received it) but we can't use
interrupt-base path (vmbus_isr()-> vmbus_on_msg_dpc()). Implement a simple
busy wait ignoring all the other messages and use it if we're in an
interrupt context.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
drivers/hv/channel_mgmt.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 82c6860..763d0c1 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -28,6 +28,7 @@
#include <linux/list.h>
#include <linux/module.h>
#include <linux/completion.h>
+#include <linux/delay.h>
#include <linux/hyperv.h>
#include "hyperv_vmbus.h"
@@ -509,6 +510,40 @@ static void init_vp_index(struct vmbus_channel *channel, const uuid_le *type_gui
channel->target_vp = hv_context.vp_index[cur_cpu];
}
+static void vmbus_wait_for_unload(void)
+{
+ int cpu = smp_processor_id();
+ void *page_addr = hv_context.synic_message_page[cpu];
+ struct hv_message *msg = (struct hv_message *)page_addr +
+ VMBUS_MESSAGE_SINT;
+ struct vmbus_channel_message_header *hdr;
+ bool unloaded = false;
+
+ while (1) {
+ if (msg->header.message_type == HVMSG_NONE) {
+ mdelay(10);
+ continue;
+ }
+
+ hdr = (struct vmbus_channel_message_header *)msg->u.payload;
+ if (hdr->msgtype == CHANNELMSG_UNLOAD_RESPONSE)
+ unloaded = true;
+
+ msg->header.message_type = HVMSG_NONE;
+ /*
+ * header.message_type needs to be written before we do
+ * wrmsrl() below.
+ */
+ mb();
+
+ if (msg->header.message_flags.msg_pending)
+ wrmsrl(HV_X64_MSR_EOM, 0);
+
+ if (unloaded)
+ break;
+ }
+}
+
/*
* vmbus_unload_response - Handler for the unload response.
*/
@@ -534,7 +569,14 @@ void vmbus_initiate_unload(void)
hdr.msgtype = CHANNELMSG_UNLOAD;
vmbus_post_msg(&hdr, sizeof(struct vmbus_channel_message_header));
- wait_for_completion(&vmbus_connection.unload_event);
+ /*
+ * vmbus_initiate_unload() is also called on crash and the crash can be
+ * happening in an interrupt context, where scheduling is impossible.
+ */
+ if (!in_interrupt())
+ wait_for_completion(&vmbus_connection.unload_event);
+ else
+ vmbus_wait_for_unload();
}
/*
--
2.5.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 3/3] Drivers: hv: vmbus: don't manipulate with clocksources on crash
2016-01-18 17:18 [PATCH 0/3] Drivers: hv: fix kdump (again) and more Vitaly Kuznetsov
2016-01-18 17:18 ` [PATCH 1/3] Drivers: hv: vmbus: avoid infinite loop in init_vp_index() Vitaly Kuznetsov
2016-01-18 17:18 ` [PATCH 2/3] Drivers: hv: vmbus: avoid scheduling in interrupt context in vmbus_initiate_unload() Vitaly Kuznetsov
@ 2016-01-18 17:18 ` Vitaly Kuznetsov
2 siblings, 0 replies; 4+ messages in thread
From: Vitaly Kuznetsov @ 2016-01-18 17:18 UTC (permalink / raw)
To: K. Y. Srinivasan; +Cc: Haiyang Zhang, devel, linux-kernel
clocksource_change_rating() involves mutex usage and can't be called
in interrupt context. It also makes sense to avoid doing redundant work
on crash.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
drivers/hv/hv.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
index 11bca51..257de21 100644
--- a/drivers/hv/hv.c
+++ b/drivers/hv/hv.c
@@ -295,8 +295,14 @@ void hv_cleanup(void)
* Cleanup the TSC page based CS.
*/
if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
- clocksource_change_rating(&hyperv_cs_tsc, 10);
- clocksource_unregister(&hyperv_cs_tsc);
+ /*
+ * Crash can happen in an interrupt context and unregistering
+ * a clocksource is impossible and redundant in this case.
+ */
+ if (!oops_in_progress) {
+ clocksource_change_rating(&hyperv_cs_tsc, 10);
+ clocksource_unregister(&hyperv_cs_tsc);
+ }
hypercall_msr.as_uint64 = 0;
wrmsrl(HV_X64_MSR_REFERENCE_TSC, hypercall_msr.as_uint64);
--
2.5.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-01-18 17:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-18 17:18 [PATCH 0/3] Drivers: hv: fix kdump (again) and more Vitaly Kuznetsov
2016-01-18 17:18 ` [PATCH 1/3] Drivers: hv: vmbus: avoid infinite loop in init_vp_index() Vitaly Kuznetsov
2016-01-18 17:18 ` [PATCH 2/3] Drivers: hv: vmbus: avoid scheduling in interrupt context in vmbus_initiate_unload() Vitaly Kuznetsov
2016-01-18 17:18 ` [PATCH 3/3] Drivers: hv: vmbus: don't manipulate with clocksources on crash Vitaly Kuznetsov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®