Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1716667imm; Thu, 19 Jul 2018 06:49:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfvyz6eXDoJsC6sZELoY39eiTgkLtAVHrU8ZMDSa4jIelxJKHrAmzhFXBtVirvmyhOl6dP2 X-Received: by 2002:a63:b74a:: with SMTP id w10-v6mr10017259pgt.266.1532008156634; Thu, 19 Jul 2018 06:49:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532008156; cv=none; d=google.com; s=arc-20160816; b=x9APPuLTvKLL1AwmBm/YxN/xcy44iNpbuEJhc+qbzrjfVo7m+8AzCP+ZjsnabcHR5n Wa8UCxqNk0SuXnC8l+4RltkPguYe/woYaEWDtVDISrVe8psPAr+cb85EAR8dYpXRqEII /St95qiOdbNy223T6YqPFpqs7ahNZvN7BIW7TyP/MJvoba7Af64Az9lsukyVe2X3b/Nl d8aTjOaCU3vujqp+qf17rtuJMXq3sAApEZyox/1mzf6R3wZFukMoU6OiOSG5kkgrL2dP qBVWP02CrdUVMOfjmD4XFRyRj7nGcKEWiCYWXU6u/BgIlRe0Adxd5vS4lkpOEzjWb31W VcJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8NhJdN2pGywVGBkWelnmRxIEK+vkxQxIBx4cwSIRH4E=; b=SU0AqiwMj/SZMhcUMUuf0tt57upG2PiG8J2SIR6eVcU2MevubGPqD96MY+5AchSp+f 4fnTvwVyaP5oqEcvlMbvD5qmMon+2HiIqpMdEjVhMvCV3tZTT0Al1/Zt+ixUHPqEXtsJ 5Wq93lC4q35CHWzCrP4HJuQMGFqQkYQtHxr5Eo95n0oKjUo9q+8FZFnpWZ5Y/TdWfI2F 4hnxVn76cO+toqwZAmEVWVa946k02HFk82kavk285H6ElewNpiIL3J0qk1u0drgR29FN n2zQMUcsAacG9Dpt/qSLVt4/ivI062RKMg6mK8Zgt+Gi9SgKk5Ub4xrUtWl6RusG0RuL xgbA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n34-v6si5790034pgm.28.2018.07.19.06.49.01; Thu, 19 Jul 2018 06:49:16 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731600AbeGSObp (ORCPT + 99 others); Thu, 19 Jul 2018 10:31:45 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:32906 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730433AbeGSObo (ORCPT ); Thu, 19 Jul 2018 10:31:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39AED401CE8B; Thu, 19 Jul 2018 13:48:29 +0000 (UTC) Received: from llong.com (dhcp-17-175.bos.redhat.com [10.18.17.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD3F62026E0E; Thu, 19 Jul 2018 13:48:28 +0000 (UTC) From: Waiman Long To: Boris Ostrovsky , Juergen Gross , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" Cc: x86@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Konrad Rzeszutek Wilk , Waiman Long Subject: [PATCH] xen/spinlock: Don't use pvqspinlock if only 1 vCPU Date: Thu, 19 Jul 2018 09:48:20 -0400 Message-Id: <1532008100-26922-1-git-send-email-longman@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 19 Jul 2018 13:48:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 19 Jul 2018 13:48:29 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'longman@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On a VM with only 1 vCPU, the locking fast paths will always be successful. In this case, there is no need to use the the PV qspinlock code which has higher overhead on the unlock side than the native qspinlock code. Signed-off-by: Waiman Long --- arch/x86/xen/spinlock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c index cd97a62..38f47ae 100644 --- a/arch/x86/xen/spinlock.c +++ b/arch/x86/xen/spinlock.c @@ -130,7 +130,8 @@ void xen_uninit_lock_cpu(int cpu) void __init xen_init_spinlocks(void) { - if (!xen_pvspin) { + /* Don't need to use pvqspinlock code if there is only 1 vCPU. */ + if (!xen_pvspin || num_possible_cpus() == 1) { printk(KERN_DEBUG "xen: PV spinlocks disabled\n"); return; } -- 1.8.3.1