All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen: Do not enable spinlocks before jump_label_init() has executed
@ 2013-09-13  2:29 Boris Ostrovsky
  2013-09-13  2:47 ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: Boris Ostrovsky @ 2013-09-13  2:29 UTC (permalink / raw)
  To: rostedt
  Cc: hpa, david.vrabel, linux-kernel, Stefano.Stabellini,
	Konrad Rzeszutek Wilk, Boris Ostrovsky

From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

xen_init_spinlocks() currently calls static_key_slow_inc() before
jump_label_init() is invoked. When CONFIG_JUMP_LABEL is set (which usually is
the case) the effect of this static_key_slow_inc() is deferred until after
jump_label_init(). This is different from when CONFIG_JUMP_LABEL is not set, in
which case the key is set immediately. Thus, depending on the value of config
option, we may observe different behavior.

In addition, when we come to __jump_label_transform() from jump_label_init(),
the key (paravirt_ticketlocks_enabled) is already enabled. On processors where
ideal_nop is not the same as default_nop this will cause a BUG() since it is
expected that before a key is enabled the latter is replaced by the former
during initialization.

To address this problem we need to move
static_key_slow_inc(&paravirt_ticketlocks_enabled) so that it is called
after jump_label_init(). We also need to make sure that this is done before
other cpus start to boot. early_initcall appears to be  a good place to do so.
(Note that we cannot move whole xen_init_spinlocks() there since pv_lock_ops
need to be set before alternative_instructions() runs.)

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 arch/x86/xen/spinlock.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index 253f63f..d90628d 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -267,11 +267,18 @@ void __init xen_init_spinlocks(void)
 		return;
 	}
 
-	static_key_slow_inc(&paravirt_ticketlocks_enabled);
-
 	pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(xen_lock_spinning);
 	pv_lock_ops.unlock_kick = xen_unlock_kick;
 }
+static __init int xen_init_spinlocks_jump(void)
+{
+	if (!xen_pvspin)
+		return 0;
+
+	static_key_slow_inc(&paravirt_ticketlocks_enabled);
+	return 0;
+}
+early_initcall(xen_init_spinlocks_jump);
 
 static __init int xen_parse_nopvspin(char *arg)
 {
-- 
1.8.1.4


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

* Re: [PATCH] xen: Do not enable spinlocks before jump_label_init() has executed
  2013-09-13  2:29 [PATCH] xen: Do not enable spinlocks before jump_label_init() has executed Boris Ostrovsky
@ 2013-09-13  2:47 ` Steven Rostedt
  2013-09-24 19:50   ` Boris Ostrovsky
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2013-09-13  2:47 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: hpa, david.vrabel, linux-kernel, Stefano.Stabellini,
	Konrad Rzeszutek Wilk

On Thu, 12 Sep 2013 22:29:44 -0400
Boris Ostrovsky <boris.ostrovsky@oracle.com> wrote:

> From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> 
> xen_init_spinlocks() currently calls static_key_slow_inc() before
> jump_label_init() is invoked. When CONFIG_JUMP_LABEL is set (which usually is
> the case) the effect of this static_key_slow_inc() is deferred until after
> jump_label_init(). This is different from when CONFIG_JUMP_LABEL is not set, in
> which case the key is set immediately. Thus, depending on the value of config
> option, we may observe different behavior.
> 
> In addition, when we come to __jump_label_transform() from jump_label_init(),
> the key (paravirt_ticketlocks_enabled) is already enabled. On processors where
> ideal_nop is not the same as default_nop this will cause a BUG() since it is
> expected that before a key is enabled the latter is replaced by the former
> during initialization.
> 
> To address this problem we need to move
> static_key_slow_inc(&paravirt_ticketlocks_enabled) so that it is called
> after jump_label_init(). We also need to make sure that this is done before
> other cpus start to boot. early_initcall appears to be  a good place to do so.
> (Note that we cannot move whole xen_init_spinlocks() there since pv_lock_ops
> need to be set before alternative_instructions() runs.)
> 

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

Peter,

This fixes a regression in 3.12 against xen. Please pull and push to
Linus sometime soon.

Thanks,

-- Steve

> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> ---
>  arch/x86/xen/spinlock.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
> index 253f63f..d90628d 100644
> --- a/arch/x86/xen/spinlock.c
> +++ b/arch/x86/xen/spinlock.c
> @@ -267,11 +267,18 @@ void __init xen_init_spinlocks(void)
>  		return;
>  	}
>  
> -	static_key_slow_inc(&paravirt_ticketlocks_enabled);
> -
>  	pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(xen_lock_spinning);
>  	pv_lock_ops.unlock_kick = xen_unlock_kick;
>  }
> +static __init int xen_init_spinlocks_jump(void)
> +{
> +	if (!xen_pvspin)
> +		return 0;
> +
> +	static_key_slow_inc(&paravirt_ticketlocks_enabled);
> +	return 0;
> +}
> +early_initcall(xen_init_spinlocks_jump);
>  
>  static __init int xen_parse_nopvspin(char *arg)
>  {


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

* Re: [PATCH] xen: Do not enable spinlocks before jump_label_init() has executed
  2013-09-13  2:47 ` Steven Rostedt
@ 2013-09-24 19:50   ` Boris Ostrovsky
  2013-09-24 20:11     ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 4+ messages in thread
From: Boris Ostrovsky @ 2013-09-24 19:50 UTC (permalink / raw)
  To: hpa
  Cc: Steven Rostedt, david.vrabel, linux-kernel, Stefano.Stabellini,
	Konrad Rzeszutek Wilk

On 09/12/2013 10:47 PM, Steven Rostedt wrote:
> On Thu, 12 Sep 2013 22:29:44 -0400
> Boris Ostrovsky <boris.ostrovsky@oracle.com> wrote:
>
>> From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>>
>> xen_init_spinlocks() currently calls static_key_slow_inc() before
>> jump_label_init() is invoked. When CONFIG_JUMP_LABEL is set (which usually is
>> the case) the effect of this static_key_slow_inc() is deferred until after
>> jump_label_init(). This is different from when CONFIG_JUMP_LABEL is not set, in
>> which case the key is set immediately. Thus, depending on the value of config
>> option, we may observe different behavior.
>>
>> In addition, when we come to __jump_label_transform() from jump_label_init(),
>> the key (paravirt_ticketlocks_enabled) is already enabled. On processors where
>> ideal_nop is not the same as default_nop this will cause a BUG() since it is
>> expected that before a key is enabled the latter is replaced by the former
>> during initialization.
>>
>> To address this problem we need to move
>> static_key_slow_inc(&paravirt_ticketlocks_enabled) so that it is called
>> after jump_label_init(). We also need to make sure that this is done before
>> other cpus start to boot. early_initcall appears to be  a good place to do so.
>> (Note that we cannot move whole xen_init_spinlocks() there since pv_lock_ops
>> need to be set before alternative_instructions() runs.)
>>
> Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
>
> Peter,
>
> This fixes a regression in 3.12 against xen. Please pull and push to
> Linus sometime soon.

Peter,

Are you planning on taking this patch?

Thanks.
-boris


>
> Thanks,
>
> -- Steve
>
>> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>> ---
>>   arch/x86/xen/spinlock.c | 11 +++++++++--
>>   1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
>> index 253f63f..d90628d 100644
>> --- a/arch/x86/xen/spinlock.c
>> +++ b/arch/x86/xen/spinlock.c
>> @@ -267,11 +267,18 @@ void __init xen_init_spinlocks(void)
>>   		return;
>>   	}
>>   
>> -	static_key_slow_inc(&paravirt_ticketlocks_enabled);
>> -
>>   	pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(xen_lock_spinning);
>>   	pv_lock_ops.unlock_kick = xen_unlock_kick;
>>   }
>> +static __init int xen_init_spinlocks_jump(void)
>> +{
>> +	if (!xen_pvspin)
>> +		return 0;
>> +
>> +	static_key_slow_inc(&paravirt_ticketlocks_enabled);
>> +	return 0;
>> +}
>> +early_initcall(xen_init_spinlocks_jump);
>>   
>>   static __init int xen_parse_nopvspin(char *arg)
>>   {


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

* Re: [PATCH] xen: Do not enable spinlocks before jump_label_init() has executed
  2013-09-24 19:50   ` Boris Ostrovsky
@ 2013-09-24 20:11     ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 4+ messages in thread
From: Konrad Rzeszutek Wilk @ 2013-09-24 20:11 UTC (permalink / raw)
  To: Boris Ostrovsky
  Cc: hpa, Steven Rostedt, david.vrabel, linux-kernel, Stefano.Stabellini

On Tue, Sep 24, 2013 at 12:50:45PM -0700, Boris Ostrovsky wrote:
> On 09/12/2013 10:47 PM, Steven Rostedt wrote:
> >On Thu, 12 Sep 2013 22:29:44 -0400
> >Boris Ostrovsky <boris.ostrovsky@oracle.com> wrote:
> >
> >>From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> >>
> >>xen_init_spinlocks() currently calls static_key_slow_inc() before
> >>jump_label_init() is invoked. When CONFIG_JUMP_LABEL is set (which usually is
> >>the case) the effect of this static_key_slow_inc() is deferred until after
> >>jump_label_init(). This is different from when CONFIG_JUMP_LABEL is not set, in
> >>which case the key is set immediately. Thus, depending on the value of config
> >>option, we may observe different behavior.
> >>
> >>In addition, when we come to __jump_label_transform() from jump_label_init(),
> >>the key (paravirt_ticketlocks_enabled) is already enabled. On processors where
> >>ideal_nop is not the same as default_nop this will cause a BUG() since it is
> >>expected that before a key is enabled the latter is replaced by the former
> >>during initialization.
> >>
> >>To address this problem we need to move
> >>static_key_slow_inc(&paravirt_ticketlocks_enabled) so that it is called
> >>after jump_label_init(). We also need to make sure that this is done before
> >>other cpus start to boot. early_initcall appears to be  a good place to do so.
> >>(Note that we cannot move whole xen_init_spinlocks() there since pv_lock_ops
> >>need to be set before alternative_instructions() runs.)
> >>
> >Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
> >
> >Peter,
> >
> >This fixes a regression in 3.12 against xen. Please pull and push to
> >Linus sometime soon.
> 
> Peter,
> 
> Are you planning on taking this patch?

If he hasn't done yet (and I don't see a tip-bot email so I think the answer
is no) I can do it (as I am back from my mini vacation).

Thanks for the ping!

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

end of thread, other threads:[~2013-09-24 20:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-13  2:29 [PATCH] xen: Do not enable spinlocks before jump_label_init() has executed Boris Ostrovsky
2013-09-13  2:47 ` Steven Rostedt
2013-09-24 19:50   ` Boris Ostrovsky
2013-09-24 20:11     ` Konrad Rzeszutek Wilk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.