On Tue, May 30, 2017 at 2:34 PM, Vitaly Kuznetsov <vkuzn...@redhat.com> wrote:
> To support implementing remote TLB flushing on Hyper-V with a hypercall
> we need to make vp_index available outside of vmbus module. Rename and
> globalize.

> +u32 *hv_vp_index;

> +       hv_vp_index[smp_processor_id()] = (u32)msr_vp_index;

Redundant casting.

> +       /* Allocate percpu VP index */
> +       hv_vp_index = kcalloc(num_possible_cpus(), sizeof(*hv_vp_index),
> +                             GFP_KERNEL);
> +       if (!hv_vp_index)
> +               return;

Consider to use kmalloc_array _if_ it doesn't require to be zeroed.

> +static inline int hv_cpu_number_to_vp_number(int cpu_number)
> +{

> +       WARN_ON(hv_vp_index[cpu_number] == -1);

How come? u32 will be never negative.

Perhaps you meant == ~0U or U32_MAX

>         for_each_cpu_and(cpu, dest, cpu_online_mask)
> -               params->vp_mask |= (1ULL << 
> vmbus_cpu_number_to_vp_number(cpu));
> +               params->vp_mask |= (1ULL << hv_cpu_number_to_vp_number(cpu));

__set_bit() ?

>                 for_each_cpu_and(cpu, affinity, cpu_online_mask) {
>                         int_pkt->int_desc.cpu_mask |=
> -                               (1ULL << vmbus_cpu_number_to_vp_number(cpu));
> +                               (1ULL << hv_cpu_number_to_vp_number(cpu));

Ditto.

-- 
With Best Regards,
Andy Shevchenko

Reply via email to