Received: by 10.223.176.5 with SMTP id f5csp497523wra; Tue, 30 Jan 2018 15:05:20 -0800 (PST) X-Google-Smtp-Source: AH8x227pfPnB2En5r/vvn66wQP8jqP5faBx2/evYVK6osKlpWvpUBLcYjcpzTXf4fSh0YTNhuOGs X-Received: by 2002:a17:902:9a97:: with SMTP id w23-v6mr27192205plp.100.1517353520198; Tue, 30 Jan 2018 15:05:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517353520; cv=none; d=google.com; s=arc-20160816; b=j4oCktpzmlXVJa3uKm7mAprC0AlQKgLCjA4gQzbw4ZP/SlNzCPhZduVz520drrgd/H xjIHw2iCTJJriHMRgq2bSFTxOrFVTbAUSrys89CX/IcarGqjP1lyAdDwPXzWPaKjB5n7 xUpCiUTKV2Sxqwl2icZLDFFwvBJAUJ3HJH13l+1OM6QJKnIASuw3JleEs7XBK+vnD+0D JiZFUH22wI77+9RZYP7Ij6pulwoM0hLbOOw74lwdJQMP1HdIA1I63rqQrS6XYJj5XdNk d5Alyo2rUdoZNfXk8KPG6dELDLYiv2fcdOWKvjFU+3iUdiKTvvgecshiyZHDtTzZ0fNZ /S6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=rf6jvsC3aUNIF2WVPav1R6QvVgpSPaPhzCX/OgGymgo=; b=vwZzigBbG9e/hWsOyAu0dizRE2Lmz814AddByuBJQJgUDM17Ji1D2mivcYMJnEGW4m CmewPMqOFVLN+FWhjONtbN6zGCmMo34xRiki+17amnDePOJFqqoqmj/VyVU9yPxzf/GA pYLiEM7KOMua6KtFy+SpHeI5Se3/AXP6hdadg4h9AzDXKMKq07UIajW/rSX5I5zRABh8 qgSN7phCZUpulr4YGwRCDcaivypbMnGvAefb3u2HuqWnDHy7/C7PyeDW8QGLMcB41yR/ CagDjtNt5IhI8RRCQYwHE3y7yau1hV71R5o8xHj26sYrtkVtal80xK3MqFiqf7OqH4gu KXSA== 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 z3-v6si531802pln.395.2018.01.30.15.05.05; Tue, 30 Jan 2018 15:05:20 -0800 (PST) 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 S1754073AbeA3XDP (ORCPT + 99 others); Tue, 30 Jan 2018 18:03:15 -0500 Received: from terminus.zytor.com ([65.50.211.136]:37485 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753615AbeA3XDL (ORCPT ); Tue, 30 Jan 2018 18:03:11 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w0UN210r011644; Tue, 30 Jan 2018 15:02:01 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w0UN21Ej011637; Tue, 30 Jan 2018 15:02:01 -0800 Date: Tue, 30 Jan 2018 15:02:01 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Vitaly Kuznetsov Message-ID: Cc: sthemmin@microsoft.com, linux-kernel@vger.kernel.org, kys@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, rkagan@virtuozzo.com, Michael.H.Kelley@microsoft.com, mmorsy@redhat.com, pbonzini@redhat.com, tglx@linutronix.de, luto@kernel.org, cavery@redhat.com, mingo@kernel.org, rkrcmar@redhat.com, vkuznets@redhat.com Reply-To: mmorsy@redhat.com, pbonzini@redhat.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com, haiyangz@microsoft.com, kys@microsoft.com, sthemmin@microsoft.com, rkagan@virtuozzo.com, Michael.H.Kelley@microsoft.com, rkrcmar@redhat.com, mingo@kernel.org, vkuznets@redhat.com, luto@kernel.org, cavery@redhat.com In-Reply-To: <20180124132337.30138-5-vkuznets@redhat.com> References: <20180124132337.30138-5-vkuznets@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/hyperv] x86/hyperv: Redirect reenlightment notifications on CPU offlining Git-Commit-ID: e7c4e36c447daca2b7df49024f6bf230871cb155 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: e7c4e36c447daca2b7df49024f6bf230871cb155 Gitweb: https://git.kernel.org/tip/e7c4e36c447daca2b7df49024f6bf230871cb155 Author: Vitaly Kuznetsov AuthorDate: Wed, 24 Jan 2018 14:23:34 +0100 Committer: Thomas Gleixner CommitDate: Tue, 30 Jan 2018 23:55:33 +0100 x86/hyperv: Redirect reenlightment notifications on CPU offlining It is very unlikely for CPUs to get offlined when running on Hyper-V as there is a protection in the vmbus module which prevents it when the guest has any VMBus devices assigned. This, however, may change in future if an option to reassign an already active channel will be added. It is also possible to run without any Hyper-V devices or to have a CPU with no assigned channels. Reassign reenlightenment notifications to some other active CPU when the CPU which is assigned to them goes offline. Signed-off-by: Vitaly Kuznetsov Signed-off-by: Thomas Gleixner Reviewed-by: Thomas Gleixner Cc: Stephen Hemminger Cc: kvm@vger.kernel.org Cc: Radim Krčmář Cc: Haiyang Zhang Cc: "Michael Kelley (EOSG)" Cc: Roman Kagan Cc: Andy Lutomirski Cc: devel@linuxdriverproject.org Cc: Paolo Bonzini Cc: "K. Y. Srinivasan" Cc: Cathy Avery Cc: Mohammed Gamal Link: https://lkml.kernel.org/r/20180124132337.30138-5-vkuznets@redhat.com --- arch/x86/hyperv/hv_init.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index 712ac40..e4377e2 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -191,6 +191,26 @@ void clear_hv_tscchange_cb(void) } EXPORT_SYMBOL_GPL(clear_hv_tscchange_cb); +static int hv_cpu_die(unsigned int cpu) +{ + struct hv_reenlightenment_control re_ctrl; + unsigned int new_cpu; + + if (hv_reenlightenment_cb == NULL) + return 0; + + rdmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *((u64 *)&re_ctrl)); + if (re_ctrl.target_vp == hv_vp_index[cpu]) { + /* Reassign to some other online CPU */ + new_cpu = cpumask_any_but(cpu_online_mask, cpu); + + re_ctrl.target_vp = hv_vp_index[new_cpu]; + wrmsrl(HV_X64_MSR_REENLIGHTENMENT_CONTROL, *((u64 *)&re_ctrl)); + } + + return 0; +} + /* * This function is to be invoked early in the boot sequence after the * hypervisor has been detected. @@ -220,7 +240,7 @@ void hyperv_init(void) return; if (cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/hyperv_init:online", - hv_cpu_init, NULL) < 0) + hv_cpu_init, hv_cpu_die) < 0) goto free_vp_index; /*