xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2] xen/events: Support event channel rebind on ARM
       [not found] <1437996911-18985-1-git-send-email-julien.grall@citrix.com>
@ 2015-07-27 12:35 ` David Vrabel
       [not found] ` <55B62588.3050502@citrix.com>
  1 sibling, 0 replies; 3+ messages in thread
From: David Vrabel @ 2015-07-27 12:35 UTC (permalink / raw)
  To: Julien Grall, xen-devel
  Cc: x86, ian.campbell, stefano.stabellini, Catalin Marinas,
	Will Deacon, linux-kernel, Ingo Molnar, H. Peter Anvin,
	Boris Ostrovsky, Thomas Gleixner, linux-arm-kernel

On 27/07/15 12:35, Julien Grall wrote:
> Currently, the event channel rebind code is gated with the presence of
> the vector callback.
> 
> The virtual interrupt controller on ARM has the concept of per-CPU
> interrupt (PPI) which allow us to support per-VCPU event channel.
> Therefore there is no need of vector callback for ARM.
> 
> Xen is already using a free PPI to notify the guest VCPU of an event.
> Furthermore, the xen code initialization in Linux (see
> arch/arm/xen/enlighten.c) is requesting correctly a per-CPU IRQ.
> 
> Introduce new helper xen_support_evtchn_rebind to allow architecture
> decide whether rebind an event is support or not. It will always return
> 1 on ARM and keep the same behavior on x86.
> 
> This is also allow us to drop the usage of xen_have_vector_callback
> entirely in the ARM code.

This did not apply cleanly.  Please always base patches on Linus's
master branch.

This also breaks the x86 build.

/local/davidvr/work/k.org/tip/arch/x86/include/asm/xen/events.h: In
function ‘xen_support_evtchn_rebind’:
/local/davidvr/work/k.org/tip/arch/x86/include/asm/xen/events.h:29:85:
error: ‘xen_have_vector_callback’ undeclared (first use in this function)
  return (!xen_hvm_domain() || xen_have_vector_callback);

> --- a/arch/arm/include/asm/xen/events.h
> +++ b/arch/arm/include/asm/xen/events.h
> @@ -20,4 +20,10 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)
>  							    atomic64_t,	\
>  							    counter), (val))
>  
> +/* Rebind event channel is supported by default */
> +static inline bool xen_support_evtchn_rebind(void)
> +{
> +	return 1;

This should be true (similarly for arm64).

David

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] xen/events: Support event channel rebind on ARM
       [not found] ` <55B62588.3050502@citrix.com>
@ 2015-07-27 12:43   ` Julien Grall
  0 siblings, 0 replies; 3+ messages in thread
From: Julien Grall @ 2015-07-27 12:43 UTC (permalink / raw)
  To: David Vrabel, xen-devel
  Cc: ian.campbell, stefano.stabellini, Catalin Marinas, x86,
	Will Deacon, linux-kernel, Ingo Molnar, H. Peter Anvin,
	Boris Ostrovsky, Thomas Gleixner, linux-arm-kernel

On 27/07/15 13:35, David Vrabel wrote:
> On 27/07/15 12:35, Julien Grall wrote:
>> Currently, the event channel rebind code is gated with the presence of
>> the vector callback.
>>
>> The virtual interrupt controller on ARM has the concept of per-CPU
>> interrupt (PPI) which allow us to support per-VCPU event channel.
>> Therefore there is no need of vector callback for ARM.
>>
>> Xen is already using a free PPI to notify the guest VCPU of an event.
>> Furthermore, the xen code initialization in Linux (see
>> arch/arm/xen/enlighten.c) is requesting correctly a per-CPU IRQ.
>>
>> Introduce new helper xen_support_evtchn_rebind to allow architecture
>> decide whether rebind an event is support or not. It will always return
>> 1 on ARM and keep the same behavior on x86.
>>
>> This is also allow us to drop the usage of xen_have_vector_callback
>> entirely in the ARM code.
> 
> This did not apply cleanly.  Please always base patches on Linus's
> master branch.

My patch is based on Linus's master branch. Although, it has a
pre-requisite of [1] which I sent a few seconds before it. Though it's
only for applying because the 2 patches are not related.

I should have mentioned it in the mail, sorry.

> This also breaks the x86 build.

I forgot to test this new version when I turned the macro into a static
inline.

> /local/davidvr/work/k.org/tip/arch/x86/include/asm/xen/events.h: In
> function ‘xen_support_evtchn_rebind’:
> /local/davidvr/work/k.org/tip/arch/x86/include/asm/xen/events.h:29:85:
> error: ‘xen_have_vector_callback’ undeclared (first use in this function)
>   return (!xen_hvm_domain() || xen_have_vector_callback);
> 
>> --- a/arch/arm/include/asm/xen/events.h
>> +++ b/arch/arm/include/asm/xen/events.h
>> @@ -20,4 +20,10 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)
>>  							    atomic64_t,	\
>>  							    counter), (val))
>>  
>> +/* Rebind event channel is supported by default */
>> +static inline bool xen_support_evtchn_rebind(void)
>> +{
>> +	return 1;
> 
> This should be true (similarly for arm64).

Will resend a new version, and remove the dependency on [1].

Regards,

[1] http://permalink.gmane.org/gmane.linux.kernel/2004690

-- 
Julien Grall

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] xen/events: Support event channel rebind on ARM
@ 2015-07-27 11:35 Julien Grall
  0 siblings, 0 replies; 3+ messages in thread
From: Julien Grall @ 2015-07-27 11:35 UTC (permalink / raw)
  To: xen-devel
  Cc: x86, ian.campbell, stefano.stabellini, Catalin Marinas,
	Will Deacon, linux-kernel, Julien Grall, Ingo Molnar,
	David Vrabel, H. Peter Anvin, Boris Ostrovsky, Thomas Gleixner,
	linux-arm-kernel

Currently, the event channel rebind code is gated with the presence of
the vector callback.

The virtual interrupt controller on ARM has the concept of per-CPU
interrupt (PPI) which allow us to support per-VCPU event channel.
Therefore there is no need of vector callback for ARM.

Xen is already using a free PPI to notify the guest VCPU of an event.
Furthermore, the xen code initialization in Linux (see
arch/arm/xen/enlighten.c) is requesting correctly a per-CPU IRQ.

Introduce new helper xen_support_evtchn_rebind to allow architecture
decide whether rebind an event is support or not. It will always return
1 on ARM and keep the same behavior on x86.

This is also allow us to drop the usage of xen_have_vector_callback
entirely in the ARM code.

Signed-off-by: Julien Grall <julien.grall@citrix.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
---
    Tested by setting the affinity manually via /proc on dom0 ARM64

    Changes in v2:
        - Use a static inline rather than a macro
        - Add David's reviewed-by
---
 arch/arm/include/asm/xen/events.h   |  6 ++++++
 arch/arm/xen/enlighten.c            |  4 ----
 arch/arm64/include/asm/xen/events.h |  6 ++++++
 arch/x86/include/asm/xen/events.h   | 14 ++++++++++++++
 drivers/xen/events/events_base.c    |  6 +-----
 include/xen/events.h                |  1 -
 6 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/arch/arm/include/asm/xen/events.h b/arch/arm/include/asm/xen/events.h
index 8b1f37b..2123aaa 100644
--- a/arch/arm/include/asm/xen/events.h
+++ b/arch/arm/include/asm/xen/events.h
@@ -20,4 +20,10 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)
 							    atomic64_t,	\
 							    counter), (val))
 
+/* Rebind event channel is supported by default */
+static inline bool xen_support_evtchn_rebind(void)
+{
+	return 1;
+}
+
 #endif /* _ASM_ARM_XEN_EVENTS_H */
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 9055c92..c50c8d3 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -45,10 +45,6 @@ static struct vcpu_info __percpu *xen_vcpu_info;
 unsigned long xen_released_pages;
 struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
 
-/* TODO: to be removed */
-__read_mostly int xen_have_vector_callback;
-EXPORT_SYMBOL_GPL(xen_have_vector_callback);
-
 static __read_mostly unsigned int xen_events_irq;
 
 static __initdata struct device_node *xen_node;
diff --git a/arch/arm64/include/asm/xen/events.h b/arch/arm64/include/asm/xen/events.h
index 8655321..ed4aa90 100644
--- a/arch/arm64/include/asm/xen/events.h
+++ b/arch/arm64/include/asm/xen/events.h
@@ -18,4 +18,10 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)
 
 #define xchg_xen_ulong(ptr, val) xchg((ptr), (val))
 
+/* Rebind event channel is supported by default */
+static inline bool xen_support_evtchn_rebind(void)
+{
+	return 1;
+}
+
 #endif /* _ASM_ARM64_XEN_EVENTS_H */
diff --git a/arch/x86/include/asm/xen/events.h b/arch/x86/include/asm/xen/events.h
index 608a79d..37bc720 100644
--- a/arch/x86/include/asm/xen/events.h
+++ b/arch/x86/include/asm/xen/events.h
@@ -20,4 +20,18 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)
 /* No need for a barrier -- XCHG is a barrier on x86. */
 #define xchg_xen_ulong(ptr, val) xchg((ptr), (val))
 
+/*
+ * Events delivered via platform PCI interrupts are always
+ * routed to vcpu 0 and hence cannot be rebound.
+ */
+static inline bool xen_support_evtchn_rebind(void)
+{
+	return (!xen_hvm_domain() || xen_have_vector_callback);
+}
+
+#define xen_support_evtchn_rebind()	\
+	(!xen_hvm_domain() || xen_have_vector_callback)
+
+extern int xen_have_vector_callback;
+
 #endif /* _ASM_X86_XEN_EVENTS_H */
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 96093ae..ed620e5 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -1301,11 +1301,7 @@ static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
 	if (!VALID_EVTCHN(evtchn))
 		return -1;
 
-	/*
-	 * Events delivered via platform PCI interrupts are always
-	 * routed to vcpu 0 and hence cannot be rebound.
-	 */
-	if (xen_hvm_domain() && !xen_have_vector_callback)
+	if (!xen_support_evtchn_rebind())
 		return -1;
 
 	/* Send future instances of this interrupt to other vcpu. */
diff --git a/include/xen/events.h b/include/xen/events.h
index 7d95fdf..88da2ab 100644
--- a/include/xen/events.h
+++ b/include/xen/events.h
@@ -92,7 +92,6 @@ void xen_hvm_callback_vector(void);
 #ifdef CONFIG_TRACING
 #define trace_xen_hvm_callback_vector xen_hvm_callback_vector
 #endif
-extern int xen_have_vector_callback;
 int xen_set_callback_via(uint64_t via);
 void xen_evtchn_do_upcall(struct pt_regs *regs);
 void xen_hvm_evtchn_do_upcall(void);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-27 12:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1437996911-18985-1-git-send-email-julien.grall@citrix.com>
2015-07-27 12:35 ` [PATCH v2] xen/events: Support event channel rebind on ARM David Vrabel
     [not found] ` <55B62588.3050502@citrix.com>
2015-07-27 12:43   ` Julien Grall
2015-07-27 11:35 Julien Grall

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).