From: KY Srinivasan <kys@microsoft.com>
To: Thomas Gleixner <tglx@linutronix.de>,
LKML <linux-kernel@vger.kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <peterz@infradead.org>, x86 <x86@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linuxdrivers <devel@linuxdriverproject.org>
Subject: RE: [patch 25/26] x86: hyperv: Cleanup the irq mess
Date: Tue, 25 Feb 2014 12:24:59 +0000 [thread overview]
Message-ID: <379403385de44bcab2ad8a676d9cd49b@BY2PR03MB299.namprd03.prod.outlook.com> (raw)
In-Reply-To: <20140223212739.028307673@linutronix.de>
> -----Original Message-----
> From: Thomas Gleixner [mailto:tglx@linutronix.de]
> Sent: Sunday, February 23, 2014 1:40 PM
> To: LKML
> Cc: Ingo Molnar; Peter Zijlstra; x86; KY Srinivasan; Greg Kroah-Hartman;
> linuxdrivers
> Subject: [patch 25/26] x86: hyperv: Cleanup the irq mess
>
> The vmbus/hyperv interrupt handling is another complete trainwreck and
> probably the worst of all currently in tree.
>
> If CONFIG_HYPERV=y then the interrupt delivery to the vmbus happens via
> the direct HYPERVISOR_CALLBACK_VECTOR. So far so good, but:
>
> The driver requests first a normal device interrupt. The only reason
> to do so is to increment the interrupt stats of that device
> interrupt.
>
> We have proper accounting mechanisms for direct vectors, but of
> course it's too much effort to add that 5 lines of code.
>
> Aside of that the alloc_intr_gate() is not protected against
> reallocation which makes module reload impossible.
>
> If CONFIG_HYPERV=n then the vmbus request a regular device interrupt via
> request_irq() and installs it's own private flow handler. Of course this lacks
> any explanation why it can't use the standard flow handler or the existing
> handle_percpu_irq handler.
>
> Solution to the problem is simple to rip out the whole mess and implement it
> correctly.
Thomas,
Thank you for cleaning up this code. When CONFIG_HYPERV== n, none of the VMBUS code is active.
The special case can go away as you have noted.
Regards,
K. Y
>
> First of all move all that code to arch/x86/kernel/cpu/mshyperv.c
>
> For the CONFIG_HYPERV=y case merily install the
> HYPERVISOR_CALLBACK_VECTOR with proper reallocation protection and
> use the proper direct vector accounting mechanism.
>
> For the CONFIG_HYPERV=n case request the device irq and install the weird
> flow handler.
>
> If the special flow handler can go away, which I assume to be true, then this
> simplifies the code even further.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: x86 <x86@kernel.org>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linuxdrivers <devel@linuxdriverproject.org>
>
> ---
> arch/x86/include/asm/mshyperv.h | 4 +
> arch/x86/kernel/cpu/mshyperv.c | 97 ++++++++++++++++++++++++------
> ----------
> drivers/hv/vmbus_drv.c | 39 +---------------
> 3 files changed, 66 insertions(+), 74 deletions(-)
>
> Index: tip/arch/x86/include/asm/mshyperv.h
> ==========================================================
> =========
> --- tip.orig/arch/x86/include/asm/mshyperv.h
> +++ tip/arch/x86/include/asm/mshyperv.h
> @@ -2,6 +2,7 @@
> #define _ASM_X86_MSHYPER_H
>
> #include <linux/types.h>
> +#include <linux/interrupt.h>
> #include <asm/hyperv.h>
>
> struct ms_hyperv_info {
> @@ -16,6 +17,7 @@ void hyperv_callback_vector(void); #define
> trace_hyperv_callback_vector hyperv_callback_vector #endif void
> hyperv_vector_handler(struct pt_regs *regs); -void
> hv_register_vmbus_handler(int irq, irq_handler_t handler);
> +int hv_setup_vmbus_irq(int irq, irq_handler_t handler, void *dev_id);
> +void hv_remove_vmbus_irq(int irq, void *dev_id);
>
> #endif
> Index: tip/arch/x86/kernel/cpu/mshyperv.c
> ==========================================================
> =========
> --- tip.orig/arch/x86/kernel/cpu/mshyperv.c
> +++ tip/arch/x86/kernel/cpu/mshyperv.c
> @@ -17,6 +17,7 @@
> #include <linux/hardirq.h>
> #include <linux/efi.h>
> #include <linux/interrupt.h>
> +#include <linux/irq.h>
> #include <asm/processor.h>
> #include <asm/hypervisor.h>
> #include <asm/hyperv.h>
> @@ -30,6 +31,64 @@
> struct ms_hyperv_info ms_hyperv;
> EXPORT_SYMBOL_GPL(ms_hyperv);
>
> +#ifdef CONFIG_HYPERV
> +static irq_handler_t *vmbus_handler;
> +
> +void hyperv_vector_handler(struct pt_regs *regs) {
> + struct pt_regs *old_regs = set_irq_regs(regs);
> +
> + irq_enter();
> + exit_idle();
> +
> + inc_irq_stat(irq_hv_callback_count);
> + if (vmbus_handler)
> + vmbus_handler();
> +
> + irq_exit();
> + set_irq_regs(old_regs);
> +}
> +
> +int hv_setup_vmbus_irq(int irq, irq_handler_t *handler, void *dev_id) {
> + vmbus_handler = handler;
> + /*
> + * Setup the IDT for hypervisor callback. Prevent reallocation
> + * at module reload.
> + */
> + if (!test_bit(HYPERVISOR_CALLBACK_VECTOR, used_vectors))
> + alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,
> + hyperv_callback_vector);
> +}
> +
> +void hv_remove_vmbus_irq(unsigned int irq, void *dev_id) {
> + /* We have no way to deallocate the interrupt gate */
> + vmbus_handler = NULL;
> +}
> +#else
> +int hv_setup_vmbus_irq(int irq, irq_handler_t handler, void *dev_id) {
> + int ret = request_irq(irq, handler, 0, "hyperv", dev_id);
> +
> + if (!ret) {
> + /*
> + * Vmbus interrupts can be handled concurrently on
> + * different CPUs. Install the simple percpu flow handler.
> + */
> + irq_set_handler(irq, handle_percpu_simple_irq);
> + }
> + return ret;
> +}
> +
> +void hv_remove_vmbus_irq(int irq, void *dev_id) {
> + free_irq(irq, dev_id);;
> +}
> +#endif
> +EXPORT_SYMBOL_GPL(hv_setup_vmbus_irq);
> +EXPORT_SYMBOL_GPL(hv_remove_vmbus_irq);
> +
> static uint32_t __init ms_hyperv_platform(void) {
> u32 eax;
> @@ -113,41 +172,3 @@ const __refconst struct hypervisor_x86 x
> .init_platform = ms_hyperv_init_platform,
> };
> EXPORT_SYMBOL(x86_hyper_ms_hyperv);
> -
> -#if IS_ENABLED(CONFIG_HYPERV)
> -static int vmbus_irq = -1;
> -static irq_handler_t vmbus_isr;
> -
> -void hv_register_vmbus_handler(int irq, irq_handler_t handler) -{
> - /*
> - * Setup the IDT for hypervisor callback.
> - */
> - alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,
> hyperv_callback_vector);
> -
> - vmbus_irq = irq;
> - vmbus_isr = handler;
> -}
> -
> -void hyperv_vector_handler(struct pt_regs *regs) -{
> - struct pt_regs *old_regs = set_irq_regs(regs);
> - struct irq_desc *desc;
> -
> - irq_enter();
> - exit_idle();
> -
> - desc = irq_to_desc(vmbus_irq);
> -
> - if (desc)
> - generic_handle_irq_desc(vmbus_irq, desc);
> -
> - irq_exit();
> - set_irq_regs(old_regs);
> -}
> -#else
> -void hv_register_vmbus_handler(int irq, irq_handler_t handler) -{ -} -#endif
> -EXPORT_SYMBOL_GPL(hv_register_vmbus_handler);
> Index: tip/drivers/hv/vmbus_drv.c
> ==========================================================
> =========
> --- tip.orig/drivers/hv/vmbus_drv.c
> +++ tip/drivers/hv/vmbus_drv.c
> @@ -25,7 +25,6 @@
> #include <linux/init.h>
> #include <linux/module.h>
> #include <linux/device.h>
> -#include <linux/irq.h>
> #include <linux/interrupt.h>
> #include <linux/sysctl.h>
> #include <linux/slab.h>
> @@ -558,9 +557,6 @@ static struct bus_type hv_bus = {
> .dev_groups = vmbus_groups,
> };
>
> -static const char *driver_name = "hyperv";
> -
> -
> struct onmessage_work_context {
> struct work_struct work;
> struct hv_message msg;
> @@ -677,19 +673,6 @@ static irqreturn_t vmbus_isr(int irq, vo }
>
> /*
> - * vmbus interrupt flow handler:
> - * vmbus interrupts can concurrently occur on multiple CPUs and
> - * can be handled concurrently.
> - */
> -
> -static void vmbus_flow_handler(unsigned int irq, struct irq_desc *desc) -{
> - kstat_incr_irqs_this_cpu(irq, desc);
> -
> - desc->action->handler(irq, desc->action->dev_id);
> -}
> -
> -/*
> * vmbus_bus_init -Main vmbus driver initialization routine.
> *
> * Here, we
> @@ -715,26 +698,13 @@ static int vmbus_bus_init(int irq)
> if (ret)
> goto err_cleanup;
>
> - ret = request_irq(irq, vmbus_isr, 0, driver_name, hv_acpi_dev);
> + ret = hv_setup_vmbus_irq(irq, vmbus_isr, hv_acpi_dev);
>
> if (ret != 0) {
> - pr_err("Unable to request IRQ %d\n",
> - irq);
> + pr_err("Unable to request IRQ %d\n", irq);
> goto err_unregister;
> }
>
> - /*
> - * Vmbus interrupts can be handled concurrently on
> - * different CPUs. Establish an appropriate interrupt flow
> - * handler that can support this model.
> - */
> - irq_set_handler(irq, vmbus_flow_handler);
> -
> - /*
> - * Register our interrupt handler.
> - */
> - hv_register_vmbus_handler(irq, vmbus_isr);
> -
> ret = hv_synic_alloc();
> if (ret)
> goto err_alloc;
> @@ -753,7 +723,7 @@ static int vmbus_bus_init(int irq)
>
> err_alloc:
> hv_synic_free();
> - free_irq(irq, hv_acpi_dev);
> + hv_remove_vmbus_irq(irq, hv_acpi_dev);
>
> err_unregister:
> bus_unregister(&hv_bus);
> @@ -978,8 +948,7 @@ cleanup:
>
> static void __exit vmbus_exit(void)
> {
> -
> - free_irq(irq, hv_acpi_dev);
> + hv_remove_vmbus_irq(irq, hv_acpi_dev);
> vmbus_free_channels();
> bus_unregister(&hv_bus);
> hv_cleanup();
>
next prev parent reply other threads:[~2014-02-25 12:25 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
2014-02-23 21:40 ` [patch 01/26] powerpc: irq: Use generic_handle_irq Thomas Gleixner
2014-03-04 16:39 ` [tip:irq/core] powerpc: Irq: " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 02/26] powerpc:evh_pic: Kill irq_desc abuse Thomas Gleixner
2014-03-04 16:39 ` [tip:irq/core] powerpc:eVh_pic: " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 03/26] powerpc: eeh: Kill another abuse of irq_desc Thomas Gleixner
2014-02-23 22:26 ` Benjamin Herrenschmidt
[not found] ` <20140224075607.GA20727@shangw.(null)>
2014-02-24 11:32 ` Thomas Gleixner
2014-03-04 16:40 ` [tip:irq/core] powerpc: Eeh: " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 04/26] xtensa: Use irq_set_affinity instead of homebrewn code Thomas Gleixner
2014-02-24 0:32 ` Max Filippov
2014-03-04 16:43 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 05/26] sh: " Thomas Gleixner
2014-03-04 16:43 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 07/26] pci: pcie-designware: Remove irq_desc abuse Thomas Gleixner
2014-03-04 16:40 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 06/26] metag: Use irq_set_affinity instead of homebrewn code Thomas Gleixner
2014-02-24 13:24 ` James Hogan
2014-02-24 14:24 ` Thomas Gleixner
2014-02-25 18:56 ` Thomas Gleixner
2014-02-25 21:57 ` James Hogan
2014-02-27 10:59 ` Thomas Gleixner
2014-02-23 21:40 ` [patch 08/26] arm: Replace various irq_desc accesses Thomas Gleixner
2014-02-24 2:55 ` Shawn Guo
2014-02-26 17:05 ` Tony Lindgren
2014-03-04 16:40 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-03-20 15:22 ` [patch 08/26] " Arnd Bergmann
2014-02-23 21:40 ` [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals Thomas Gleixner
2014-02-23 23:17 ` Uwe Kleine-König
2014-02-24 6:07 ` Chao Xie
2014-02-24 6:43 ` Haojian Zhuang
2014-02-24 11:31 ` Thomas Gleixner
2014-02-27 1:37 ` Chao Xie
2014-02-27 2:19 ` Haojian Zhuang
2014-02-27 11:28 ` Thomas Gleixner
2014-02-24 11:27 ` Thomas Gleixner
2014-03-04 16:40 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 10/26] blackfin:Use generic /proc/interrupts implementation Thomas Gleixner
2014-02-26 10:00 ` Steven Miao
2014-02-23 21:40 ` [patch 12/26] mips: Use the core irq stats function Thomas Gleixner
2014-03-04 16:41 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 11/26] genirq: Add a kstat helper to increment irq stats Thomas Gleixner
2014-03-04 16:41 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 13/26] sparc: Use the core irq stats function Thomas Gleixner
2014-03-04 16:41 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-03-04 18:57 ` [patch 13/26] " David Miller
2014-02-23 21:40 ` [patch 15/26] x86: xen: " Thomas Gleixner
2014-02-24 14:20 ` [Xen-devel] " David Vrabel
2014-03-04 16:41 ` [tip:irq/core] x86: Xen: " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 14/26] mn10300: " Thomas Gleixner
2014-03-04 16:42 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 17/26] ia64: " Thomas Gleixner
2014-03-04 16:42 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 16/26] s390: cio: " Thomas Gleixner
2014-03-04 16:42 ` [tip:irq/core] s390: Cio: " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 18/26] xen: Use the proper irq functions Thomas Gleixner
2014-02-24 14:24 ` [Xen-devel] " David Vrabel
2014-02-24 21:13 ` Thomas Gleixner
2014-03-04 16:40 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 20/26] genirq: Provide irq_is_allocated() Thomas Gleixner
2014-02-23 21:40 ` [patch 19/26] genirq: Provide irqd_irq_has_actions() Thomas Gleixner
2014-02-23 21:40 ` [patch 22/26] x86: Add proper vector accounting for HyperV Thomas Gleixner
2014-02-25 12:24 ` KY Srinivasan
2014-03-04 16:42 ` [tip:irq/core] x86: Add proper vector accounting for HYPERVISOR_CALLBACK_VECTOR tip-bot for Thomas Gleixner
2014-09-22 21:03 ` [patch 22/26] x86: Add proper vector accounting for HyperV Elliott, Robert (Server Storage)
2014-02-23 21:40 ` [patch 21/26] xen: Get rid of the last irq_desc abuse Thomas Gleixner
2014-02-24 14:33 ` [Xen-devel] " David Vrabel
2014-02-24 21:12 ` Thomas Gleixner
2014-03-04 16:41 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-03-04 17:16 ` [Xen-devel] " David Vrabel
2014-02-23 21:40 ` [patch 24/26] genirq: Provide handle_percpu_simple_irq() Thomas Gleixner
2014-02-25 12:25 ` KY Srinivasan
2014-02-23 21:40 ` [patch 23/26] xen: Add proper irq accounting for HYPERCALL vector Thomas Gleixner
2014-02-24 14:48 ` [Xen-devel] " David Vrabel
2014-03-04 16:42 ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 25/26] x86: hyperv: Cleanup the irq mess Thomas Gleixner
2014-02-25 12:24 ` KY Srinivasan [this message]
2014-02-25 19:10 ` Thomas Gleixner
2014-02-28 2:50 ` KY Srinivasan
2014-03-04 16:42 ` [tip:irq/core] x86: Hyperv: " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 26/26] genirq: Move kstats_inc_irqs_this_cpu() to core Thomas Gleixner
2014-03-04 16:43 ` [tip:irq/core] genirq: Move kstat_incr_irqs_this_cpu() " tip-bot for Thomas Gleixner
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=379403385de44bcab2ad8a676d9cd49b@BY2PR03MB299.namprd03.prod.outlook.com \
--to=kys@microsoft.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@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
all inboxes | Powered by JetHome®