Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1653513
| From | Jork Loeser <Jork.Loeser@microsoft.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | RE: [PATCH v5 09/10] x86/hyper-v: support extended CPU ranges for TLB flush hypercalls |
| Date | 2017-05-30 21:20 +0200 |
| Message-ID | <tMUQq-2TU-21@gated-at.bofh.it> (permalink) |
| References | <tMNFf-6JG-3@gated-at.bofh.it> <tMNFf-6JG-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
> -----Original Message-----
> From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com]
> Sent: Tuesday, May 30, 2017 04:34
> To: x86@kernel.org; devel@linuxdriverproject.org
> Cc: linux-kernel@vger.kernel.org; KY Srinivasan <kys@microsoft.com>; Haiyang
> Zhang <haiyangz@microsoft.com>; Stephen Hemminger
> <sthemmin@microsoft.com>; Thomas Gleixner <tglx@linutronix.de>; Ingo
> Molnar <mingo@redhat.com>; H. Peter Anvin <hpa@zytor.com>; Steven
> Rostedt <rostedt@goodmis.org>; Jork Loeser <Jork.Loeser@microsoft.com>;
> Simon Xiao <sixiao@microsoft.com>; Andy Lutomirski <luto@kernel.org>; Andy
> Shevchenko <andy.shevchenko@gmail.com>
> Subject: [PATCH v5 09/10] x86/hyper-v: support extended CPU ranges for TLB
> flush hypercalls
>
> Hyper-V hosts may support more than 64 vCPUs, we need to use
> HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX/LIST_EX hypercalls in this case.
> +static inline int cpumask_to_vp_set(struct hv_flush_pcpu_ex *flush,
> + const struct cpumask *cpus)
> +{
> + int cpu, vcpu, vcpu_bank, vcpu_offset, cur_bank, nr_bank = 0;
> + bool has_cpus;
> +
> + /*
> + * We can't be sure that translated vCPU numbers will always be
> + * in ascending order, so iterate over all possible banks and
> + * check all vCPUs in it instead.
> + */
> + for (cur_bank = 0; cur_bank < ms_hyperv.max_vp_index/64;
> cur_bank++) {
> + has_cpus = false;
> + for_each_cpu(cpu, cpus) {
> + vcpu = hv_cpu_number_to_vp_number(cpu);
> + vcpu_bank = vcpu / 64;
> + vcpu_offset = vcpu % 64;
> +
> + if (vcpu_bank != cur_bank)
> + continue;
> + __set_bit(vcpu_offset, (unsigned long *)
> + &flush->hv_vp_set.bank_contents[nr_bank]);
> + if (!has_cpus) {
> + __set_bit(vcpu_bank, (unsigned long *)
> + &flush->hv_vp_set.valid_bank_mask);
> + has_cpus = true;
> + }
> + }
> + if (has_cpus)
> + nr_bank++;
> + }
> +
> + return nr_bank;
> +}
Note that the HV_VP_SET may contain empty banks. As such, consider enabling all (5) bits in the valid_bank_mask, and a single for_each(cpu, cpus) pass - setting the bits as per hv_cpu_number_to_vp_number(cpu).
Regards,
Jork
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v5 09/10] x86/hyper-v: support extended CPU ranges for TLB flush hypercalls Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-05-30 13:40 +0200
Re: [PATCH v5 09/10] x86/hyper-v: support extended CPU ranges for TLB flush hypercalls Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-05-30 19:10 +0200
RE: [PATCH v5 09/10] x86/hyper-v: support extended CPU ranges for TLB flush hypercalls Jork Loeser <Jork.Loeser@microsoft.com> - 2017-05-30 21:20 +0200
Re: [PATCH v5 09/10] x86/hyper-v: support extended CPU ranges for TLB flush hypercalls Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-05-31 17:10 +0200
csiph-web