linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] xen/events: remove event handling recursion detection
@ 2019-11-28  8:45 Juergen Gross
  2019-11-28 21:37 ` Boris Ostrovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Juergen Gross @ 2019-11-28  8:45 UTC (permalink / raw)
  To: xen-devel, linux-kernel
  Cc: Juergen Gross, Boris Ostrovsky, Stefano Stabellini

__xen_evtchn_do_upcall() contains guards against being called
recursively. This mechanism was introduced in the early pvops times
(kernel 2.6.26) when there were all the Xen backend drivers missing
from the upstream kernel, and some of those out-of-tree drivers were
enabling interrupts in their event handlers (which was explicitly
allowed in the initial XenoLinux).

Nowadays we don't need to support those old drivers any more and the
capability to allow recursive calls of __xen_evtchn_do_upcall() can
be removed.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V2: adapt commit message (Jan Beulich)
---
 drivers/xen/events/events_base.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 6c8843968a52..33212c494afd 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -1213,31 +1213,21 @@ void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector)
 	notify_remote_via_irq(irq);
 }
 
-static DEFINE_PER_CPU(unsigned, xed_nesting_count);
-
 static void __xen_evtchn_do_upcall(void)
 {
 	struct vcpu_info *vcpu_info = __this_cpu_read(xen_vcpu);
-	int cpu = get_cpu();
-	unsigned count;
+	int cpu = smp_processor_id();
 
 	do {
 		vcpu_info->evtchn_upcall_pending = 0;
 
-		if (__this_cpu_inc_return(xed_nesting_count) - 1)
-			goto out;
-
 		xen_evtchn_handle_events(cpu);
 
 		BUG_ON(!irqs_disabled());
 
-		count = __this_cpu_read(xed_nesting_count);
-		__this_cpu_write(xed_nesting_count, 0);
-	} while (count != 1 || vcpu_info->evtchn_upcall_pending);
-
-out:
+		rmb(); /* Hypervisor can set upcall pending. */
 
-	put_cpu();
+	} while (vcpu_info->evtchn_upcall_pending);
 }
 
 void xen_evtchn_do_upcall(struct pt_regs *regs)
-- 
2.16.4


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

* Re: [PATCH v2] xen/events: remove event handling recursion detection
  2019-11-28  8:45 [PATCH v2] xen/events: remove event handling recursion detection Juergen Gross
@ 2019-11-28 21:37 ` Boris Ostrovsky
  2019-11-29  5:59   ` Jürgen Groß
  0 siblings, 1 reply; 3+ messages in thread
From: Boris Ostrovsky @ 2019-11-28 21:37 UTC (permalink / raw)
  To: Juergen Gross, xen-devel, linux-kernel; +Cc: Stefano Stabellini

On 11/28/19 3:45 AM, Juergen Gross wrote:
> -
>  static void __xen_evtchn_do_upcall(void)
>  {
>  	struct vcpu_info *vcpu_info = __this_cpu_read(xen_vcpu);
> -	int cpu = get_cpu();
> -	unsigned count;
> +	int cpu = smp_processor_id();
>  
>  	do {
>  		vcpu_info->evtchn_upcall_pending = 0;
>  
> -		if (__this_cpu_inc_return(xed_nesting_count) - 1)
> -			goto out;
> -
>  		xen_evtchn_handle_events(cpu);
>  
>  		BUG_ON(!irqs_disabled());
>  
> -		count = __this_cpu_read(xed_nesting_count);
> -		__this_cpu_write(xed_nesting_count, 0);
> -	} while (count != 1 || vcpu_info->evtchn_upcall_pending);
> -
> -out:
> +		rmb(); /* Hypervisor can set upcall pending. */

virt_rmb() perhaps then?

-boris

>  
> -	put_cpu();
> +	} while (vcpu_info->evtchn_upcall_pending);
>  }
>  
>  void xen_evtchn_do_upcall(struct pt_regs *regs)


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

* Re: [PATCH v2] xen/events: remove event handling recursion detection
  2019-11-28 21:37 ` Boris Ostrovsky
@ 2019-11-29  5:59   ` Jürgen Groß
  0 siblings, 0 replies; 3+ messages in thread
From: Jürgen Groß @ 2019-11-29  5:59 UTC (permalink / raw)
  To: Boris Ostrovsky, xen-devel, linux-kernel; +Cc: Stefano Stabellini

On 28.11.19 22:37, Boris Ostrovsky wrote:
> On 11/28/19 3:45 AM, Juergen Gross wrote:
>> -
>>   static void __xen_evtchn_do_upcall(void)
>>   {
>>   	struct vcpu_info *vcpu_info = __this_cpu_read(xen_vcpu);
>> -	int cpu = get_cpu();
>> -	unsigned count;
>> +	int cpu = smp_processor_id();
>>   
>>   	do {
>>   		vcpu_info->evtchn_upcall_pending = 0;
>>   
>> -		if (__this_cpu_inc_return(xed_nesting_count) - 1)
>> -			goto out;
>> -
>>   		xen_evtchn_handle_events(cpu);
>>   
>>   		BUG_ON(!irqs_disabled());
>>   
>> -		count = __this_cpu_read(xed_nesting_count);
>> -		__this_cpu_write(xed_nesting_count, 0);
>> -	} while (count != 1 || vcpu_info->evtchn_upcall_pending);
>> -
>> -out:
>> +		rmb(); /* Hypervisor can set upcall pending. */
> 
> virt_rmb() perhaps then?

Yes, that's better.


Juergen


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

end of thread, other threads:[~2019-11-29  5:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-28  8:45 [PATCH v2] xen/events: remove event handling recursion detection Juergen Gross
2019-11-28 21:37 ` Boris Ostrovsky
2019-11-29  5:59   ` Jürgen Groß

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