Received: by 10.192.165.148 with SMTP id m20csp1022515imm; Wed, 25 Apr 2018 11:16:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpk2ADqic28LxZtSQ2Zz0aaNLONsanrXiNkuusa1XBZphcj7x8QIS3/xOYTdYmZE4KUKUZk X-Received: by 2002:a17:902:d68c:: with SMTP id v12-v6mr5178048ply.190.1524680208701; Wed, 25 Apr 2018 11:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524680208; cv=none; d=google.com; s=arc-20160816; b=Zi4h0C2PYTRM4EXNwpEy3WQ9+ibo+QgiG6xngkDC1M2Wb/agmeBim0SWCIqBeGqN2d BzAS8w7SKztRGpGj9Ka4q3JsymeaqnU3gLwbfQgdZnu1EJ3LQwAatEGAYJ8ETS3RnCKR cLOnxEgO/3wt1HzJLk+PHSbHOsKYiEIWhFL03gvFSDy0ZafWt9H4Zg7Zoz0b8kL1oca4 S8Za6CqLjigqTG2q6dzRM02sUriuowaOEhQ6tRusbUZ6nwHrCr788wyUI0Jzs7w/kZWY XlaoTwEqGdu3xI6iP/l45LtTlfxBlDaVPzT05SApFEpsgZR4khdFlzjcR3be4JcYZtGc E+9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=GgsQYcGLYQvssyiFNNV2ixinoyvBCwcwIqtBZA6BFFA=; b=p+xjII0JMDyrtKplSib2Ded3LJ4wt1N9Vs7oL/vlLOfYJ08ST4CF5QdYehBp+gU2g3 CVqIUfcak5q1Vb4DeZQbV+sGL3rpUq2k9T4XVB4er2Cxz0tTXJyVCIBg0jrVgN/jbIRt Q+P2zQHVoArz2IieBELZUL/NZ2prMAiwwJn7VQBPLjjBhlC9bA/1TAbZg0GRDvgAoA2x kiDH2HryPBVLlGP11bMh2QkFLsE2DuTUgsPXISbpz7IEOxhZs1WzwglARp4PzXNYa5zO JpUvOsIOnLAiVIHHmJRKj3TKbYUMpBuESdLTNMQyZCPOacnMOKqr9fGTY2uYNiL4Jttw NCDw== 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 34-v6si16688990plm.495.2018.04.25.11.16.34; Wed, 25 Apr 2018 11:16:48 -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 S1756158AbeDYSOb (ORCPT + 99 others); Wed, 25 Apr 2018 14:14:31 -0400 Received: from a2nlsmtp01-05.prod.iad2.secureserver.net ([198.71.225.49]:46182 "EHLO a2nlsmtp01-05.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755361AbeDYSNy (ORCPT ); Wed, 25 Apr 2018 14:13:54 -0400 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id BOuSfEwnDHUQCBOuSfgkRc; Wed, 25 Apr 2018 11:12:53 -0700 x-originating-ip: 107.180.71.197 Received: from kys by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.89_1) (envelope-from ) id 1fBOuS-0002IC-P3; Wed, 25 Apr 2018 11:12:52 -0700 From: kys@linuxonhyperv.com To: x86@kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, jasowang@redhat.com, tglx@linutronix.de, hpa@zytor.com, sthemmin@microsoft.com, Michael.H.Kelley@microsoft.com, vkuznets@redhat.com Cc: "K. Y. Srinivasan" Subject: [PATCH 4/5] X86: Hyper-V: Consolidate code for converting cpumask to vpset Date: Wed, 25 Apr 2018 11:12:49 -0700 Message-Id: <20180425181250.8740-4-kys@linuxonhyperv.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180425181250.8740-1-kys@linuxonhyperv.com> References: <20180425181110.8683-1-kys@linuxonhyperv.com> <20180425181250.8740-1-kys@linuxonhyperv.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfI1DU+7SxRvHjDdvlxPmKjsOKU26kPFEo2L9KMzpWv6MA9tS9nQqvEdyPiYaLduP0tWDIT2Oq8iy466kSRjOiBWec5LPVE/sD9Jz3Mhu8VT+cHweO2r1 NXMERw9Kf2qhqPyxhPFiSVGxtsLH3TgGBjSH7wwIqYFlLZfw0r5+akIWXKqPYF/V28iwbqpxWJ/bwVlfACdHrLcCmoKRGRTcLEI8Go4lynEyBQ1kaHfcIU2h 3I2H2OELF3J9Qk6u0fwmi+5kot3gK79Dolk139I1H3MQpmCCXlW0ylaniz2Ye2PAtcuC/NjfrZvgYJkMBYyuiD4HNpePKrQ/ApDT6Vl+2EpuFBm8Imo5hVRp 9ftH0aOkXo0eb4JrPsjQriC1OfoJ4fLinrYiuxVWULeRxYGzsDZN/TgpUOIMesyFPPfCb0s2VonhADssSS0hkwprjY2f0G82/7mERuIYl3G7Bpdjya8SvMw1 /R+qn4Wc1lSBXeRExUGCJ/3XB9VbbIevlun96k34xGcjog4aQCQB/gxNltsJjeYudDOHc6KwkS19SvyBcA9/NfoB6v07vjC5W1CB/FgUjATbF5TPpoqQHf7O qvOw/Sdvh2gwpNPKUSSy26yx Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "K. Y. Srinivasan" Consolidate code for converting cpumask to vpset. Signed-off-by: K. Y. Srinivasan --- arch/x86/hyperv/hv_apic.c | 2 +- arch/x86/hyperv/mmu.c | 45 +++----------------------------------- arch/x86/include/asm/hyperv-tlfs.h | 2 +- 3 files changed, 5 insertions(+), 44 deletions(-) diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c index fbb408b91e25..508889c8499e 100644 --- a/arch/x86/hyperv/hv_apic.c +++ b/arch/x86/hyperv/hv_apic.c @@ -123,7 +123,7 @@ static int __send_ipi_mask_ex(const struct cpumask *mask, int vector) ipi_arg->vp_set.valid_bank_mask = 0; if (!cpumask_equal(mask, cpu_present_mask)) { - ipi_arg->vp_set.format = HV_GENERIC_SET_SPARCE_4K; + ipi_arg->vp_set.format = HV_GENERIC_SET_SPARSE_4K; nr_bank = cpumask_to_vpset(&(ipi_arg->vp_set), mask); } if (!nr_bank) diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c index 56c9ebac946f..c9cd28f0bae4 100644 --- a/arch/x86/hyperv/mmu.c +++ b/arch/x86/hyperv/mmu.c @@ -25,11 +25,7 @@ struct hv_flush_pcpu { struct hv_flush_pcpu_ex { u64 address_space; u64 flags; - struct { - u64 format; - u64 valid_bank_mask; - u64 bank_contents[]; - } hv_vp_set; + struct hv_vpset hv_vp_set; u64 gva_list[]; }; @@ -70,41 +66,6 @@ static inline int fill_gva_list(u64 gva_list[], int offset, return gva_n - offset; } -/* Return the number of banks in the resulting vp_set */ -static inline int cpumask_to_vp_set(struct hv_flush_pcpu_ex *flush, - const struct cpumask *cpus) -{ - int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1; - - /* valid_bank_mask can represent up to 64 banks */ - if (hv_max_vp_index / 64 >= 64) - return 0; - - /* - * Clear all banks up to the maximum possible bank as hv_flush_pcpu_ex - * structs are not cleared between calls, we risk flushing unneeded - * vCPUs otherwise. - */ - for (vcpu_bank = 0; vcpu_bank <= hv_max_vp_index / 64; vcpu_bank++) - flush->hv_vp_set.bank_contents[vcpu_bank] = 0; - - /* - * Some banks may end up being empty but this is acceptable. - */ - for_each_cpu(cpu, cpus) { - vcpu = hv_cpu_number_to_vp_number(cpu); - vcpu_bank = vcpu / 64; - vcpu_offset = vcpu % 64; - __set_bit(vcpu_offset, (unsigned long *) - &flush->hv_vp_set.bank_contents[vcpu_bank]); - if (vcpu_bank >= nr_bank) - nr_bank = vcpu_bank + 1; - } - flush->hv_vp_set.valid_bank_mask = GENMASK_ULL(nr_bank - 1, 0); - - return nr_bank; -} - static void hyperv_flush_tlb_others(const struct cpumask *cpus, const struct flush_tlb_info *info) { @@ -239,8 +200,8 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask *cpus, flush->hv_vp_set.valid_bank_mask = 0; if (!cpumask_equal(cpus, cpu_present_mask)) { - flush->hv_vp_set.format = HV_GENERIC_SET_SPARCE_4K; - nr_bank = cpumask_to_vp_set(flush, cpus); + flush->hv_vp_set.format = HV_GENERIC_SET_SPARSE_4K; + nr_bank = cpumask_to_vpset(&(flush->hv_vp_set), cpus); } if (!nr_bank) { diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h index 53ea30d768d9..b32b87945538 100644 --- a/arch/x86/include/asm/hyperv-tlfs.h +++ b/arch/x86/include/asm/hyperv-tlfs.h @@ -370,7 +370,7 @@ struct hv_tsc_emulation_status { #define HV_FLUSH_USE_EXTENDED_RANGE_FORMAT BIT(3) enum HV_GENERIC_SET_FORMAT { - HV_GENERIC_SET_SPARCE_4K, + HV_GENERIC_SET_SPARSE_4K, HV_GENERIC_SET_ALL, }; -- 2.15.1