kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kvm fix: Enable pvspinlock after jump_label_init() to avoid VM hang
@ 2013-10-09  9:03 Raghavendra K T
  2013-10-09  9:23 ` Paolo Bonzini
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Raghavendra K T @ 2013-10-09  9:03 UTC (permalink / raw)
  To: mingo, hpa, x86, gleb, pbonzini, tglx
  Cc: konrad.wilk, habanero, linux-kernel, kvm, mtosatti,
	Steven Rostedt, Raghavendra K T

We use jump label to enable pv-spinlock. With the changes in
(442e0973e927 Merge branch 'x86/jumplabel'), the jump label behaviour has changed
that would result in evntual hang of the VM since we would end up in a situation
where slowpath locks would halt the vcpus but we will not be able to wakeup the
vcpu by lock releaser using unlock kick.

Similar problem in Xen and more detailed description is available in
a945928ea270 (xen: Do not enable spinlocks before jump_label_init() has executed)

This patch splits kvm_spinlock_init to separate jump label changes with pvops
patching and also make jump label enabling after jump_label_init().

Signed-off-by: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
---
 Thanks to Andrew Theurer who reported weird behaviour of pvspinlock
 in 3.12-rc that led to my git bisection and investigation and Konrad
 for his jump label findings for Xen.

 arch/x86/kernel/kvm.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 697b93a..a0e2a8a 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -775,11 +775,22 @@ void __init kvm_spinlock_init(void)
 	if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT))
 		return;
 
-	printk(KERN_INFO "KVM setup paravirtual spinlock\n");
+	pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(kvm_lock_spinning);
+	pv_lock_ops.unlock_kick = kvm_unlock_kick;
+}
+
+static __init int kvm_spinlock_init_jump(void)
+{
+	if (!kvm_para_available())
+		return 0;
+	if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT))
+		return 0;
 
 	static_key_slow_inc(&paravirt_ticketlocks_enabled);
+	printk(KERN_INFO "KVM setup paravirtual spinlock\n");
 
-	pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(kvm_lock_spinning);
-	pv_lock_ops.unlock_kick = kvm_unlock_kick;
+	return 0;
 }
+early_initcall(kvm_spinlock_init_jump);
+
 #endif	/* CONFIG_PARAVIRT_SPINLOCKS */
-- 
1.7.11.7

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

* Re: [PATCH] kvm fix: Enable pvspinlock after jump_label_init() to avoid VM hang
  2013-10-09  9:03 [PATCH] kvm fix: Enable pvspinlock after jump_label_init() to avoid VM hang Raghavendra K T
@ 2013-10-09  9:23 ` Paolo Bonzini
  2013-10-10 14:43 ` Steven Rostedt
  2013-10-13  8:08 ` Raghavendra K T
  2 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2013-10-09  9:23 UTC (permalink / raw)
  To: Raghavendra K T
  Cc: mingo, hpa, x86, gleb, tglx, konrad.wilk, habanero, linux-kernel,
	kvm, mtosatti, Steven Rostedt

Il 09/10/2013 11:03, Raghavendra K T ha scritto:
> We use jump label to enable pv-spinlock. With the changes in
> (442e0973e927 Merge branch 'x86/jumplabel'), the jump label behaviour has changed
> that would result in evntual hang of the VM since we would end up in a situation
> where slowpath locks would halt the vcpus but we will not be able to wakeup the
> vcpu by lock releaser using unlock kick.
> 
> Similar problem in Xen and more detailed description is available in
> a945928ea270 (xen: Do not enable spinlocks before jump_label_init() has executed)
> 
> This patch splits kvm_spinlock_init to separate jump label changes with pvops
> patching and also make jump label enabling after jump_label_init().
> 
> Signed-off-by: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
> ---
>  Thanks to Andrew Theurer who reported weird behaviour of pvspinlock
>  in 3.12-rc that led to my git bisection and investigation and Konrad
>  for his jump label findings for Xen.
> 
>  arch/x86/kernel/kvm.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index 697b93a..a0e2a8a 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -775,11 +775,22 @@ void __init kvm_spinlock_init(void)
>  	if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT))
>  		return;
>  
> -	printk(KERN_INFO "KVM setup paravirtual spinlock\n");
> +	pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(kvm_lock_spinning);
> +	pv_lock_ops.unlock_kick = kvm_unlock_kick;
> +}
> +
> +static __init int kvm_spinlock_init_jump(void)
> +{
> +	if (!kvm_para_available())
> +		return 0;
> +	if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT))
> +		return 0;
>  
>  	static_key_slow_inc(&paravirt_ticketlocks_enabled);
> +	printk(KERN_INFO "KVM setup paravirtual spinlock\n");
>  
> -	pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(kvm_lock_spinning);
> -	pv_lock_ops.unlock_kick = kvm_unlock_kick;
> +	return 0;
>  }
> +early_initcall(kvm_spinlock_init_jump);
> +
>  #endif	/* CONFIG_PARAVIRT_SPINLOCKS */
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

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

* Re: [PATCH] kvm fix: Enable pvspinlock after jump_label_init() to avoid VM hang
  2013-10-09  9:03 [PATCH] kvm fix: Enable pvspinlock after jump_label_init() to avoid VM hang Raghavendra K T
  2013-10-09  9:23 ` Paolo Bonzini
@ 2013-10-10 14:43 ` Steven Rostedt
  2013-10-13  8:08 ` Raghavendra K T
  2 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2013-10-10 14:43 UTC (permalink / raw)
  To: Raghavendra K T
  Cc: mingo, hpa, x86, gleb, pbonzini, tglx, konrad.wilk, habanero,
	linux-kernel, kvm, mtosatti

On Wed,  9 Oct 2013 14:33:21 +0530
Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com> wrote:

> We use jump label to enable pv-spinlock. With the changes in
> (442e0973e927 Merge branch 'x86/jumplabel'), the jump label behaviour has changed
> that would result in evntual hang of the VM since we would end up in a situation
> where slowpath locks would halt the vcpus but we will not be able to wakeup the
> vcpu by lock releaser using unlock kick.
> 
> Similar problem in Xen and more detailed description is available in
> a945928ea270 (xen: Do not enable spinlocks before jump_label_init() has executed)
> 
> This patch splits kvm_spinlock_init to separate jump label changes with pvops
> patching and also make jump label enabling after jump_label_init().
> 
> Signed-off-by: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>

Reviewed-by: Steven Rostedt <rostedt@goodmis.org>

-- Steve

> ---
>  Thanks to Andrew Theurer who reported weird behaviour of pvspinlock
>  in 3.12-rc that led to my git bisection and investigation and Konrad
>  for his jump label findings for Xen.
> 
>  arch/x86/kernel/kvm.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 

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

* Re: [PATCH] kvm fix: Enable pvspinlock after jump_label_init() to avoid VM hang
  2013-10-09  9:03 [PATCH] kvm fix: Enable pvspinlock after jump_label_init() to avoid VM hang Raghavendra K T
  2013-10-09  9:23 ` Paolo Bonzini
  2013-10-10 14:43 ` Steven Rostedt
@ 2013-10-13  8:08 ` Raghavendra K T
  2013-10-13  8:11   ` Gleb Natapov
  2 siblings, 1 reply; 5+ messages in thread
From: Raghavendra K T @ 2013-10-13  8:08 UTC (permalink / raw)
  To: mingo, hpa, tglx
  Cc: Raghavendra K T, x86, gleb, pbonzini, konrad.wilk, habanero,
	linux-kernel, kvm, mtosatti, Steven Rostedt

On 10/09/2013 02:33 PM, Raghavendra K T wrote:
> We use jump label to enable pv-spinlock. With the changes in
> (442e0973e927 Merge branch 'x86/jumplabel'), the jump label behaviour has changed
> that would result in evntual hang of the VM since we would end up in a situation
> where slowpath locks would halt the vcpus but we will not be able to wakeup the
> vcpu by lock releaser using unlock kick.
>
> Similar problem in Xen and more detailed description is available in
> a945928ea270 (xen: Do not enable spinlocks before jump_label_init() has executed)
>
> This patch splits kvm_spinlock_init to separate jump label changes with pvops
> patching and also make jump label enabling after jump_label_init().
>
> Signed-off-by: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>

Ingo,
Could you please take this fix?
This is reviewed by Paolo and Steven.

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

* Re: [PATCH] kvm fix: Enable pvspinlock after jump_label_init() to avoid VM hang
  2013-10-13  8:08 ` Raghavendra K T
@ 2013-10-13  8:11   ` Gleb Natapov
  0 siblings, 0 replies; 5+ messages in thread
From: Gleb Natapov @ 2013-10-13  8:11 UTC (permalink / raw)
  To: Raghavendra K T
  Cc: mingo, hpa, tglx, x86, pbonzini, konrad.wilk, habanero,
	linux-kernel, kvm, mtosatti, Steven Rostedt

On Sun, Oct 13, 2013 at 01:38:57PM +0530, Raghavendra K T wrote:
> On 10/09/2013 02:33 PM, Raghavendra K T wrote:
> >We use jump label to enable pv-spinlock. With the changes in
> >(442e0973e927 Merge branch 'x86/jumplabel'), the jump label behaviour has changed
> >that would result in evntual hang of the VM since we would end up in a situation
> >where slowpath locks would halt the vcpus but we will not be able to wakeup the
> >vcpu by lock releaser using unlock kick.
> >
> >Similar problem in Xen and more detailed description is available in
> >a945928ea270 (xen: Do not enable spinlocks before jump_label_init() has executed)
> >
> >This patch splits kvm_spinlock_init to separate jump label changes with pvops
> >patching and also make jump label enabling after jump_label_init().
> >
> >Signed-off-by: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
> 
> Ingo,
> Could you please take this fix?
> This is reviewed by Paolo and Steven.
It's KVM, I'll take it.

--
			Gleb.

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

end of thread, other threads:[~2013-10-13  8:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-09  9:03 [PATCH] kvm fix: Enable pvspinlock after jump_label_init() to avoid VM hang Raghavendra K T
2013-10-09  9:23 ` Paolo Bonzini
2013-10-10 14:43 ` Steven Rostedt
2013-10-13  8:08 ` Raghavendra K T
2013-10-13  8:11   ` Gleb Natapov

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