Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1204708imm; Tue, 2 Oct 2018 04:39:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV62O67siWFv/qn3zI6+5VJ+iotiz+nk6Zs+ZYdCtjnz/UFlgblOgP82keF+GM0T3ID7mwuR+ X-Received: by 2002:a63:fa4e:: with SMTP id g14-v6mr14237203pgk.18.1538480360717; Tue, 02 Oct 2018 04:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538480360; cv=none; d=google.com; s=arc-20160816; b=ataBi8AnXLZpfRhG35S3ZrwCvVXP0rf2Fs/2Wj2f0W/fhHpJjbA0VNoFWYAqoCuEQC tgVDAoroC9MVduYUIfhtTgaIP5ia4Ma9+VlTrLt9MxTTD/nivsagqAxxqTTcbKwlyVO7 CIgTdaFpCS3/Z5pSskCy40JkozLaZVyARFBqtKk/OS3qIsXI6ABTJ/RBVvvV3kceuaJc ugxqMERtjTb+guwFgag7nVZzERIjJ0pft8c8VcQIKxXJaiWNDMq+4XagfFV3KyTcGifL BFasxDe3QjhttIEFfRXyhI8qHi6d+QCjsnlUfsIzngvqFHDHt0rrSMvXqOqQw98F+IaL PnKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:to:subject; bh=qgGbkZsntCMlZ9z4B4bpXEOeEejBN6BgL0NqTiEqHfQ=; b=uut+wkOn7dLP6sz9VjEBzH9WCA+10Ri09Y3qmRYFHLCx7ZvNhFpcEWjSxwdNh2CG5B b/IH3S/EBASQVNK3ARNbodoEqUwfCtWYQ7TSOhHIW7J5G66IuBYIJOQt3O210MC1Up6p /63+1UHSjIk+qG6Upeesjz8/sNxvp2ncY2deIRzejJQexYlN+rtU8r6lvlQfR3kw5bKI fbUb5uFhQ0MChXp8rrW/s8WehUsx6iDHlXWxEPAfMCyy+wnHPIgEPEqcgxJI90idtiSW D+1XtnjIxlLJiUWl1AUw0Nkq2UPPszMjI8+HjA+zinCqGIeFNYjhkK7ilzVDjoLkYb0X zfRw== 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 e39-v6si12529525plg.188.2018.10.02.04.39.03; Tue, 02 Oct 2018 04:39:20 -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 S1727526AbeJBSVu (ORCPT + 99 others); Tue, 2 Oct 2018 14:21:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:53118 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727471AbeJBSVu (ORCPT ); Tue, 2 Oct 2018 14:21:50 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E0AE7AEE6; Tue, 2 Oct 2018 11:38:56 +0000 (UTC) Subject: Re: [tip:x86/hyperv] x86/hyperv: Enable PV qspinlock for Hyper-V To: linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, sthemmin@microsoft.com, mikelley@microsoft.com, kys@microsoft.com, haiyangz@microsoft.com, yi.y.sun@linux.intel.com, hpa@zytor.com References: <1538028104-114050-3-git-send-email-yi.y.sun@linux.intel.com> From: Juergen Gross Openpgp: preference=signencrypt Autocrypt: addr=jgross@suse.com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yDZaixT2T0f4tyF5Lfs+Ha8xVMhIyzNb1byDI5FKCb Message-ID: <0005fc50-4415-87a0-1954-fb15a1f8bd0b@suse.com> Date: Tue, 2 Oct 2018 13:38:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry for noticing this only now, but I have been fighting with Xen PV qspinlocks last weekend: On 02/10/2018 13:28, tip-bot for Yi Sun wrote: > Commit-ID: aaa7fc34c003bd8133a49f7634480cef6288ad55 > Gitweb: https://git.kernel.org/tip/aaa7fc34c003bd8133a49f7634480cef6288ad55 > Author: Yi Sun > AuthorDate: Thu, 27 Sep 2018 14:01:44 +0800 > Committer: Thomas Gleixner > CommitDate: Tue, 2 Oct 2018 13:22:06 +0200 > > x86/hyperv: Enable PV qspinlock for Hyper-V > > Implement the necessary callbacks for PV spinlocks which allow vCPU idling > and kicking operations when running as a guest on Hyper-V > > Signed-off-by: Yi Sun > Signed-off-by: Thomas Gleixner > Reviewed-by: Michael Kelley > Cc: chao.p.peng@intel.com > Cc: chao.gao@intel.com > Cc: isaku.yamahata@intel.com > Cc: tianyu.lan@microsoft.com > Cc: "K. Y. Srinivasan" > Cc: Haiyang Zhang > Cc: Stephen Hemminger > Link: https://lkml.kernel.org/r/1538028104-114050-3-git-send-email-yi.y.sun@linux.intel.com > --- > Documentation/admin-guide/kernel-parameters.txt | 5 ++ > arch/x86/hyperv/Makefile | 4 ++ > arch/x86/hyperv/hv_spinlock.c | 75 +++++++++++++++++++++++++ > arch/x86/include/asm/mshyperv.h | 1 + > arch/x86/kernel/cpu/mshyperv.c | 14 +++++ > 5 files changed, 99 insertions(+) > ... > diff --git a/arch/x86/hyperv/hv_spinlock.c b/arch/x86/hyperv/hv_spinlock.c > new file mode 100644 > index 000000000000..6d3221322d0d > --- /dev/null > +++ b/arch/x86/hyperv/hv_spinlock.c > @@ -0,0 +1,75 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +/* > + * Hyper-V specific spinlock code. > + * > + * Copyright (C) 2018, Intel, Inc. > + * > + * Author : Yi Sun > + */ > + > +#define pr_fmt(fmt) "Hyper-V: " fmt > + > +#include > + > +#include > +#include > +#include > +#include > +#include > + > +static bool __initdata hv_pvspin = true; > + > +static void hv_qlock_kick(int cpu) > +{ > + apic->send_IPI(cpu, X86_PLATFORM_IPI_VECTOR); > +} > + > +static void hv_qlock_wait(u8 *byte, u8 val) > +{ > + unsigned long msr_val; > + > + if (READ_ONCE(*byte) != val) > + return; > + > + /* > + * Read HV_X64_MSR_GUEST_IDLE MSR can trigger the guest's > + * transition to the idle power state which can be exited > + * by an IPI even if IF flag is disabled. > + */ What if interrupts are enabled? Won't a kick happening here just interrupt and then the following rdmsr result in a hang? I believe the correct way would be to: - disable interrupts before above READ_ONCE() and restore them after the rdmsrl() - return early if in_nmi() similar as the kvm specific variant is doing it. Juergen