From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932381AbdJ0RZI (ORCPT ); Fri, 27 Oct 2017 13:25:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:47730 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932190AbdJ0RZH (ORCPT ); Fri, 27 Oct 2017 13:25:07 -0400 Subject: Re: [PATCH][tip] x86/paravirt: Make the virt_spin_lock_key setup after jump_label_init() To: Vitaly Kuznetsov , Boris Petkov Cc: Dou Liyang , linux-kernel@vger.kernel.org, x86@kernel.org, xen-devel@lists.xenproject.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, boris.ostrovsky@oracle.com, luto@kernel.org References: <1509120120-5386-1-git-send-email-douly.fnst@cn.fujitsu.com> <87bmkszfeb.fsf@vitty.brq.redhat.com> From: Juergen Gross Message-ID: <5c60e12c-1900-cf45-0db9-e5b67b0920d2@suse.com> Date: Fri, 27 Oct 2017 19:25:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <87bmkszfeb.fsf@vitty.brq.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/10/17 19:09, Vitaly Kuznetsov wrote: > Boris Petkov writes: > >> On October 27, 2017 6:02:00 PM GMT+02:00, 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 >>> Suggested-by: Juergen Gross >>> Signed-off-by: Dou Liyang >>> --- >>> 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