Skip to contentSkip to conversation

xen: Enable interrupts when calling _cond_resched()

PATCH Superseded Thomas Gleixner 2 participants 5 messages Feb 19, 2020 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Enable interrupts when calling _cond_resched()

xen_maybe_preempt_hcall() is called from the exception entry point xen_do_hypervisor_callback with interrupts disabled.

_cond_resched() evades the might_sleep() check in cond_resched() which would have caught that and schedule_debug() unfortunately lacks a check for irqs_disabled().

Enable interrupts around the call and use cond_resched() to catch future issues.

Fixes fdfd811ddde3 ("x86/xen: allow privcmd hypercalls to be preempted")
---
 drivers/xen/preempt.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/preempt.c +3 -1
@@ -33,8 +33,10 @@ asmlinkage __visible void xen_maybe_pree
 		 * cpu.
 		 */
 		__this_cpu_write(xen_in_preemptible_hcall, false);
-		_cond_resched();
+		local_irq_enable();
+		cond_resched();
 		__this_cpu_write(xen_in_preemptible_hcall, true);
+		local_irq_disable();
 	}
 }
 #endif /* CONFIG_PREEMPTION */
maintainer
#1 lore raw
Quoted 19 lines · Thomas Gleixner

xen_maybe_preempt_hcall() is called from the exception entry point xen_do_hypervisor_callback with interrupts disabled.

_cond_resched() evades the might_sleep() check in cond_resched() which would have caught that and schedule_debug() unfortunately lacks a check for irqs_disabled().

Enable interrupts around the call and use cond_resched() to catch future issues.

Fixes fdfd811ddde3 ("x86/xen: allow privcmd hypercalls to be preempted")
---
  drivers/xen/preempt.c |    4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

drivers/xen/preempt.c asmlinkage __visible void xen_maybe_pree · line 39

Quoted 8 lines
drivers/xen/preempt.c +3 -1
@@ -33,8 +33,10 @@ asmlinkage __visible void xen_maybe_pree
  		 * cpu.
  		 */
  		__this_cpu_write(xen_in_preemptible_hcall, false);
-		_cond_resched();
+		local_irq_enable();
+		cond_resched();
  		__this_cpu_write(xen_in_preemptible_hcall, true);
+		local_irq_disable();

Could you please put the call of local_irq_disable() directly after the cond_resched() call to make the result symmetric regarding writing of xen_in_preemptible_hcall and irq enable/disable?

Juergen

#2 lore raw
Quoted 17 lines · Jürgen Groß
Quoted 16 lines · Thomas Gleixner

xen_maybe_preempt_hcall() is called from the exception entry point xen_do_hypervisor_callback with interrupts disabled.

_cond_resched() evades the might_sleep() check in cond_resched() which would have caught that and schedule_debug() unfortunately lacks a check for irqs_disabled().

Enable interrupts around the call and use cond_resched() to catch future issues.

Fixes fdfd811ddde3 ("x86/xen: allow privcmd hypercalls to be preempted")
---
  drivers/xen/preempt.c |    4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 15 lines

drivers/xen/preempt.c asmlinkage __visible void xen_maybe_pree · line 39

Quoted 11 lines
drivers/xen/preempt.c +3 -1
@@ -33,8 +33,10 @@ asmlinkage __visible void xen_maybe_pree
  		 * cpu.
  		 */
  		__this_cpu_write(xen_in_preemptible_hcall, false);
-		_cond_resched();
+		local_irq_enable();
+		cond_resched();
  		__this_cpu_write(xen_in_preemptible_hcall, true);
+		local_irq_disable();

Could you please put the call of local_irq_disable() directly after the cond_resched() call to make the result symmetric regarding writing of xen_in_preemptible_hcall and irq enable/disable?

Darn. Of course does this need to be there. Stupid me, let me resend.

#3 lore raw

PATCH v2 1/1 xen: Enable interrupts when calling _cond_resched()

xen_maybe_preempt_hcall() is called from the exception entry point xen_do_hypervisor_callback with interrupts disabled.

_cond_resched() evades the might_sleep() check in cond_resched() which would have caught that and schedule_debug() unfortunately lacks a check for irqs_disabled().

Enable interrupts around the call and use cond_resched() to catch future issues.

Fixes fdfd811ddde3 ("x86/xen: allow privcmd hypercalls to be preempted")

---
V2: Put local_irq_disable() where it belongs.

---
 drivers/xen/preempt.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/preempt.c +3 -1
@@ -33,7 +33,9 @@ asmlinkage __visible void xen_maybe_pree
 		 * cpu.
 		 */
 		__this_cpu_write(xen_in_preemptible_hcall, false);
-		_cond_resched();
+		local_irq_enable();
+		cond_resched();
+		local_irq_disable();
 		__this_cpu_write(xen_in_preemptible_hcall, true);
 	}
 }
maintainer Reviewed-by on v2 1/1
#4 lore raw
Quoted 7 lines · Thomas Gleixner

xen_maybe_preempt_hcall() is called from the exception entry point xen_do_hypervisor_callback with interrupts disabled.

_cond_resched() evades the might_sleep() check in cond_resched() which would have caught that and schedule_debug() unfortunately lacks a check for irqs_disabled().

Quoted 5 lines

Enable interrupts around the call and use cond_resched() to catch future issues.

Fixes fdfd811ddde3 ("x86/xen: allow privcmd hypercalls to be preempted")

Juergen