Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp522048imm; Fri, 14 Sep 2018 02:08:15 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb8JCpqI7TC2qbyanr/5Fj6WWFBUXfodorejaEtFJhkfN2oYl7rLAXm14tGABaaereFH4Bm X-Received: by 2002:a17:902:25ab:: with SMTP id y40-v6mr10942020pla.120.1536916095201; Fri, 14 Sep 2018 02:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536916095; cv=none; d=google.com; s=arc-20160816; b=UK0HG/sWs6Ys+ME1z7fjYo0Eu1BK6PsAGDAcy9YY2oEdkQDndyqH1qOzaGfMy0Z0ow Md/G20xorN5Za3W+msnnClO2MuO5Potd4vwnIFQEfGPnLeA7H0uZACuOV2jio9jcdSIE hZOy+1/XEnzrQwL5JgF2+Ey7nDAgnJ30I8za+vBWuMjdlJ0V3xSg4SEFnkRt6K214ZBU 3by1SxLwdmQjNClhAtxODOdDNxOGTzeJ6ibDIFLKwKFsKpHXnfBIEGEtqOjncapJhkXF CtysdkuerTdms5oboJQ2BUgKyGslhnKWeoy6jwL6YL1OHHYfaj/lLEuy+o6eb5RGd2b5 whAg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=xCCChOK0ssu/Fb9WNOW4AWLtjEjM38+pjZqUL/IRYQE=; b=cZzOPhYMSyOOfxa86l/mrX63IBHUlMbn3VI5mkywk42H8l/fnq4IhtdAf/g8ZeThRR U94BXGnfI3gdYzd4cNDu+ojcQClzuEGTuVoAQtPhhw6YXidQ/2XaMvwWLYNOa6JtvOvP MazXu64NUaJ6V2nkPEYTQ1QgaEmNqLRxMm8OQkCyJJ3Y0Nudp2i8gLxTnjfIAxlkgoyP rvIVYS/4TyYQsSvrd7QDp/VmRb7v8i7irsTNNX7JfGzVsudCGjFWPgZcQc2h8+ElNwAk zE9qusTeJxWxl278HNmkksw1SIcHCS9ETeb7r/twD9Dfcl/o0xRsofT/XUAJrTEKtyGd X6fw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12-v6si6178713pgk.636.2018.09.14.02.07.59; Fri, 14 Sep 2018 02:08:15 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728124AbeINOUs (ORCPT + 99 others); Fri, 14 Sep 2018 10:20:48 -0400 Received: from mga12.intel.com ([192.55.52.136]:53964 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726883AbeINOUs (ORCPT ); Fri, 14 Sep 2018 10:20:48 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Sep 2018 02:07:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,372,1531810800"; d="scan'208";a="85980025" Received: from yisun1-ubuntu.bj.intel.com (HELO localhost) ([10.238.156.104]) by fmsmga002.fm.intel.com with ESMTP; 14 Sep 2018 02:07:12 -0700 Date: Fri, 14 Sep 2018 17:04:40 +0800 From: Yi Sun To: Thomas Gleixner 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 Message-ID: <20180914090440.GB11769@yi.y.sun> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18-09-13 13:24:07, Thomas Gleixner wrote: > 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. > I will check this. Thanks! > > +static bool hv_pvspin = true; > > __initdata please. > > > +static u32 spin_wait_info = 0; > > No need for 0 initialization. > Will modify them. > > + > > +static void hv_notify_long_spin_wait(void) > > +{ > > + u64 input = spin_wait_info | 0x00000000ffffffff; > > What? The result is always 0x00000000ffffffff ..... > Oh, sorry for such error. > > + 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. > Per Microsoft Hypervisor Top Level Functional Specification, the input parameter of HVCALL_NOTIFY_LONG_SPIN_WAIT is defined as below: SpinwaitInfo – Specifies the accumulated count the guest was spinning. So, it is increased when guest is spinning and reduced when spinlock is released. I may add comments to explain it. > > + 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. > Per above spec, reading HV_X64_MSR_GUEST_IDLE can make guest idle. I will add comment here. > > +/* > > + * Hyper-V does not support this so far. > > + */ > > +bool hv_vcpu_is_preempted(int vcpu) > > static ? > PV_CALLEE_SAVE_REGS_THUNK definition is below. #define PV_CALLEE_SAVE_REGS_THUNK(func) \ extern typeof(func) __raw_callee_save_##func; \ ...... So, the hv_vcpu_is_preempted cannot be declared as 'static'. Otherwise, the make fails with below info. arch/x86/hyperv/hv_spinlock.o: In function `__raw_callee_save_hv_vcpu_is_preempted': hv_spinlock.c:(.text+0xd): undefined reference to `hv_vcpu_is_preempted' > > +{ > > + 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. > Got it. Thanks! > > +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. > Will merge patch 3 into 2. Thanks! > Thanks, > > tglx