Skip to contentSkip to conversation

Bug report and patch about IRQ freezing after gic_restore_state

DISCUSSION Jaeyong Yoo 3 participants 3 messages May 22, 2013 – May 23, 2013

lore
Share & tools
lore
#0 lore raw
Quoted 24 lines · 유재용
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines

Signed-off-by: Jaeyong Yoo
---

 xen/arch/arm/domain.c |    4 ++-- 
 xen/arch/arm/gic.c    |    4 ++-- 
 2 files changed, 4 insertions(+), 4 deletions(-) 
xen/arch/arm/domain.c +0 -1
index f71b582..2c3b132 100644 
--- a/xen/arch/arm/domain.c 
Quoted 8 lines

xen/arch/arm/domain.c static void ctxt_switch_to(struct vcpu *n) · line 144

Quoted 6 lines

+++ b/xen/arch/arm/domain.c

xen/arch/arm/domain.c +2 -0
@@ -141,6 +141,8 @@ static void ctxt_switch_to(struct vcpu *n) 
     /* VGIC */ 
     gic_restore_state(n); 
+    local_irq_enable(); 
+

Could you move the local_irq_enable right after ctxt_switch_to?

Quoted 5 lines

Of course.
Just one small concern:
Would it be more efficient (i.e., less scheduling latency) if we enable irq right after gic_restore state similar to lock-breaking effect?

Quoted 5 lines

Perhaps, but I think at this stage we should aim for obvious correctness.

Optimising things for IRQ/scheduler latency is a complete project in its own right.

I got it.
Here goes the updated patch:

___

 xen/arch/arm/domain.c |    4 ++--
 xen/arch/arm/gic.c    |    2 --
 2 files changed, 2 insertions(+), 4 deletions(-)
xen/arch/arm/domain.c +2 -2
index 9ca44ea..ee12b5f 100644
@@ -226,10 +226,10 @@ static void schedule_tail(struct vcpu *prev)
 {
     ctxt_switch_from(prev);
 
-    local_irq_enable();
-
     ctxt_switch_to(current);
 
+    local_irq_enable();
+
     if ( prev != current )
         update_runstate_area(current);
 }
xen/arch/arm/gic.c +0 -2
index 30bf8d1..d9940ea 100644
@@ -93,11 +93,9 @@ void gic_restore_state(struct vcpu *v)
     if ( is_idle_vcpu(v) )
         return;
 
-    spin_lock_irq(&gic.lock);
     this_cpu(lr_mask) = v->arch.lr_mask;
     for ( i=0; i<nr_lrs; i++)
         GICH[GICH_LR + i] = v->arch.gic_lr[i];
-    spin_unlock_irq(&gic.lock);
     GICH[GICH_APR] = v->arch.gic_apr;
     GICH[GICH_HCR] = GICH_HCR_EN;
     isb();

best,
Jaeyong
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw
Quoted 4 lines · Jaeyong Yoo

I got it.
Here goes the updated patch:

Quoted 45 lines
 xen/arch/arm/domain.c |    4 ++--
 xen/arch/arm/gic.c    |    2 --
 2 files changed, 2 insertions(+), 4 deletions(-)
xen/arch/arm/domain.c +2 -2
index 9ca44ea..ee12b5f 100644
@@ -226,10 +226,10 @@ static void schedule_tail(struct vcpu *prev)
 {
     ctxt_switch_from(prev);
 
-    local_irq_enable();
-
     ctxt_switch_to(current);
 
+    local_irq_enable();
+
     if ( prev != current )
         update_runstate_area(current);
 }
xen/arch/arm/gic.c +0 -2
index 30bf8d1..d9940ea 100644
@@ -93,11 +93,9 @@ void gic_restore_state(struct vcpu *v)
     if ( is_idle_vcpu(v) )
         return;
 
-    spin_lock_irq(&gic.lock);
     this_cpu(lr_mask) = v->arch.lr_mask;
     for ( i=0; i<nr_lrs; i++)
         GICH[GICH_LR + i] = v->arch.gic_lr[i];
-    spin_unlock_irq(&gic.lock);
     GICH[GICH_APR] = v->arch.gic_apr;
     GICH[GICH_HCR] = GICH_HCR_EN;
     isb();

best,
Jaeyong
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by Stefano Stabellini
#2 lore raw
Quoted 3 lines · Stefano Stabellini
Quoted 2 lines · Jaeyong Yoo

I got it.
Here goes the updated patch:

Please can you include the (updated as necessary) changelog when reposting variants on patches. I have written one for you this time.

Quoted 4 lines
Quoted 2 lines

I applied this but I had to workaround the fact that the patch had DOS line endings.

Jaeyong, please can you try and fix this for next time.

The wiki page http://wiki.xen.org/wiki/Submitting_Xen_Patches might help
with some advice for tooling, in particular it has advice on using git
as well as a link to
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/email-clients.txt;hb=HEAD which has lots of useful advice on convincing your MUA not to mangle things...

What I have committed is below, please check that it is correct.

Cheers,
Ian.

commit 9f5179a4ecafd9a15e0a066e0f935ded681bf997

Author: Jaeyong Yoo <[email protected]>
Date:   Wed May 22 02:34:18 2013 +0000

xen/arm: Disable interrupts for the entire duration of the context switch

Not just while saving state. Otherwise there is a race between interrupts arriving and updating the LR state and gic_restore_state overwriting them with the saved state.

With this change we no longer need to disable interrupts in gic_restore_state.

[ ijc -- rewrote commit message ]
xen/arch/arm/domain.c +2 -2
index 9ca44ea..ee12b5f 100644
@@ -226,10 +226,10 @@ static void schedule_tail(struct vcpu *prev)
 {
     ctxt_switch_from(prev);
 
-    local_irq_enable();
-
     ctxt_switch_to(current);
 
+    local_irq_enable();
+
     if ( prev != current )
         update_runstate_area(current);
 }
xen/arch/arm/gic.c +0 -2
index 30bf8d1..d9940ea 100644
@@ -93,11 +93,9 @@ void gic_restore_state(struct vcpu *v)
     if ( is_idle_vcpu(v) )
         return;
 
-    spin_lock_irq(&gic.lock);
     this_cpu(lr_mask) = v->arch.lr_mask;
     for ( i=0; i<nr_lrs; i++)
         GICH[GICH_LR + i] = v->arch.gic_lr[i];
-    spin_unlock_irq(&gic.lock);
     GICH[GICH_APR] = v->arch.gic_apr;
     GICH[GICH_HCR] = GICH_HCR_EN;
     isb();