Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2596603ybd; Thu, 27 Jun 2019 15:30:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqww2c6uSuGvOZUslOwZ0MCWdDG9CYr7LsmOkPy8y2tTzDseh9lpsqrK5g+4BKd6w4J5IlyP X-Received: by 2002:a17:90a:1b0c:: with SMTP id q12mr8963578pjq.76.1561674656693; Thu, 27 Jun 2019 15:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561674656; cv=none; d=google.com; s=arc-20160816; b=HajXe8BSrX6eUo9zE3VfPusSHedT3a+0lqPSQNA90ZmucOnvpjoxfID82PdnibuALm 5nUsNh3SJLx7uYv/OVIVL/uhzu+3h/i5u3VtH4u7DEbDK+89EPaI8ARvlcDk4og9YJEP fqoqrmK4mPWz19SUGw7i99O07iy2dQWD1XLWZgARszHvMVMVEir2TYHBS4ul4eDCwylG ofTCrYmW6D5xPxCym4zWQr8pON0jpyQqdoReQDKx89qQP/3w7Ift6qJDz/jdENqA1Yt/ h7l/eaGMrfgQDXxwtZ8RS/296HexLHS9EkriZ+JerYZ/TyDg2z4S5Ecocoqe++1jSFT7 GeJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YzY5VYK/LI60YYAM4d6tDfkgRA5BCFWE5ZcTTvi0hqE=; b=UvcE9NIeQh0VgdolW1fOw5PqMXtehUzZq0SU266KGhFNQ6yAll5Pw5piUkdF3qnhVp afFdnwsflKPbLjuFRO0WbzIS74ZF1cH2P1OkMWZ5bJ5o4gKOdebJrKM3DAjOt2MG9Ep7 PTOcGbnNEgLCwxvDXOQ8tVjbzJUqiMqMlAJUocSqjTxU2pKNJ4aC6Q72bJcGwamsppyD froWk4x/a96Y46SClfQfSL8fQGhzFh7OC7qP4yaQZkbtYL5DcQHLu47dpit05zGeBL7M kV2cHxRqUdCmVDmuhIKbfCl1c3yHxt9tvVnyZeoDJ297I+NcZgQt+aqUJ3HkiunXHLcG oKuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Owhjj5MU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si227426pji.109.2019.06.27.15.30.39; Thu, 27 Jun 2019 15:30:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Owhjj5MU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726702AbfF0W2x (ORCPT + 99 others); Thu, 27 Jun 2019 18:28:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:56326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726445AbfF0W2x (ORCPT ); Thu, 27 Jun 2019 18:28:53 -0400 Received: from localhost (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 542FE2063F; Thu, 27 Jun 2019 22:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561674532; bh=6gDuV+DVL5Bbj1QRS6t+kNeAHKtQQVMNQqIxE+766Lk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Owhjj5MUM+bk7m39E3qMZJQshMRs1inLMvVheIBkFQTyF1mnp8ZzEOlEORXuaAObe AiLVAMrJZMh39QZV0FMyLxhbhwTS09aSMZuyntRYJwA8vHGiH5h1bGgws0e2EAdF66 r1e6HA5Vs/cItxOEJOsnHPmiikj34gPmTPz2Ji3A= Date: Thu, 27 Jun 2019 18:28:51 -0400 From: Sasha Levin To: Zhenzhong Duan Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, bp@alien8.de, hpa@zytor.com, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, peterz@infradead.org, srinivas.eeda@oracle.com, Waiman Long , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Ingo Molnar , linux-hyperv@vger.kernel.org Subject: Re: [PATCH v2 6/7] locking/spinlocks, paravirt, hyperv: Correct the hv_nopvspin case Message-ID: <20190627222851.GC11506@sasha-vm> References: <1561377779-28036-1-git-send-email-zhenzhong.duan@oracle.com> <1561377779-28036-7-git-send-email-zhenzhong.duan@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <1561377779-28036-7-git-send-email-zhenzhong.duan@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 24, 2019 at 08:02:58PM +0800, Zhenzhong Duan wrote: >With the boot parameter "hv_nopvspin" specified a Hyperv guest should >not make use of paravirt spinlocks, but behave as if running on bare >metal. This is not true, however, as the qspinlock code will fall back >to a test-and-set scheme when it is detecting a hypervisor. > >In order to avoid this disable the virt_spin_lock_key. > >Same change for XEN is already in Commit e6fd28eb3522 >("locking/spinlocks, paravirt, xen: Correct the xen_nopvspin case") > >Signed-off-by: Zhenzhong Duan >Cc: Waiman Long >Cc: Peter Zijlstra (Intel) >Cc: "K. Y. Srinivasan" >Cc: Haiyang Zhang >Cc: Stephen Hemminger >Cc: Sasha Levin >Cc: Thomas Gleixner >Cc: Ingo Molnar >Cc: Borislav Petkov >Cc: linux-hyperv@vger.kernel.org >--- > arch/x86/hyperv/hv_spinlock.c | 3 +++ > 1 file changed, 3 insertions(+) > >diff --git a/arch/x86/hyperv/hv_spinlock.c b/arch/x86/hyperv/hv_spinlock.c >index 07f21a0..d90b4b0 100644 >--- a/arch/x86/hyperv/hv_spinlock.c >+++ b/arch/x86/hyperv/hv_spinlock.c >@@ -64,6 +64,9 @@ __visible bool hv_vcpu_is_preempted(int vcpu) > > void __init hv_init_spinlocks(void) > { >+ if (unlikely(!hv_pvspin)) >+ static_branch_disable(&virt_spin_lock_key); This should be combined in the conditional under it, which already attempts to disable PV spinlocks, note how hv_pvspin is checked there. hc_pvspin isn't the only reason we would disable PV spinlocks on hyperv. Also, there's no need for the unlikely() here, it's only getting called once... -- Thanks, Sasha