Skip to content

Commit 7ad9bb9

Browse files
committed
asm-generic/hyperv: provide cpumask_to_vpset_noself
This is a new variant which removes `self' cpu from the vpset. It will be used in Hyper-V enlightened IPI code. Signed-off-by: Wei Liu <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f1940d4 commit 7ad9bb9

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

include/asm-generic/mshyperv.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,12 @@ static inline int hv_cpu_number_to_vp_number(int cpu_number)
184184
return hv_vp_index[cpu_number];
185185
}
186186

187-
static inline int cpumask_to_vpset(struct hv_vpset *vpset,
188-
const struct cpumask *cpus)
187+
static inline int __cpumask_to_vpset(struct hv_vpset *vpset,
188+
const struct cpumask *cpus,
189+
bool exclude_self)
189190
{
190191
int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1;
192+
int this_cpu = smp_processor_id();
191193

192194
/* valid_bank_mask can represent up to 64 banks */
193195
if (hv_max_vp_index / 64 >= 64)
@@ -205,6 +207,8 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset,
205207
* Some banks may end up being empty but this is acceptable.
206208
*/
207209
for_each_cpu(cpu, cpus) {
210+
if (exclude_self && cpu == this_cpu)
211+
continue;
208212
vcpu = hv_cpu_number_to_vp_number(cpu);
209213
if (vcpu == VP_INVAL)
210214
return -1;
@@ -219,6 +223,19 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset,
219223
return nr_bank;
220224
}
221225

226+
static inline int cpumask_to_vpset(struct hv_vpset *vpset,
227+
const struct cpumask *cpus)
228+
{
229+
return __cpumask_to_vpset(vpset, cpus, false);
230+
}
231+
232+
static inline int cpumask_to_vpset_noself(struct hv_vpset *vpset,
233+
const struct cpumask *cpus)
234+
{
235+
WARN_ON_ONCE(preemptible());
236+
return __cpumask_to_vpset(vpset, cpus, true);
237+
}
238+
222239
void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die);
223240
bool hv_is_hyperv_initialized(void);
224241
bool hv_is_hibernation_supported(void);

0 commit comments

Comments
 (0)