Received: by 10.192.165.148 with SMTP id m20csp397656imm; Thu, 3 May 2018 23:11:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpLv5NBm2SqMz8QoAVfn+jKz6SiFcz2my/uhLyKC7diFa66463g8IXT4c8POxcHnDpYCGDv X-Received: by 2002:a63:b203:: with SMTP id x3-v6mr21068971pge.266.1525414284143; Thu, 03 May 2018 23:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525414284; cv=none; d=google.com; s=arc-20160816; b=eH81graINfghPRbo/dXEEQ4vCZvOE8hayNkhy8Bbxf1WygPyBkXPSmB0NkXHrgRIyC wMEIo5NVb5K7LYHalIKJElI5s8jGgeRfX7cbG2h+oFHDRbw5B8iBQHavwsmfE8q9gK98 J3E95B4Y7T4i0wZtkKWZfN5uFtXXzXLhWOMmYIDE9mI8MTiA9c0cM46/Ua2YhfrTk2m0 sejnOuf0iSzR9YbrnY+cCwmalK6IUFWKZZypINW6iklOKfKmQA5UDSyirxn3PPBXhuSl XsBtOjL3LVYPUb8o0iYAMEt5rwaTEFhlntlV5ROabyX2qczwdHO1/NH5RLlEpwMhdMdL 7ecA== 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=S27CzbAbEgqmiNM5ZbXFWN8qYM8EWi+NzGvC05M1HRM=; b=TZuZZ6WupXtIgWAM+ebVs0HpTklpRz6C6Ag2gOUWXBEJ4oOKBJ5cVUGglJa7NM+UO4 /aAHnUVvpEKK241v5Sr3jOQ0UlJW4SnVdiHuIQH12X2ZVHzSLDRQGEP4omnUwS5AT76s bMpieNrwWppqOYykiz+W+mcMi+lOghVxHIYYOVkNPjeDA/nR5SjwPOy6zNJPGDxspBTi gO0UYH6YErP/Ox3lS7kzqZAstZgp8zAg95cAr+LvT4w02vyXKP61GM9GEGKpupYGv3Qo gmchyh/Z6YpyBZkJOhWPiT+xBwaut9aiIcZo+yJkjYIi7KbuWavZPKcaFuSEpk8wTobM ON7A== 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 bi5-v6si12641543plb.190.2018.05.03.23.11.10; Thu, 03 May 2018 23:11:24 -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 S1751817AbeEDGK2 (ORCPT + 99 others); Fri, 4 May 2018 02:10:28 -0400 Received: from a2nlsmtp01-04.prod.iad2.secureserver.net ([198.71.225.38]:39706 "EHLO a2nlsmtp01-04.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751001AbeEDGJ1 (ORCPT ); Fri, 4 May 2018 02:09:27 -0400 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id ETtKfoDbDGqYmETtKf6GZK; Thu, 03 May 2018 23:08:26 -0700 x-originating-ip: 107.180.71.197 Received: from kys by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.89_1) (envelope-from ) id 1fETtJ-0000t1-SH; Thu, 03 May 2018 23:08:25 -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 V2 4/5] X86: Hyper-V: Consolidate code for converting cpumask to vpset Date: Thu, 3 May 2018 23:08:22 -0700 Message-Id: <20180504060823.3345-4-kys@linuxonhyperv.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180504060823.3345-1-kys@linuxonhyperv.com> References: <20180504060653.3240-1-kys@linuxonhyperv.com> <20180504060823.3345-1-kys@linuxonhyperv.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfO5fvkw+ICjeE8oWzPxGFCBGm3Zc66fVrKwfAY82FCzX5SI+qzbsNESUFMgu8U9vXG5J+SmXeLoe4jHRvWFEvMaDNmzlUNB5UOig/OjoQZZ9Y/qZyeDB ZgskzSkTDTXEi8ZAL8b9bv0or+nECpDcOWa5PkYq+9WblT5448g61b9k9rLVa2B0gWwANUFq5GaiNJv3WF5pf/8xS0uCBB6gb+NUHYYfyCZGClmp7PPXIJZU 9bPAb3A83HvKdXvIwxc/eT7F8NyoZGewzUZVsJJbwIy5v36cV9m8zqtEdPHOyDDdYhJhHCqdxQ+bwsMhOBv1D2oja/zrE2FKIKd7QnpRt04tWBs72R0WaDE2 Fww29vmU3O996oy/B9a+uhs8vMVQFbVf/QUOzjYm/Gz8JFxE4kWQC+cgttC6thE7if1xYz6YwM/aFV2X18R9+ussT9oCHDHBqu3Jg6Y0EqPuo/pYn8yZYXiQ MGbtxmAzHRVXZxXrGxEfgm50rr7YEtYk2NecToZ3IHgugIUQYryRhnVc5tmlRONXcfDLVP/SXkzGqDBUFZvipH9zuXVFdKOMqSF5OesnPCwYUEVXKgOgw+vA QY3Tgp9Ttqddo3CbwLApoBp2 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/mmu.c | 43 ++----------------------------------------- 1 file changed, 2 insertions(+), 41 deletions(-) diff --git a/arch/x86/hyperv/mmu.c b/arch/x86/hyperv/mmu.c index adee39a7a3f2..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) { @@ -240,7 +201,7 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask *cpus, if (!cpumask_equal(cpus, cpu_present_mask)) { flush->hv_vp_set.format = HV_GENERIC_SET_SPARSE_4K; - nr_bank = cpumask_to_vp_set(flush, cpus); + nr_bank = cpumask_to_vpset(&(flush->hv_vp_set), cpus); } if (!nr_bank) { -- 2.15.1