From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932217AbdJYHf0 (ORCPT ); Wed, 25 Oct 2017 03:35:26 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:35848 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751546AbdJYHfZ (ORCPT ); Wed, 25 Oct 2017 03:35:25 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="29579342" Subject: Re: [PATCH] paravirt/locks: avoid modifying static key before jump_label_init() To: Juergen Gross , , References: <20171023134948.24886-1-jgross@suse.com> <7223e00c-0fe6-8844-d0f2-a7cabfba9c03@suse.com> CC: , , , , From: Dou Liyang Message-ID: <1c852010-e9df-fac8-8970-6c60f769f40e@cn.fujitsu.com> Date: Wed, 25 Oct 2017 15:35:21 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <7223e00c-0fe6-8844-d0f2-a7cabfba9c03@suse.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.106] X-yoursite-MailScanner-ID: D9C264818486.AA94B X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: douly.fnst@cn.fujitsu.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Juergen, [...] >> I like your original method. >> So, I try to fix it by moving the native_pv_lock_init() from >> native_smp_prepare_boot_cpu() to native_smp_prepare_cpus(). > > Hmm, this might work, but the Xen case has to be modified (same for > my more general solution), as xen_init_spinlocks() is still modifying > the static key too early. And we can't move xen_init_spinlocks() to > smp_prepare_cpus() as this would be too late for the alternatives > patching. > Yes, Right. > So let me extend your patch a little bit to cover Xen, too. > Yes! How about moving the check of xen_pvspin into native_pv_lock_init() like below? Thanks, dou. ------------------------->8 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 041096b..b5f3ecb 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -119,7 +119,7 @@ DEFINE_STATIC_KEY_TRUE(virt_spin_lock_key); void __init native_pv_lock_init(void) { - if (!static_cpu_has(X86_FEATURE_HYPERVISOR)) + if (!static_cpu_has(X86_FEATURE_HYPERVISOR) || !xen_pvspin) static_branch_disable(&virt_spin_lock_key); } 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..8e0ec79 100644 --- a/arch/x86/xen/spinlock.c +++ b/arch/x86/xen/spinlock.c @@ -130,7 +130,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"); >> I hope it's useful to you. > > It really is, thanks. > > > Juergen > > >