Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1810475ybd; Thu, 27 Jun 2019 01:55:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1oKFAKU+YC0nuY+xIY1kei11QTrGbGI8kRN1rHmoJwHlSvEvNRa6QJXRguNf7v2tsL6Cj X-Received: by 2002:a17:902:24c:: with SMTP id 70mr3354831plc.2.1561625752017; Thu, 27 Jun 2019 01:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561625752; cv=none; d=google.com; s=arc-20160816; b=DHjCdWA/gZLSH7sc4ou5j2eeL1cuxkT++HP+uGSrcRFI79skRhwkyvhC1WnZ6Vgo9J ekNDWKV/iL+a49C/wB9zXlC9DUltSQ4xb3LoVWjdI1NPo+Npa1kjWHBF5PYWB0N2XNv3 w/6QEGFyjZqVyuZjoxCES6o+C2RIfh8HyhlDZStwgW8/PV3UrZF4AAWBZPJbDta6LZGX t2DsoHgG9CPVuT05ncxUsovWic9KEAoEUgvbfBzIdR9A0pcxxcfLB0O4Ww8kp0ddtVY3 8TRlhGx7bzc+GJWZ0J5dm3Joftb9zy429704SCQF8NjKNkNpNRH29tzQaPO6Jtp5Qai7 qF9A== 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 :dkim-signature; bh=5KptyXNJmsTfP77XZt6SnuUAhHI9DQzGxKm5f7pgB/c=; b=M+gl2k8PcYbe9MLKczqBTGkeqxpKHhpljTjDFPh2IzinCVX59Lc9k4aTf1S7K3hys5 t5p9exjjJ8ZmHm0iDP/PrBY3XU4oMGMpA84oO7Gl/o/h8U6to1ZqE4T9wemTusc3asYs 9D71no74KJyx5+ryxsA5BN5EklFYEWevk5LUXFNfU23fS2LIqoXGUCTOaoL/bcdndLY+ 9w5xSVXhWdyDFLccQ8ZlhG+nfpX90Re4PqsPqRxgEwNZgCLr1SWszhEOb192xshAPxdR DjUQB7PQadqo2vy9ZKGxhiTpcQbou7PHrzJlkskVHATPQE+0syQVW1NC+QUss8EsR0l2 HJVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ZLYYb7UF; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 8si2168850pfv.149.2019.06.27.01.55.32; Thu, 27 Jun 2019 01:55:52 -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=@oracle.com header.s=corp-2018-07-02 header.b=ZLYYb7UF; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726578AbfF0IzH (ORCPT + 99 others); Thu, 27 Jun 2019 04:55:07 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:41116 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725385AbfF0IzH (ORCPT ); Thu, 27 Jun 2019 04:55:07 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5R8sCA5058141; Thu, 27 Jun 2019 08:54:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=5KptyXNJmsTfP77XZt6SnuUAhHI9DQzGxKm5f7pgB/c=; b=ZLYYb7UFwgWFaRYyu6JpYhO5fd6M2quAU8xGVS5kQ8hcr2oFJ38wen5HoT81YUMJpqyE 6oxiA5DRsjp4irhvb5WgbndwNQyfZx6wtw3Cv/VgPxTsen4zZKRjvKtrqdlmAZG59DPc RZeeoQEUXg3IVo2If1FgItoTJxeaYPqssea6Ukl20L4ejILxLuSZosnH1LQDNDYEUpVF FWCdid540riv/M6bRtOirnUh57w6PhS6Erf3GFLjcgjkd1oRd0yTvZoHGSv2odX5K+wZ 09yg2cXJ4Ce1Awma+6PcOTpAB/qWNsZrNlGnyw7ILBzbYUCr50WkAgWV1vp/uf45P5my jA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2t9c9py1ks-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Jun 2019 08:54:23 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5R8pvea017707; Thu, 27 Jun 2019 08:52:23 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2t99f4w3j3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 27 Jun 2019 08:52:23 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5R8qLWd027247; Thu, 27 Jun 2019 08:52:21 GMT Received: from z2.cn.oracle.com (/10.182.69.87) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 27 Jun 2019 01:52:20 -0700 From: Zhenzhong Duan To: linux-kernel@vger.kernel.org Cc: Zhenzhong Duan , Waiman Long , "Peter Zijlstra (Intel)" , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Sasha Levin , Thomas Gleixner , Ingo Molnar , Borislav Petkov , linux-hyperv@vger.kernel.org Subject: [PATCH RESEND] locking/spinlocks, paravirt, hyperv: Correct the hv_nopvspin case Date: Wed, 26 Jun 2019 16:56:01 +0800 Message-Id: <1561539361-29313-1-git-send-email-zhenzhong.duan@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9300 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906270104 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9300 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906270105 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); + if (!hv_pvspin || !apic || !(ms_hyperv.hints & HV_X64_CLUSTER_IPI_RECOMMENDED) || !(ms_hyperv.features & HV_X64_MSR_GUEST_IDLE_AVAILABLE)) { -- 1.8.3.1