diff options
author | K. Y. Srinivasan <kys@microsoft.com> | 2018-05-16 17:53:33 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2018-05-19 07:23:18 -0400 |
commit | 800b8f03fdc8d66885ff03de531285526a4ca0d4 (patch) | |
tree | e935e1e8be726544d68c3c1a3cd6177fb1b745d3 | |
parent | 366f03b0cf90ef55f063d4a54cf62b0ac9b6da9d (diff) |
X86/Hyper-V: Consolidate code for converting cpumask to vpset
Consolidate code for converting cpumask to vpset.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Cc: olaf@aepfle.de
Cc: sthemmin@microsoft.com
Cc: gregkh@linuxfoundation.org
Cc: jasowang@redhat.com
Cc: Michael.H.Kelley@microsoft.com
Cc: hpa@zytor.com
Cc: apw@canonical.com
Cc: devel@linuxdriverproject.org
Cc: vkuznets@redhat.com
Link: https://lkml.kernel.org/r/20180516215334.6547-4-kys@linuxonhyperv.com
-rw-r--r-- | arch/x86/hyperv/mmu.c | 43 |
1 files 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 { | |||
25 | struct hv_flush_pcpu_ex { | 25 | struct hv_flush_pcpu_ex { |
26 | u64 address_space; | 26 | u64 address_space; |
27 | u64 flags; | 27 | u64 flags; |
28 | struct { | 28 | struct hv_vpset hv_vp_set; |
29 | u64 format; | ||
30 | u64 valid_bank_mask; | ||
31 | u64 bank_contents[]; | ||
32 | } hv_vp_set; | ||
33 | u64 gva_list[]; | 29 | u64 gva_list[]; |
34 | }; | 30 | }; |
35 | 31 | ||
@@ -70,41 +66,6 @@ static inline int fill_gva_list(u64 gva_list[], int offset, | |||
70 | return gva_n - offset; | 66 | return gva_n - offset; |
71 | } | 67 | } |
72 | 68 | ||
73 | /* Return the number of banks in the resulting vp_set */ | ||
74 | static inline int cpumask_to_vp_set(struct hv_flush_pcpu_ex *flush, | ||
75 | const struct cpumask *cpus) | ||
76 | { | ||
77 | int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1; | ||
78 | |||
79 | /* valid_bank_mask can represent up to 64 banks */ | ||
80 | if (hv_max_vp_index / 64 >= 64) | ||
81 | return 0; | ||
82 | |||
83 | /* | ||
84 | * Clear all banks up to the maximum possible bank as hv_flush_pcpu_ex | ||
85 | * structs are not cleared between calls, we risk flushing unneeded | ||
86 | * vCPUs otherwise. | ||
87 | */ | ||
88 | for (vcpu_bank = 0; vcpu_bank <= hv_max_vp_index / 64; vcpu_bank++) | ||
89 | flush->hv_vp_set.bank_contents[vcpu_bank] = 0; | ||
90 | |||
91 | /* | ||
92 | * Some banks may end up being empty but this is acceptable. | ||
93 | */ | ||
94 | for_each_cpu(cpu, cpus) { | ||
95 | vcpu = hv_cpu_number_to_vp_number(cpu); | ||
96 | vcpu_bank = vcpu / 64; | ||
97 | vcpu_offset = vcpu % 64; | ||
98 | __set_bit(vcpu_offset, (unsigned long *) | ||
99 | &flush->hv_vp_set.bank_contents[vcpu_bank]); | ||
100 | if (vcpu_bank >= nr_bank) | ||
101 | nr_bank = vcpu_bank + 1; | ||
102 | } | ||
103 | flush->hv_vp_set.valid_bank_mask = GENMASK_ULL(nr_bank - 1, 0); | ||
104 | |||
105 | return nr_bank; | ||
106 | } | ||
107 | |||
108 | static void hyperv_flush_tlb_others(const struct cpumask *cpus, | 69 | static void hyperv_flush_tlb_others(const struct cpumask *cpus, |
109 | const struct flush_tlb_info *info) | 70 | const struct flush_tlb_info *info) |
110 | { | 71 | { |
@@ -240,7 +201,7 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask *cpus, | |||
240 | 201 | ||
241 | if (!cpumask_equal(cpus, cpu_present_mask)) { | 202 | if (!cpumask_equal(cpus, cpu_present_mask)) { |
242 | flush->hv_vp_set.format = HV_GENERIC_SET_SPARSE_4K; | 203 | flush->hv_vp_set.format = HV_GENERIC_SET_SPARSE_4K; |
243 | nr_bank = cpumask_to_vp_set(flush, cpus); | 204 | nr_bank = cpumask_to_vpset(&(flush->hv_vp_set), cpus); |
244 | } | 205 | } |
245 | 206 | ||
246 | if (!nr_bank) { | 207 | if (!nr_bank) { |