All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
@ 2017-10-27 16:02 Dou Liyang
  2017-10-27 16:52 ` Boris Petkov
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Dou Liyang @ 2017-10-27 16:02 UTC (permalink / raw)
  To: linux-kernel, x86, xen-devel
  Cc: tglx, mingo, hpa, jgross, boris.ostrovsky, bp, luto, vkuznets,
	Dou Liyang

Commit:

  9043442b43b1 ("locking/paravirt: Use new static key for controlling
  call of virt_spin_lock()")

set the static virt_spin_lock_key to a value before jump_label_init()
has been called, which will result in a WARN().

Move the native_pv_lock_init() into xx_smp_prepare_cpus(). Make the
setup later to avoid the WARN().

Reported-by: Juergen Gross <jgross@suse.com>
Suggested-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
---
 arch/x86/kernel/smpboot.c | 3 ++-
 arch/x86/xen/smp_pv.c     | 2 ++
 arch/x86/xen/spinlock.c   | 6 ++++--
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index aed1460..6b1335a 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1323,6 +1323,8 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
 	pr_info("CPU0: ");
 	print_cpu_info(&cpu_data(0));
 
+	native_pv_lock_init();
+
 	uv_system_init();
 
 	set_mtrr_aps_delayed_init();
@@ -1350,7 +1352,6 @@ void __init native_smp_prepare_boot_cpu(void)
 	/* already set me in cpu_online_mask in boot_cpu_init() */
 	cpumask_set_cpu(me, cpu_callout_mask);
 	cpu_set_state_online(me);
-	native_pv_lock_init();
 }
 
 void __init native_smp_cpus_done(unsigned int max_cpus)
diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
index 5147140..570b2bc 100644
--- a/arch/x86/xen/smp_pv.c
+++ b/arch/x86/xen/smp_pv.c
@@ -236,6 +236,8 @@ static void __init xen_pv_smp_prepare_cpus(unsigned int max_cpus)
 		xen_raw_printk(m);
 		panic(m);
 	}
+	native_pv_lock_init();
+
 	xen_init_lock_cpu(0);
 
 	smp_store_boot_cpu_info();
diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index e8ab80a..1e1462d 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -81,8 +81,11 @@ void xen_init_lock_cpu(int cpu)
 	int irq;
 	char *name;
 
-	if (!xen_pvspin)
+	if (!xen_pvspin) {
+		if (cpu == 0)
+			static_branch_disable(&virt_spin_lock_key);
 		return;
+	}
 
 	WARN(per_cpu(lock_kicker_irq, cpu) >= 0, "spinlock on CPU%d exists on IRQ%d!\n",
 	     cpu, per_cpu(lock_kicker_irq, cpu));
@@ -130,7 +133,6 @@ void __init xen_init_spinlocks(void)
 
 	if (!xen_pvspin) {
 		printk(KERN_DEBUG "xen: PV spinlocks disabled\n");
-		static_branch_disable(&virt_spin_lock_key);
 		return;
 	}
 	printk(KERN_DEBUG "xen: PV spinlocks enabled\n");
-- 
2.5.5

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

* Re: [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
  2017-10-27 16:02 [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init() Dou Liyang
  2017-10-27 16:52 ` Boris Petkov
@ 2017-10-27 16:52 ` Boris Petkov
  2017-10-27 17:09   ` Vitaly Kuznetsov
  2017-10-27 17:09   ` Vitaly Kuznetsov
  2017-10-27 17:27 ` Juergen Gross
  2017-10-27 17:27 ` Juergen Gross
  3 siblings, 2 replies; 14+ messages in thread
From: Boris Petkov @ 2017-10-27 16:52 UTC (permalink / raw)
  To: Dou Liyang, linux-kernel, x86, xen-devel
  Cc: tglx, mingo, hpa, jgross, boris.ostrovsky, luto, vkuznets

On October 27, 2017 6:02:00 PM GMT+02:00, Dou Liyang <douly.fnst@cn.fujitsu.com> wrote:
>Commit:
>
>  9043442b43b1 ("locking/paravirt: Use new static key for controlling
>  call of virt_spin_lock()")
>
>set the static virt_spin_lock_key to a value before jump_label_init()
>has been called, which will result in a WARN().
>
>Move the native_pv_lock_init() into xx_smp_prepare_cpus(). Make the
>setup later to avoid the WARN().
>
>Reported-by: Juergen Gross <jgross@suse.com>
>Suggested-by: Juergen Gross <jgross@suse.com>
>Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
>---
> arch/x86/kernel/smpboot.c | 3 ++-
> arch/x86/xen/smp_pv.c     | 2 ++
> arch/x86/xen/spinlock.c   | 6 ++++--
> 3 files changed, 8 insertions(+), 3 deletions(-)
>
>diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
>index aed1460..6b1335a 100644
>--- a/arch/x86/kernel/smpboot.c
>+++ b/arch/x86/kernel/smpboot.c
>@@ -1323,6 +1323,8 @@ void __init native_smp_prepare_cpus(unsigned int
>max_cpus)
> 	pr_info("CPU0: ");
> 	print_cpu_info(&cpu_data(0));
> 
>+	native_pv_lock_init();
>+
> 	uv_system_init();
> 
> 	set_mtrr_aps_delayed_init();
>@@ -1350,7 +1352,6 @@ void __init native_smp_prepare_boot_cpu(void)
> 	/* already set me in cpu_online_mask in boot_cpu_init() */
> 	cpumask_set_cpu(me, cpu_callout_mask);
> 	cpu_set_state_online(me);
>-	native_pv_lock_init();
> }
> 
> void __init native_smp_cpus_done(unsigned int max_cpus)
>diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
>index 5147140..570b2bc 100644
>--- a/arch/x86/xen/smp_pv.c
>+++ b/arch/x86/xen/smp_pv.c
>@@ -236,6 +236,8 @@ static void __init xen_pv_smp_prepare_cpus(unsigned
>int max_cpus)
> 		xen_raw_printk(m);
> 		panic(m);
> 	}
>+	native_pv_lock_init();
>+
> 	xen_init_lock_cpu(0);
> 
> 	smp_store_boot_cpu_info();
>diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
>index e8ab80a..1e1462d 100644
>--- a/arch/x86/xen/spinlock.c
>+++ b/arch/x86/xen/spinlock.c
>@@ -81,8 +81,11 @@ void xen_init_lock_cpu(int cpu)
> 	int irq;
> 	char *name;
> 
>-	if (!xen_pvspin)
>+	if (!xen_pvspin) {
>+		if (cpu == 0)
>+			static_branch_disable(&virt_spin_lock_key);

This is assuming CPU 0 is the boot cpu. I think you want boot_cpu_data.cpu_index here or whatever is used on xen to identify the BSP reliably. 


-- 
Sent from a small device: formatting sux and brevity is inevitable. 

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

* Re: [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
  2017-10-27 16:02 [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init() Dou Liyang
@ 2017-10-27 16:52 ` Boris Petkov
  2017-10-27 16:52 ` Boris Petkov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 14+ messages in thread
From: Boris Petkov @ 2017-10-27 16:52 UTC (permalink / raw)
  To: Dou Liyang, linux-kernel, x86, xen-devel
  Cc: jgross, vkuznets, mingo, luto, hpa, tglx, boris.ostrovsky

On October 27, 2017 6:02:00 PM GMT+02:00, Dou Liyang <douly.fnst@cn.fujitsu.com> wrote:
>Commit:
>
>  9043442b43b1 ("locking/paravirt: Use new static key for controlling
>  call of virt_spin_lock()")
>
>set the static virt_spin_lock_key to a value before jump_label_init()
>has been called, which will result in a WARN().
>
>Move the native_pv_lock_init() into xx_smp_prepare_cpus(). Make the
>setup later to avoid the WARN().
>
>Reported-by: Juergen Gross <jgross@suse.com>
>Suggested-by: Juergen Gross <jgross@suse.com>
>Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
>---
> arch/x86/kernel/smpboot.c | 3 ++-
> arch/x86/xen/smp_pv.c     | 2 ++
> arch/x86/xen/spinlock.c   | 6 ++++--
> 3 files changed, 8 insertions(+), 3 deletions(-)
>
>diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
>index aed1460..6b1335a 100644
>--- a/arch/x86/kernel/smpboot.c
>+++ b/arch/x86/kernel/smpboot.c
>@@ -1323,6 +1323,8 @@ void __init native_smp_prepare_cpus(unsigned int
>max_cpus)
> 	pr_info("CPU0: ");
> 	print_cpu_info(&cpu_data(0));
> 
>+	native_pv_lock_init();
>+
> 	uv_system_init();
> 
> 	set_mtrr_aps_delayed_init();
>@@ -1350,7 +1352,6 @@ void __init native_smp_prepare_boot_cpu(void)
> 	/* already set me in cpu_online_mask in boot_cpu_init() */
> 	cpumask_set_cpu(me, cpu_callout_mask);
> 	cpu_set_state_online(me);
>-	native_pv_lock_init();
> }
> 
> void __init native_smp_cpus_done(unsigned int max_cpus)
>diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
>index 5147140..570b2bc 100644
>--- a/arch/x86/xen/smp_pv.c
>+++ b/arch/x86/xen/smp_pv.c
>@@ -236,6 +236,8 @@ static void __init xen_pv_smp_prepare_cpus(unsigned
>int max_cpus)
> 		xen_raw_printk(m);
> 		panic(m);
> 	}
>+	native_pv_lock_init();
>+
> 	xen_init_lock_cpu(0);
> 
> 	smp_store_boot_cpu_info();
>diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
>index e8ab80a..1e1462d 100644
>--- a/arch/x86/xen/spinlock.c
>+++ b/arch/x86/xen/spinlock.c
>@@ -81,8 +81,11 @@ void xen_init_lock_cpu(int cpu)
> 	int irq;
> 	char *name;
> 
>-	if (!xen_pvspin)
>+	if (!xen_pvspin) {
>+		if (cpu == 0)
>+			static_branch_disable(&virt_spin_lock_key);

This is assuming CPU 0 is the boot cpu. I think you want boot_cpu_data.cpu_index here or whatever is used on xen to identify the BSP reliably. 


-- 
Sent from a small device: formatting sux and brevity is inevitable. 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
  2017-10-27 16:52 ` Boris Petkov
  2017-10-27 17:09   ` Vitaly Kuznetsov
@ 2017-10-27 17:09   ` Vitaly Kuznetsov
  2017-10-27 17:25     ` Juergen Gross
  2017-10-27 17:25     ` Juergen Gross
  1 sibling, 2 replies; 14+ messages in thread
From: Vitaly Kuznetsov @ 2017-10-27 17:09 UTC (permalink / raw)
  To: Boris Petkov
  Cc: Dou Liyang, linux-kernel, x86, xen-devel, tglx, mingo, hpa,
	jgross, boris.ostrovsky, luto

Boris Petkov <bp@suse.de> writes:

> On October 27, 2017 6:02:00 PM GMT+02:00, Dou Liyang <douly.fnst@cn.fujitsu.com> wrote:
>>Commit:
>>
>>  9043442b43b1 ("locking/paravirt: Use new static key for controlling
>>  call of virt_spin_lock()")
>>
>>set the static virt_spin_lock_key to a value before jump_label_init()
>>has been called, which will result in a WARN().
>>
>>Move the native_pv_lock_init() into xx_smp_prepare_cpus(). Make the
>>setup later to avoid the WARN().
>>
>>Reported-by: Juergen Gross <jgross@suse.com>
>>Suggested-by: Juergen Gross <jgross@suse.com>
>>Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
>>---
>> arch/x86/kernel/smpboot.c | 3 ++-
>> arch/x86/xen/smp_pv.c     | 2 ++
>> arch/x86/xen/spinlock.c   | 6 ++++--
>> 3 files changed, 8 insertions(+), 3 deletions(-)
>>
>>diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
>>index aed1460..6b1335a 100644
>>--- a/arch/x86/kernel/smpboot.c
>>+++ b/arch/x86/kernel/smpboot.c
>>@@ -1323,6 +1323,8 @@ void __init native_smp_prepare_cpus(unsigned int
>>max_cpus)
>> 	pr_info("CPU0: ");
>> 	print_cpu_info(&cpu_data(0));
>> 
>>+	native_pv_lock_init();
>>+
>> 	uv_system_init();
>> 
>> 	set_mtrr_aps_delayed_init();
>>@@ -1350,7 +1352,6 @@ void __init native_smp_prepare_boot_cpu(void)
>> 	/* already set me in cpu_online_mask in boot_cpu_init() */
>> 	cpumask_set_cpu(me, cpu_callout_mask);
>> 	cpu_set_state_online(me);
>>-	native_pv_lock_init();
>> }
>> 
>> void __init native_smp_cpus_done(unsigned int max_cpus)
>>diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
>>index 5147140..570b2bc 100644
>>--- a/arch/x86/xen/smp_pv.c
>>+++ b/arch/x86/xen/smp_pv.c
>>@@ -236,6 +236,8 @@ static void __init xen_pv_smp_prepare_cpus(unsigned
>>int max_cpus)
>> 		xen_raw_printk(m);
>> 		panic(m);
>> 	}
>>+	native_pv_lock_init();
>>+
>> 	xen_init_lock_cpu(0);
>> 
>> 	smp_store_boot_cpu_info();
>>diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
>>index e8ab80a..1e1462d 100644
>>--- a/arch/x86/xen/spinlock.c
>>+++ b/arch/x86/xen/spinlock.c
>>@@ -81,8 +81,11 @@ void xen_init_lock_cpu(int cpu)
>> 	int irq;
>> 	char *name;
>> 
>>-	if (!xen_pvspin)
>>+	if (!xen_pvspin) {
>>+		if (cpu == 0)
>>+			static_branch_disable(&virt_spin_lock_key);
>
> This is assuming CPU 0 is the boot cpu. I think you want boot_cpu_data.cpu_index here or whatever is used on xen to identify the BSP reliably. 

It seems both PV and PVHVM call xen_init_lock_cpu(0) so 0 here is
Linux's idea of CPU id, not Xen's.

In case Xen's idea is needed xen_vcpu_id mapping should be used. But I
don't think it's the case here.

-- 
  Vitaly

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

* Re: [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
  2017-10-27 16:52 ` Boris Petkov
@ 2017-10-27 17:09   ` Vitaly Kuznetsov
  2017-10-27 17:09   ` Vitaly Kuznetsov
  1 sibling, 0 replies; 14+ messages in thread
From: Vitaly Kuznetsov @ 2017-10-27 17:09 UTC (permalink / raw)
  To: Boris Petkov
  Cc: jgross, Dou Liyang, x86, linux-kernel, mingo, luto, hpa,
	xen-devel, tglx, boris.ostrovsky

Boris Petkov <bp@suse.de> writes:

> On October 27, 2017 6:02:00 PM GMT+02:00, Dou Liyang <douly.fnst@cn.fujitsu.com> wrote:
>>Commit:
>>
>>  9043442b43b1 ("locking/paravirt: Use new static key for controlling
>>  call of virt_spin_lock()")
>>
>>set the static virt_spin_lock_key to a value before jump_label_init()
>>has been called, which will result in a WARN().
>>
>>Move the native_pv_lock_init() into xx_smp_prepare_cpus(). Make the
>>setup later to avoid the WARN().
>>
>>Reported-by: Juergen Gross <jgross@suse.com>
>>Suggested-by: Juergen Gross <jgross@suse.com>
>>Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
>>---
>> arch/x86/kernel/smpboot.c | 3 ++-
>> arch/x86/xen/smp_pv.c     | 2 ++
>> arch/x86/xen/spinlock.c   | 6 ++++--
>> 3 files changed, 8 insertions(+), 3 deletions(-)
>>
>>diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
>>index aed1460..6b1335a 100644
>>--- a/arch/x86/kernel/smpboot.c
>>+++ b/arch/x86/kernel/smpboot.c
>>@@ -1323,6 +1323,8 @@ void __init native_smp_prepare_cpus(unsigned int
>>max_cpus)
>> 	pr_info("CPU0: ");
>> 	print_cpu_info(&cpu_data(0));
>> 
>>+	native_pv_lock_init();
>>+
>> 	uv_system_init();
>> 
>> 	set_mtrr_aps_delayed_init();
>>@@ -1350,7 +1352,6 @@ void __init native_smp_prepare_boot_cpu(void)
>> 	/* already set me in cpu_online_mask in boot_cpu_init() */
>> 	cpumask_set_cpu(me, cpu_callout_mask);
>> 	cpu_set_state_online(me);
>>-	native_pv_lock_init();
>> }
>> 
>> void __init native_smp_cpus_done(unsigned int max_cpus)
>>diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
>>index 5147140..570b2bc 100644
>>--- a/arch/x86/xen/smp_pv.c
>>+++ b/arch/x86/xen/smp_pv.c
>>@@ -236,6 +236,8 @@ static void __init xen_pv_smp_prepare_cpus(unsigned
>>int max_cpus)
>> 		xen_raw_printk(m);
>> 		panic(m);
>> 	}
>>+	native_pv_lock_init();
>>+
>> 	xen_init_lock_cpu(0);
>> 
>> 	smp_store_boot_cpu_info();
>>diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
>>index e8ab80a..1e1462d 100644
>>--- a/arch/x86/xen/spinlock.c
>>+++ b/arch/x86/xen/spinlock.c
>>@@ -81,8 +81,11 @@ void xen_init_lock_cpu(int cpu)
>> 	int irq;
>> 	char *name;
>> 
>>-	if (!xen_pvspin)
>>+	if (!xen_pvspin) {
>>+		if (cpu == 0)
>>+			static_branch_disable(&virt_spin_lock_key);
>
> This is assuming CPU 0 is the boot cpu. I think you want boot_cpu_data.cpu_index here or whatever is used on xen to identify the BSP reliably. 

It seems both PV and PVHVM call xen_init_lock_cpu(0) so 0 here is
Linux's idea of CPU id, not Xen's.

In case Xen's idea is needed xen_vcpu_id mapping should be used. But I
don't think it's the case here.

-- 
  Vitaly

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
  2017-10-27 17:09   ` Vitaly Kuznetsov
@ 2017-10-27 17:25     ` Juergen Gross
  2017-10-28 10:55         ` Borislav Petkov
  2017-10-27 17:25     ` Juergen Gross
  1 sibling, 1 reply; 14+ messages in thread
From: Juergen Gross @ 2017-10-27 17:25 UTC (permalink / raw)
  To: Vitaly Kuznetsov, Boris Petkov
  Cc: Dou Liyang, linux-kernel, x86, xen-devel, tglx, mingo, hpa,
	boris.ostrovsky, luto

On 27/10/17 19:09, Vitaly Kuznetsov wrote:
> Boris Petkov <bp@suse.de> writes:
> 
>> On October 27, 2017 6:02:00 PM GMT+02:00, Dou Liyang <douly.fnst@cn.fujitsu.com> wrote:
>>> Commit:
>>>
>>>  9043442b43b1 ("locking/paravirt: Use new static key for controlling
>>>  call of virt_spin_lock()")
>>>
>>> set the static virt_spin_lock_key to a value before jump_label_init()
>>> has been called, which will result in a WARN().
>>>
>>> Move the native_pv_lock_init() into xx_smp_prepare_cpus(). Make the
>>> setup later to avoid the WARN().
>>>
>>> Reported-by: Juergen Gross <jgross@suse.com>
>>> Suggested-by: Juergen Gross <jgross@suse.com>
>>> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
>>> ---
>>> arch/x86/kernel/smpboot.c | 3 ++-
>>> arch/x86/xen/smp_pv.c     | 2 ++
>>> arch/x86/xen/spinlock.c   | 6 ++++--
>>> 3 files changed, 8 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
>>> index aed1460..6b1335a 100644
>>> --- a/arch/x86/kernel/smpboot.c
>>> +++ b/arch/x86/kernel/smpboot.c
>>> @@ -1323,6 +1323,8 @@ void __init native_smp_prepare_cpus(unsigned int
>>> max_cpus)
>>> 	pr_info("CPU0: ");
>>> 	print_cpu_info(&cpu_data(0));
>>>
>>> +	native_pv_lock_init();
>>> +
>>> 	uv_system_init();
>>>
>>> 	set_mtrr_aps_delayed_init();
>>> @@ -1350,7 +1352,6 @@ void __init native_smp_prepare_boot_cpu(void)
>>> 	/* already set me in cpu_online_mask in boot_cpu_init() */
>>> 	cpumask_set_cpu(me, cpu_callout_mask);
>>> 	cpu_set_state_online(me);
>>> -	native_pv_lock_init();
>>> }
>>>
>>> void __init native_smp_cpus_done(unsigned int max_cpus)
>>> diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
>>> index 5147140..570b2bc 100644
>>> --- a/arch/x86/xen/smp_pv.c
>>> +++ b/arch/x86/xen/smp_pv.c
>>> @@ -236,6 +236,8 @@ static void __init xen_pv_smp_prepare_cpus(unsigned
>>> int max_cpus)
>>> 		xen_raw_printk(m);
>>> 		panic(m);
>>> 	}
>>> +	native_pv_lock_init();
>>> +
>>> 	xen_init_lock_cpu(0);
>>>
>>> 	smp_store_boot_cpu_info();
>>> diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
>>> index e8ab80a..1e1462d 100644
>>> --- a/arch/x86/xen/spinlock.c
>>> +++ b/arch/x86/xen/spinlock.c
>>> @@ -81,8 +81,11 @@ void xen_init_lock_cpu(int cpu)
>>> 	int irq;
>>> 	char *name;
>>>
>>> -	if (!xen_pvspin)
>>> +	if (!xen_pvspin) {
>>> +		if (cpu == 0)
>>> +			static_branch_disable(&virt_spin_lock_key);
>>
>> This is assuming CPU 0 is the boot cpu. I think you want boot_cpu_data.cpu_index here or whatever is used on xen to identify the BSP reliably. 
> 
> It seems both PV and PVHVM call xen_init_lock_cpu(0) so 0 here is
> Linux's idea of CPU id, not Xen's.
> 
> In case Xen's idea is needed xen_vcpu_id mapping should be used. But I
> don't think it's the case here.
> 

Correct.


Juergen

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

* Re: [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
  2017-10-27 17:09   ` Vitaly Kuznetsov
  2017-10-27 17:25     ` Juergen Gross
@ 2017-10-27 17:25     ` Juergen Gross
  1 sibling, 0 replies; 14+ messages in thread
From: Juergen Gross @ 2017-10-27 17:25 UTC (permalink / raw)
  To: Vitaly Kuznetsov, Boris Petkov
  Cc: Dou Liyang, x86, linux-kernel, mingo, luto, hpa, xen-devel, tglx,
	boris.ostrovsky

On 27/10/17 19:09, Vitaly Kuznetsov wrote:
> Boris Petkov <bp@suse.de> writes:
> 
>> On October 27, 2017 6:02:00 PM GMT+02:00, Dou Liyang <douly.fnst@cn.fujitsu.com> wrote:
>>> Commit:
>>>
>>>  9043442b43b1 ("locking/paravirt: Use new static key for controlling
>>>  call of virt_spin_lock()")
>>>
>>> set the static virt_spin_lock_key to a value before jump_label_init()
>>> has been called, which will result in a WARN().
>>>
>>> Move the native_pv_lock_init() into xx_smp_prepare_cpus(). Make the
>>> setup later to avoid the WARN().
>>>
>>> Reported-by: Juergen Gross <jgross@suse.com>
>>> Suggested-by: Juergen Gross <jgross@suse.com>
>>> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
>>> ---
>>> arch/x86/kernel/smpboot.c | 3 ++-
>>> arch/x86/xen/smp_pv.c     | 2 ++
>>> arch/x86/xen/spinlock.c   | 6 ++++--
>>> 3 files changed, 8 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
>>> index aed1460..6b1335a 100644
>>> --- a/arch/x86/kernel/smpboot.c
>>> +++ b/arch/x86/kernel/smpboot.c
>>> @@ -1323,6 +1323,8 @@ void __init native_smp_prepare_cpus(unsigned int
>>> max_cpus)
>>> 	pr_info("CPU0: ");
>>> 	print_cpu_info(&cpu_data(0));
>>>
>>> +	native_pv_lock_init();
>>> +
>>> 	uv_system_init();
>>>
>>> 	set_mtrr_aps_delayed_init();
>>> @@ -1350,7 +1352,6 @@ void __init native_smp_prepare_boot_cpu(void)
>>> 	/* already set me in cpu_online_mask in boot_cpu_init() */
>>> 	cpumask_set_cpu(me, cpu_callout_mask);
>>> 	cpu_set_state_online(me);
>>> -	native_pv_lock_init();
>>> }
>>>
>>> void __init native_smp_cpus_done(unsigned int max_cpus)
>>> diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
>>> index 5147140..570b2bc 100644
>>> --- a/arch/x86/xen/smp_pv.c
>>> +++ b/arch/x86/xen/smp_pv.c
>>> @@ -236,6 +236,8 @@ static void __init xen_pv_smp_prepare_cpus(unsigned
>>> int max_cpus)
>>> 		xen_raw_printk(m);
>>> 		panic(m);
>>> 	}
>>> +	native_pv_lock_init();
>>> +
>>> 	xen_init_lock_cpu(0);
>>>
>>> 	smp_store_boot_cpu_info();
>>> diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
>>> index e8ab80a..1e1462d 100644
>>> --- a/arch/x86/xen/spinlock.c
>>> +++ b/arch/x86/xen/spinlock.c
>>> @@ -81,8 +81,11 @@ void xen_init_lock_cpu(int cpu)
>>> 	int irq;
>>> 	char *name;
>>>
>>> -	if (!xen_pvspin)
>>> +	if (!xen_pvspin) {
>>> +		if (cpu == 0)
>>> +			static_branch_disable(&virt_spin_lock_key);
>>
>> This is assuming CPU 0 is the boot cpu. I think you want boot_cpu_data.cpu_index here or whatever is used on xen to identify the BSP reliably. 
> 
> It seems both PV and PVHVM call xen_init_lock_cpu(0) so 0 here is
> Linux's idea of CPU id, not Xen's.
> 
> In case Xen's idea is needed xen_vcpu_id mapping should be used. But I
> don't think it's the case here.
> 

Correct.


Juergen

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
  2017-10-27 16:02 [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init() Dou Liyang
                   ` (2 preceding siblings ...)
  2017-10-27 17:27 ` Juergen Gross
@ 2017-10-27 17:27 ` Juergen Gross
  3 siblings, 0 replies; 14+ messages in thread
From: Juergen Gross @ 2017-10-27 17:27 UTC (permalink / raw)
  To: Dou Liyang, linux-kernel, x86, xen-devel
  Cc: tglx, mingo, hpa, boris.ostrovsky, bp, luto, vkuznets

On 27/10/17 18:02, Dou Liyang wrote:
> Commit:
> 
>   9043442b43b1 ("locking/paravirt: Use new static key for controlling
>   call of virt_spin_lock()")
> 
> set the static virt_spin_lock_key to a value before jump_label_init()
> has been called, which will result in a WARN().
> 
> Move the native_pv_lock_init() into xx_smp_prepare_cpus(). Make the
> setup later to avoid the WARN().
> 
> Reported-by: Juergen Gross <jgross@suse.com>
> Suggested-by: Juergen Gross <jgross@suse.com>
> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
> ---
>  arch/x86/kernel/smpboot.c | 3 ++-
>  arch/x86/xen/smp_pv.c     | 2 ++
>  arch/x86/xen/spinlock.c   | 6 ++++--
>  3 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
> index aed1460..6b1335a 100644
> --- a/arch/x86/kernel/smpboot.c
> +++ b/arch/x86/kernel/smpboot.c
> @@ -1323,6 +1323,8 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
>  	pr_info("CPU0: ");
>  	print_cpu_info(&cpu_data(0));
>  
> +	native_pv_lock_init();
> +
>  	uv_system_init();
>  
>  	set_mtrr_aps_delayed_init();
> @@ -1350,7 +1352,6 @@ void __init native_smp_prepare_boot_cpu(void)
>  	/* already set me in cpu_online_mask in boot_cpu_init() */
>  	cpumask_set_cpu(me, cpu_callout_mask);
>  	cpu_set_state_online(me);
> -	native_pv_lock_init();
>  }
>  
>  void __init native_smp_cpus_done(unsigned int max_cpus)
> diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
> index 5147140..570b2bc 100644
> --- a/arch/x86/xen/smp_pv.c
> +++ b/arch/x86/xen/smp_pv.c
> @@ -236,6 +236,8 @@ static void __init xen_pv_smp_prepare_cpus(unsigned int max_cpus)
>  		xen_raw_printk(m);
>  		panic(m);
>  	}
> +	native_pv_lock_init();
> +

This can be removed, as for a Xen domain native_pv_lock_init() is a nop.

With that:

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen

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

* Re: [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
  2017-10-27 16:02 [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init() Dou Liyang
  2017-10-27 16:52 ` Boris Petkov
  2017-10-27 16:52 ` Boris Petkov
@ 2017-10-27 17:27 ` Juergen Gross
  2017-10-27 17:27 ` Juergen Gross
  3 siblings, 0 replies; 14+ messages in thread
From: Juergen Gross @ 2017-10-27 17:27 UTC (permalink / raw)
  To: Dou Liyang, linux-kernel, x86, xen-devel
  Cc: vkuznets, mingo, luto, hpa, tglx, bp, boris.ostrovsky

On 27/10/17 18:02, Dou Liyang wrote:
> Commit:
> 
>   9043442b43b1 ("locking/paravirt: Use new static key for controlling
>   call of virt_spin_lock()")
> 
> set the static virt_spin_lock_key to a value before jump_label_init()
> has been called, which will result in a WARN().
> 
> Move the native_pv_lock_init() into xx_smp_prepare_cpus(). Make the
> setup later to avoid the WARN().
> 
> Reported-by: Juergen Gross <jgross@suse.com>
> Suggested-by: Juergen Gross <jgross@suse.com>
> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
> ---
>  arch/x86/kernel/smpboot.c | 3 ++-
>  arch/x86/xen/smp_pv.c     | 2 ++
>  arch/x86/xen/spinlock.c   | 6 ++++--
>  3 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
> index aed1460..6b1335a 100644
> --- a/arch/x86/kernel/smpboot.c
> +++ b/arch/x86/kernel/smpboot.c
> @@ -1323,6 +1323,8 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
>  	pr_info("CPU0: ");
>  	print_cpu_info(&cpu_data(0));
>  
> +	native_pv_lock_init();
> +
>  	uv_system_init();
>  
>  	set_mtrr_aps_delayed_init();
> @@ -1350,7 +1352,6 @@ void __init native_smp_prepare_boot_cpu(void)
>  	/* already set me in cpu_online_mask in boot_cpu_init() */
>  	cpumask_set_cpu(me, cpu_callout_mask);
>  	cpu_set_state_online(me);
> -	native_pv_lock_init();
>  }
>  
>  void __init native_smp_cpus_done(unsigned int max_cpus)
> diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
> index 5147140..570b2bc 100644
> --- a/arch/x86/xen/smp_pv.c
> +++ b/arch/x86/xen/smp_pv.c
> @@ -236,6 +236,8 @@ static void __init xen_pv_smp_prepare_cpus(unsigned int max_cpus)
>  		xen_raw_printk(m);
>  		panic(m);
>  	}
> +	native_pv_lock_init();
> +

This can be removed, as for a Xen domain native_pv_lock_init() is a nop.

With that:

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
  2017-10-27 17:25     ` Juergen Gross
@ 2017-10-28 10:55         ` Borislav Petkov
  0 siblings, 0 replies; 14+ messages in thread
From: Borislav Petkov @ 2017-10-28 10:55 UTC (permalink / raw)
  To: Juergen Gross
  Cc: Vitaly Kuznetsov, Dou Liyang, linux-kernel, x86, xen-devel, tglx,
	mingo, hpa, boris.ostrovsky, luto

On Fri, Oct 27, 2017 at 07:25:04PM +0200, Juergen Gross wrote:
> >> This is assuming CPU 0 is the boot cpu. I think you want boot_cpu_data.cpu_index here or whatever is used on xen to identify the BSP reliably. 
> > 
> > It seems both PV and PVHVM call xen_init_lock_cpu(0) so 0 here is
> > Linux's idea of CPU id, not Xen's.
> > 
> > In case Xen's idea is needed xen_vcpu_id mapping should be used. But I
> > don't think it's the case here.
> > 
> 
> Correct.

If it is Linux's idea of the BSP, then you need to check against
boot_cpu_data.cpu_index.

-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

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

* Re: [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
@ 2017-10-28 10:55         ` Borislav Petkov
  0 siblings, 0 replies; 14+ messages in thread
From: Borislav Petkov @ 2017-10-28 10:55 UTC (permalink / raw)
  To: Juergen Gross
  Cc: Dou Liyang, boris.ostrovsky, x86, linux-kernel, mingo, luto, hpa,
	xen-devel, Vitaly Kuznetsov, tglx

On Fri, Oct 27, 2017 at 07:25:04PM +0200, Juergen Gross wrote:
> >> This is assuming CPU 0 is the boot cpu. I think you want boot_cpu_data.cpu_index here or whatever is used on xen to identify the BSP reliably. 
> > 
> > It seems both PV and PVHVM call xen_init_lock_cpu(0) so 0 here is
> > Linux's idea of CPU id, not Xen's.
> > 
> > In case Xen's idea is needed xen_vcpu_id mapping should be used. But I
> > don't think it's the case here.
> > 
> 
> Correct.

If it is Linux's idea of the BSP, then you need to check against
boot_cpu_data.cpu_index.

-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
  2017-10-28 10:55         ` Borislav Petkov
  (?)
@ 2017-10-29 12:15         ` Juergen Gross
  -1 siblings, 0 replies; 14+ messages in thread
From: Juergen Gross @ 2017-10-29 12:15 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Vitaly Kuznetsov, Dou Liyang, linux-kernel, x86, xen-devel, tglx,
	mingo, hpa, boris.ostrovsky, luto

On 28/10/17 12:55, Borislav Petkov wrote:
> On Fri, Oct 27, 2017 at 07:25:04PM +0200, Juergen Gross wrote:
>>>> This is assuming CPU 0 is the boot cpu. I think you want boot_cpu_data.cpu_index here or whatever is used on xen to identify the BSP reliably. 
>>>
>>> It seems both PV and PVHVM call xen_init_lock_cpu(0) so 0 here is
>>> Linux's idea of CPU id, not Xen's.
>>>
>>> In case Xen's idea is needed xen_vcpu_id mapping should be used. But I
>>> don't think it's the case here.
>>>
>>
>> Correct.
> 
> If it is Linux's idea of the BSP, then you need to check against
> boot_cpu_data.cpu_index.

The idea is to set the static key on the first call of
xen_init_lock_cpu(). As this first call is done with 0 as parameter
the correct check is against 0.


Juergen

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

* Re: [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
  2017-10-28 10:55         ` Borislav Petkov
  (?)
  (?)
@ 2017-10-29 12:15         ` Juergen Gross
  -1 siblings, 0 replies; 14+ messages in thread
From: Juergen Gross @ 2017-10-29 12:15 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: Dou Liyang, boris.ostrovsky, x86, linux-kernel, mingo, luto, hpa,
	xen-devel, Vitaly Kuznetsov, tglx

On 28/10/17 12:55, Borislav Petkov wrote:
> On Fri, Oct 27, 2017 at 07:25:04PM +0200, Juergen Gross wrote:
>>>> This is assuming CPU 0 is the boot cpu. I think you want boot_cpu_data.cpu_index here or whatever is used on xen to identify the BSP reliably. 
>>>
>>> It seems both PV and PVHVM call xen_init_lock_cpu(0) so 0 here is
>>> Linux's idea of CPU id, not Xen's.
>>>
>>> In case Xen's idea is needed xen_vcpu_id mapping should be used. But I
>>> don't think it's the case here.
>>>
>>
>> Correct.
> 
> If it is Linux's idea of the BSP, then you need to check against
> boot_cpu_data.cpu_index.

The idea is to set the static key on the first call of
xen_init_lock_cpu(). As this first call is done with 0 as parameter
the correct check is against 0.


Juergen

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init()
@ 2017-10-27 16:02 Dou Liyang
  0 siblings, 0 replies; 14+ messages in thread
From: Dou Liyang @ 2017-10-27 16:02 UTC (permalink / raw)
  To: linux-kernel, x86, xen-devel
  Cc: jgross, Dou Liyang, vkuznets, mingo, luto, hpa, tglx, bp,
	boris.ostrovsky

Commit:

  9043442b43b1 ("locking/paravirt: Use new static key for controlling
  call of virt_spin_lock()")

set the static virt_spin_lock_key to a value before jump_label_init()
has been called, which will result in a WARN().

Move the native_pv_lock_init() into xx_smp_prepare_cpus(). Make the
setup later to avoid the WARN().

Reported-by: Juergen Gross <jgross@suse.com>
Suggested-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>
---
 arch/x86/kernel/smpboot.c | 3 ++-
 arch/x86/xen/smp_pv.c     | 2 ++
 arch/x86/xen/spinlock.c   | 6 ++++--
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index aed1460..6b1335a 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1323,6 +1323,8 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
 	pr_info("CPU0: ");
 	print_cpu_info(&cpu_data(0));
 
+	native_pv_lock_init();
+
 	uv_system_init();
 
 	set_mtrr_aps_delayed_init();
@@ -1350,7 +1352,6 @@ void __init native_smp_prepare_boot_cpu(void)
 	/* already set me in cpu_online_mask in boot_cpu_init() */
 	cpumask_set_cpu(me, cpu_callout_mask);
 	cpu_set_state_online(me);
-	native_pv_lock_init();
 }
 
 void __init native_smp_cpus_done(unsigned int max_cpus)
diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
index 5147140..570b2bc 100644
--- a/arch/x86/xen/smp_pv.c
+++ b/arch/x86/xen/smp_pv.c
@@ -236,6 +236,8 @@ static void __init xen_pv_smp_prepare_cpus(unsigned int max_cpus)
 		xen_raw_printk(m);
 		panic(m);
 	}
+	native_pv_lock_init();
+
 	xen_init_lock_cpu(0);
 
 	smp_store_boot_cpu_info();
diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index e8ab80a..1e1462d 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -81,8 +81,11 @@ void xen_init_lock_cpu(int cpu)
 	int irq;
 	char *name;
 
-	if (!xen_pvspin)
+	if (!xen_pvspin) {
+		if (cpu == 0)
+			static_branch_disable(&virt_spin_lock_key);
 		return;
+	}
 
 	WARN(per_cpu(lock_kicker_irq, cpu) >= 0, "spinlock on CPU%d exists on IRQ%d!\n",
 	     cpu, per_cpu(lock_kicker_irq, cpu));
@@ -130,7 +133,6 @@ void __init xen_init_spinlocks(void)
 
 	if (!xen_pvspin) {
 		printk(KERN_DEBUG "xen: PV spinlocks disabled\n");
-		static_branch_disable(&virt_spin_lock_key);
 		return;
 	}
 	printk(KERN_DEBUG "xen: PV spinlocks enabled\n");
-- 
2.5.5




_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

end of thread, other threads:[~2017-10-29 12:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-27 16:02 [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init() Dou Liyang
2017-10-27 16:52 ` Boris Petkov
2017-10-27 16:52 ` Boris Petkov
2017-10-27 17:09   ` Vitaly Kuznetsov
2017-10-27 17:09   ` Vitaly Kuznetsov
2017-10-27 17:25     ` Juergen Gross
2017-10-28 10:55       ` Borislav Petkov
2017-10-28 10:55         ` Borislav Petkov
2017-10-29 12:15         ` Juergen Gross
2017-10-29 12:15         ` Juergen Gross
2017-10-27 17:25     ` Juergen Gross
2017-10-27 17:27 ` Juergen Gross
2017-10-27 17:27 ` Juergen Gross
  -- strict thread matches above, loose matches on Subject: below --
2017-10-27 16:02 Dou Liyang

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.