Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp562751imm; Thu, 13 Sep 2018 04:25:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY8Z5g1gvnhd077SZtV9RbExZP2zsOc3xnm/LAXm8u+S++jG2qfD7ek8qqrgH3Vdp6eZVSK X-Received: by 2002:a17:902:934a:: with SMTP id g10-v6mr6796394plp.121.1536837905703; Thu, 13 Sep 2018 04:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536837905; cv=none; d=google.com; s=arc-20160816; b=fipwqotEHTRE+4VYcFWppUaG+DlnsQzTXfP2uJsavnJIGMQLo/lGdKekJXxFiNV7Fu 12OmJCD1OOEs3sh2b6JNWucHFo8/kx4aftG8NKDodP1ecgCWj6dgKWQcnETO6HuSs6WT 4u87bSSZRJ0hy7P7K82EruE6ZTng1F2e+BQiqNrINGxe6/s+UPFIQMwCe2hAxgpT4uIt 5lFVi19FZ3mGoD5K6z2i1VSIVR7I19N7fMrn1YJeVhG0S0QsisCEyb722RmcvHCHNEzH fHVQAeNOuHiRlUW+OmHahACyUACj6jmDGB8oO/pkTIfjurzLx3/dKMAbSI81nH2GSb32 XmLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=9p7iZSOBd5fz079FO5IBCEbA0QwvE9xG7uPDBz464MM=; b=HfOGrmoivYv1LyVfgGWY13Ckh3LPqXmwv1YqLxAVa14tLWQxfwTMLtf9yiyi3Onb7o sBtXfzlVlz+uiIMQ7zy+YoDmQgQPJZushxlRsfKMGyJvPRV0f8mjBwMxEQP3BiVHTyYE 4ay9VFG9yidOa1Q748f3eCzYuPqNNUkHEcDu7S5ubwtPc79sNwGD7VwWdhdS/7n8GQLC TOvYFonlu1l0YJrw3xyEW91WfEhXIJgBivTUlaNo4lPjth5YDg/qigqGFjt8DzQXRqpH l9Ui4Qes0prT4xymBHfmzK6eZMpdmMS3wzkSczllBovc6I7Wa/99Ke29IO41E40KlfhJ uVWA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y22-v6si3691092pgj.436.2018.09.13.04.24.49; Thu, 13 Sep 2018 04:25:05 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727790AbeIMQdN (ORCPT + 99 others); Thu, 13 Sep 2018 12:33:13 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:45611 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726450AbeIMQdN (ORCPT ); Thu, 13 Sep 2018 12:33:13 -0400 Received: from p4fea45ac.dip0.t-ipconnect.de ([79.234.69.172] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1g0PjD-0007xe-L4; Thu, 13 Sep 2018 13:24:07 +0200 Date: Thu, 13 Sep 2018 13:24:07 +0200 (CEST) From: Thomas Gleixner To: Yi Sun cc: linux-kernel@vger.kernel.org, x86@kernel.org, chao.p.peng@intel.com, chao.gao@intel.com, isaku.yamahata@intel.com, michael.h.kelly@microsoft.com, tianyu.lan@microsoft.com, "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger Subject: Re: [PATCH v1 2/3] locking/pvqspinlock, hv: Enable PV qspinlock for Hyper-V In-Reply-To: <1536830005-37260-3-git-send-email-yi.y.sun@linux.intel.com> Message-ID: References: <1536830005-37260-1-git-send-email-yi.y.sun@linux.intel.com> <1536830005-37260-3-git-send-email-yi.y.sun@linux.intel.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 13 Sep 2018, Yi Sun wrote: > +++ b/arch/x86/hyperv/hv_spinlock.c > @@ -0,0 +1,99 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +/* > + * Hyper-V specific spinlock code. > + * > + * Copyright (C) 2018, Intel, Inc. > + * > + * Author : Yi Sun > + * > + * This program is free software; you can redistribute it and/or modify it > + * under the terms of the GNU General Public License version 2 as published > + * by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, but > + * WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or > + * NON INFRINGEMENT. See the GNU General Public License for more > + * details. Please remove the boilerplate. The SPDX identifier is enough. If in doubt talk to Intel legal. > +static bool hv_pvspin = true; __initdata please. > +static u32 spin_wait_info = 0; No need for 0 initialization. > + > +static void hv_notify_long_spin_wait(void) > +{ > + u64 input = spin_wait_info | 0x00000000ffffffff; What? The result is always 0x00000000ffffffff ..... > + spin_wait_info++; > + hv_do_fast_hypercall8(HVCALL_NOTIFY_LONG_SPIN_WAIT, input); > +} > + > +static void hv_qlock_kick(int cpu) > +{ > + spin_wait_info--; Looking at the above this is completely pointless and I have no idea what that variable is supposed to do. > + apic->send_IPI(cpu, X86_PLATFORM_IPI_VECTOR); > +} > + > +/* > + * Halt the current CPU & release it back to the host > + */ > +static void hv_qlock_wait(u8 *byte, u8 val) > +{ > + unsigned long msr_val; > + > + if (READ_ONCE(*byte) != val) > + return; > + > + hv_notify_long_spin_wait(); > + > + rdmsrl(HV_X64_MSR_GUEST_IDLE, msr_val); Magic rdmsrl(). That wants a comment what this is for. > +/* > + * Hyper-V does not support this so far. > + */ > +bool hv_vcpu_is_preempted(int vcpu) static ? > +{ > + return false; > +} > +PV_CALLEE_SAVE_REGS_THUNK(hv_vcpu_is_preempted); > + > +void __init hv_init_spinlocks(void) > +{ > + if (!hv_pvspin || > + !apic || > + !(ms_hyperv.hints & HV_X64_CLUSTER_IPI_RECOMMENDED) || > + !(ms_hyperv.features & HV_X64_MSR_GUEST_IDLE_AVAILABLE)) { > + pr_warn("hv: PV spinlocks disabled\n"); Why does this need to be pr_warn? This is purely informational. Also please use pr_fmt instead of the 'hv:' prefix. > +static __init int hv_parse_nopvspin(char *arg) > +{ > + hv_pvspin = false; > + return 0; > +} > +early_param("hv_nopvspin", hv_parse_nopvspin); That lacks Documentation of the command line parameter. Wants to be in the same patch. Thanks, tglx