xen: event handling cleanup
Subsystems (4)
Juergen Gross
maintainerv2 cover xen: event handling cleanup
Do some cleanups in Xen event handling code.
Changes in V2:
- addressed comments
Juergen Gross (5):
xen: remove no longer used functions
xen/events: make struct irq_info private to events_base.c xen/events: only register debug interrupt for 2-level events xen/events: unmask a fifo event channel only if it was masked
Documentation: add xen.fifo_events kernel parameter description
.../admin-guide/kernel-parameters.txt | 7 ++ arch/x86/xen/smp.c | 19 ++-- arch/x86/xen/xen-ops.h | 2 + drivers/xen/events/events_2l.c | 7 +- drivers/xen/events/events_base.c | 94 +++++++++++++------ drivers/xen/events/events_fifo.c | 9 +- drivers/xen/events/events_internal.h | 70 ++------------ include/xen/events.h | 8 -- 8 files changed, 102 insertions(+), 114 deletions(-)
Signature · 1 line
2.26.2
Juergen Gross
maintainerPATCH v2 1/5 xen: remove no longer used functions
With the switch to the lateeoi model for interdomain event channels some functions are no longer in use. Remove them.
--- drivers/xen/events/events_base.c | 21 --------------------- include/xen/events.h | 8 -------- 2 files changed, 29 deletions(-)
drivers/xen/events/events_base.c +0 -21
@@ -1145,14 +1145,6 @@ static int bind_interdomain_evtchn_to_irq_chip(unsigned int remote_domain, chip); } -int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, -evtchn_port_t remote_port) -{ -return bind_interdomain_evtchn_to_irq_chip (remote_domain, remote_port, - &xen_dynamic_chip); -} -EXPORT_SYMBOL_GPL (bind_interdomain_evtchn_to_irq); -int bind_interdomain_evtchn_to_irq_lateeoi (unsigned int remote_domain,evtchn_port_t remote_port) {
@@ -1320,19 +1312,6 @@ static int bind_interdomain_evtchn_to_irqhandler_chip(return irq; } -int bind_interdomain_evtchn_to_irqhandler (unsigned int remote_domain, -evtchn_port_t remote_port, -irq_handler_t handler, -unsigned long irqflags, -const char *devname, -void *dev_id) -{ -return bind_interdomain_evtchn_to_irqhandler_chip (remote_domain, - remote_port, handler, irqflags, devname, - dev_id, &xen_dynamic_chip); -} -EXPORT_SYMBOL_GPL (bind_interdomain_evtchn_to_irqhandler); - int bind_interdomain_evtchn_to_irqhandler_lateeoi(unsigned int remote_domain, evtchn_port_t remote_port, irq_handler_t handler,
include/xen/events.h +0 -8
@@ -35,16 +35,8 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,unsigned long irqflags, const char *devname, void *dev_id); -int bind_interdomain_evtchn_to_irq (unsigned int remote_domain, -evtchn_port_t remote_port);int bind_interdomain_evtchn_to_irq_lateeoi (unsigned int remote_domain,evtchn_port_t remote_port); -int bind_interdomain_evtchn_to_irqhandler (unsigned int remote_domain, -evtchn_port_t remote_port, -irq_handler_t handler, -unsigned long irqflags, -const char *devname, -void *dev_id); int bind_interdomain_evtchn_to_irqhandler_lateeoi(unsigned int remote_domain, evtchn_port_t remote_port, irq_handler_t handler,
Signature · 1 line
2.26.2
Juergen Gross
maintainerPATCH v2 2/5 xen/events: make struct irq_info private to events_base.c
In reply to Juergen GrossThe struct irq_info of Xen's event handling is used only for two evtchn_ops functions outside of events_base.c. Those two functions can easily be switched to avoid that usage.
This allows to make struct irq_info and its related access functions private to events_base.c.
--- drivers/xen/events/events_2l.c | 7 +-- drivers/xen/events/events_base.c | 63 ++++++++++++++++++++++--- drivers/xen/events/events_fifo.c | 6 +-- drivers/xen/events/events_internal.h | 70 ++++------------------------ 4 files changed, 73 insertions(+), 73 deletions(-)
drivers/xen/events/events_2l.c +4 -3
@@ -47,10 +47,11 @@ static unsigned evtchn_2l_max_channels(void)return EVTCHN_2L_NR_CHANNELS ; } -static void evtchn_2l_bind_to_cpu (struct irq_info *info,unsigned cpu) +static void evtchn_2l_bind_to_cpu (evtchn_port_t evtchn,unsigned int cpu, +unsigned int old_cpu) { -clear_bit (info->evtchn,BM (per_cpu (cpu_evtchn_mask, info->cpu))); -set_bit (info->evtchn,BM (per_cpu (cpu_evtchn_mask, cpu))); +clear_bit (evtchn,BM (per_cpu (cpu_evtchn_mask, old_cpu))); +set_bit (evtchn,BM (per_cpu (cpu_evtchn_mask, cpu))); }static void evtchn_2l_clear_pending (evtchn_port_t port)
drivers/xen/events/events_base.c +57 -6
105 lines not on this page · raw message
drivers/xen/events/events_fifo.c +3 -3
@@ -138,9 +138,8 @@ static void init_array_page(event_word_t *array_page) array_page[i] =1 <<EVTCHN_FIFO_MASKED ; } -static int evtchn_fifo_setup (struct irq_info *info) +static int evtchn_fifo_setup (evtchn_port_t port) { -evtchn_port_t port = info->evtchn;unsigned new_array_pages;int ret;
@@ -186,7 +185,8 @@ static int evtchn_fifo_setup(struct irq_info *info)return ret; } -static void evtchn_fifo_bind_to_cpu (struct irq_info *info,unsigned cpu) +static void evtchn_fifo_bind_to_cpu (evtchn_port_t evtchn,unsigned int cpu, +unsigned int old_cpu) {/* no-op */ }
drivers/xen/events/events_internal.h +9 -61
103 lines not on this page · raw message
Signature · 1 line
2.26.2
Juergen Gross
maintainerPATCH v2 3/5 xen/events: only register debug interrupt for 2-level events
In reply to Juergen Grossxen_debug_interrupt() is specific to 2-level event handling. So don't register it with fifo event handling being active.
---
V2:
- rename fifo_events variable to xen_fifo_events (Jan Beulich)
--- arch/x86/xen/smp.c | 19 +++++++++++-------- arch/x86/xen/xen-ops.h | 2 ++ drivers/xen/events/events_base.c | 10 ++++++---- 3 files changed, 19 insertions(+), 12 deletions(-)
arch/x86/xen/smp.c +11 -8
@@ -88,14 +88,17 @@ int xen_smp_intr_init(unsigned int cpu)per_cpu (xen_callfunc_irq, cpu).irq = rc;per_cpu (xen_callfunc_irq, cpu).name = callfunc_name; - debug_name =kasprintf (GFP_KERNEL ,"debug%d" , cpu); - rc =bind_virq_to_irqhandler (VIRQ_DEBUG , cpu, xen_debug_interrupt, -IRQF_PERCPU |IRQF_NOBALANCING , - debug_name,NULL ); -if (rc <0 ) - goto fail; -per_cpu (xen_debug_irq, cpu).irq = rc; -per_cpu (xen_debug_irq, cpu).name = debug_name; +if (!xen_fifo_events) { + debug_name =kasprintf (GFP_KERNEL ,"debug%d" , cpu); + rc =bind_virq_to_irqhandler (VIRQ_DEBUG , cpu, + xen_debug_interrupt, +IRQF_PERCPU |IRQF_NOBALANCING , + debug_name,NULL ); +if (rc <0 ) + goto fail; +per_cpu (xen_debug_irq, cpu).irq = rc; +per_cpu (xen_debug_irq, cpu).name = debug_name; + } callfunc_name =kasprintf (GFP_KERNEL ,"callfuncsingle%d" , cpu); rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_SINGLE_VECTOR,
arch/x86/xen/xen-ops.h +2 -0
@@ -29,6 +29,8 @@ extern struct start_info *xen_start_info;extern struct shared_info xen_dummy_shared_info;extern struct shared_info *HYPERVISOR_shared_info; +extern bool xen_fifo_events; +void xen_setup_mfn_list_list (void );void xen_build_mfn_list_list (void );void xen_setup_machphys_mapping (void );
drivers/xen/events/events_base.c +6 -4
@@ -2050,8 +2050,8 @@ void xen_setup_callback_vector(void) {}static inline void xen_alloc_callback_vector (void ) {}#endif -static bool fifo_events = true; -module_param (fifo_events, bool,0 ); +bool xen_fifo_events = true; +module_param_named (fifo_events, xen_fifo_events, bool,0 );static int xen_evtchn_cpu_prepare (unsigned int cpu) {
@@ -2080,10 +2080,12 @@ void __init xen_init_IRQ(void)int ret = -EINVAL ;evtchn_port_t evtchn; -if (fifo_events) +if (xen_fifo_events) ret =xen_evtchn_fifo_init (); -if (ret <0 ) +if (ret <0 ) {xen_evtchn_2l_init (); + xen_fifo_events = false; + }xen_cpu_init_eoi (smp_processor_id ());
Signature · 1 line
2.26.2
Re: [PATCH v2 3/5] xen/events: only register debug interrupt for 2-level events
drivers/xen/events/events_base.c void __init xen_init_IRQ(void) · line 2088
Quoted 12 lines · Juergen Gross
drivers/xen/events/events_base.c +4
-2@@ -2080,10 +2080,12 @@ void __init xen_init_IRQ(void)int ret = -EINVAL ;evtchn_port_t evtchn; -if (fifo_events) +if (xen_fifo_events) ret =xen_evtchn_fifo_init (); -if (ret <0 ) +if (ret <0 ) {xen_evtchn_2l_init (); + xen_fifo_events = false; + }
Another note: While it may not matter right here, maybe better first set the variable and the call the function?
Jan
Jürgen Groß
maintainerRe: [PATCH v2 3/5] xen/events: only register debug interrupt for 2-level events
Quoted 5 lines · Jan Beulich
Quoted 4 lines · Juergen Gross
drivers/xen/events/events_base.c +0
-0@@ -2080,10 +2080,12 @@ void __init xen_init_IRQ(void)int ret = -EINVAL ;evtchn_port_t evtchn;
Quoted 11 lines
drivers/xen/events/events_base.c void __init xen_init_IRQ(void) · line 2088
Quoted 8 lines
drivers/xen/events/events_base.c +4
-2-if (fifo_events) +if (xen_fifo_events) ret =xen_evtchn_fifo_init (); -if (ret <0 ) +if (ret <0 ) {xen_evtchn_2l_init (); + xen_fifo_events = false; + }Another note: While it may not matter right here, maybe better first set the variable and the call the function?
I don't think this is really important, TBH.
This code is executed before other cpus are up and we'd have major other problems in case the sequence would really matter here.
Juergen
Re: [PATCH v2 3/5] xen/events: only register debug interrupt for 2-level events
Quoted 18 lines · Jürgen Groß
Quoted 5 lines · Jan Beulich
Quoted 4 lines · Juergen Gross
drivers/xen/events/events_base.c +0
-0@@ -2080,10 +2080,12 @@ void __init xen_init_IRQ(void)int ret = -EINVAL ;evtchn_port_t evtchn;Quoted 11 lines
drivers/xen/events/events_base.c void __init xen_init_IRQ(void) · line 2088
Quoted 8 lines
drivers/xen/events/events_base.c +4
-2-if (fifo_events) +if (xen_fifo_events) ret =xen_evtchn_fifo_init (); -if (ret <0 ) +if (ret <0 ) {xen_evtchn_2l_init (); + xen_fifo_events = false; + }Another note: While it may not matter right here, maybe better first set the variable and the call the function?
Quoted 4 lines
I don't think this is really important, TBH.
This code is executed before other cpus are up and we'd have major other problems in case the sequence would really matter here.
Fair enough; I was thinking in particular that it ought to be legitimate for xen_evtchn_2l_init() to BUG_ON(xen_fifo_events).
Jan
Juergen Gross
maintainerPATCH v2 4/5 xen/events: unmask a fifo event channel only if it was masked
In reply to Juergen GrossUnmasking an event channel with fifo events channels being used can require a hypercall to be made, so try to avoid that by checking whether the event channel was really masked.
---
V2:
- move test for already unmasked into loop (Jan Beulich)
--- drivers/xen/events/events_fifo.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/xen/events/events_fifo.c +3 -0
@@ -237,6 +237,9 @@ static bool clear_masked_cond(volatile event_word_t *word) w = *word; do { + if (!(w & (1 << EVTCHN_FIFO_MASKED))) + return true; + if (w & (1 << EVTCHN_FIFO_PENDING)) return false;
Signature · 1 line
2.26.2
Juergen Gross
maintainerPATCH v2 5/5 Documentation: add xen.fifo_events kernel parameter description
In reply to Juergen GrossThe kernel boot parameter xen.fifo_events isn't listed in Documentation/admin-guide/kernel-parameters.txt. Add it.
--- Documentation/admin-guide/kernel-parameters.txt | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +7 -0
@@ -5978,6 +5978,13 @@ After which time (jiffies) the event handling loop should start to delay EOI handling. Default is 2. + xen.fifo_events= [XEN] + Boolean parameter to disable using fifo event handling + even if available. Normally fifo event handling is + preferred over the 2-level event handling, as it is + fairer and the number of possible event channels is + much higher. Default is on (use fifo events). + nopv= [X86,XEN,KVM,HYPER_V,VMWARE] Disables the PV optimizations forcing the guest to run as generic guest with no PV drivers. Currently support
Signature · 1 line
2.26.2
Quoted 12 lines · Juergen Gross
Do some cleanups in Xen event handling code.
Changes in V2:
- addressed commentsJuergen Gross (5):
xen: remove no longer used functions
xen/events: make structirq_infoprivate toevents_base.cxen/events: only register debug interrupt for 2-level events xen/events: unmask a fifo event channel only if it was masked
Documentation: add xen.fifo_events kernel parameter description
Quoted 10 lines
.../admin-guide/kernel-parameters.txt | 7 ++ arch/x86/xen/smp.c | 19 ++-- arch/x86/xen/xen-ops.h | 2 + drivers/xen/events/events_2l.c | 7 +- drivers/xen/events/events_base.c | 94 +++++++++++++------ drivers/xen/events/events_fifo.c | 9 +- drivers/xen/events/events_internal.h | 70 ++------------ include/xen/events.h | 8 -- 8 files changed, 102 insertions(+), 114 deletions(-)
Applied to for-linus-5.10b.
-boris