Re: [PATCH v4 4/7] x86/hyper-v: allocate and use Virtual Processor Assist Pages

From: Thomas Gleixner
Date: Sun Mar 18 2018 - 11:47:16 EST


On Fri, 16 Mar 2018, Vitaly Kuznetsov wrote:
> static int hv_cpu_init(unsigned int cpu)
> @@ -101,6 +104,23 @@ static int hv_cpu_init(unsigned int cpu)
> if (msr_vp_index > hv_max_vp_index)
> hv_max_vp_index = msr_vp_index;
>
> + if (!hv_vp_assist_page)
> + return 0;
> +
> + if (!hv_vp_assist_page[smp_processor_id()])
> + hv_vp_assist_page[smp_processor_id()] =
> + __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL);

Please avoid the ugly line break which makes the statement appear as
multiline - which would require curly braces for readability - and simply
have a local variable

struct hv_vp_assist_page **hvp = hv_vp_assist_page[smp_processor_id()];

and use that throughout the function.

> + if (hv_vp_assist_page[smp_processor_id()]) {
> + u64 val;
> +
> + val = vmalloc_to_pfn(hv_vp_assist_page[smp_processor_id()]);
> + val = (val << HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT) |
> + HV_X64_MSR_VP_ASSIST_PAGE_ENABLE;
> +
> + wrmsrl(HV_X64_MSR_VP_ASSIST_PAGE, val);
> + }
> +
> return 0;

Other than that:

Reviewed-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>