RE: [EXTERNAL] Re: [PATCH v2] x86/Hyper-V: Support for free page reporting
From: Sunil Muthuswamy
Date: Wed Jan 06 2021 - 18:04:56 EST
> > +// Bit mask of the extended capability to query: see HV_EXT_CAPABILITY_xxx
>
> Please don't use '//' comments in Linux (here and below)
Will fix in v3.
> > + /*
> > + * Repurpose the input page arg to accept output from Hyper-V for
> > + * now because this is the only call that needs output from the
> > + * hypervisor. It should be fixed properly by introducing an
> > + * output arg once we have more places that require output.
> > + */
>
> I remember there was a patch from Wei (realter to running Linux as root
> partition) doing the job, we can probably merge it early to avoid this
> re-purposing.
I would prefer getting this in right now and we can update this once Wei's
patches gets merged.
> > - pr_info("Hyper-V: features 0x%x, hints 0x%x, misc 0x%x\n",
> > - ms_hyperv.features, ms_hyperv.hints, ms_hyperv.misc_features);
> > + pr_info("Hyper-V: features 0x%x, privilege flags high: 0x%x, hints 0x%x, misc 0x%x\n",
> > + ms_hyperv.features, ms_hyperv.priv_high, ms_hyperv.hints,
> > + ms_hyperv.misc_features);
>
> Even if we would like to avoid the curn and keep 'ms_hyperv.features',
> we could've reported this as
>
> "privilege flags low:%0x%x high:0x%x" to avoid the misleading 'features'.
>
Sure, will change it in v3.
> > + WARN_ON(nents > HV_MEMORY_HINT_MAX_GPA_PAGE_RANGES);
>
> WARN_ON_ONCE() maybe?
Sure, coming in v3.
> > + for (i = 0, sg = sgl; sg; sg = sg_next(sg), i++) {
>
> This looks like an open-coded for_each_sg() version.
Thanks, will change in v3.
> > + BUILD_BUG_ON(pageblock_order < HV_MIN_PAGE_REPORTING_ORDER);
> > + if (!hv_query_ext_cap(HV_EXT_CAPABILITY_MEMORY_COLD_DISCARD_HINT)) {
> > + pr_info("Cold memory discard hint not supported by Hyper-V\n");
> > + return;
> > + }
>
> Which Hyper-V versions/Azure instance types don't support it? In case
> there's something fairly modern on the list, I'd suggest to drop this
> pr_info (or convert it to pr_debug) to not mislead users into thinking
> there's something wrong. In case they don't see 'Cold memory discard
> hint enabled' they know it is unsupported.
>
This is not available in Hypervisor spec 5.0 and was added in 6.0. I don't see any problems
with making it 'pr_debug'
> > +#define HV_EXT_MEMORY_HEAT_HINT_TYPE_COLD_DISCARD 2
> > +struct hv_memory_hint {
> > + u64 type:2;
> > + u64 reserved:62;
> > + union hv_gpa_page_range ranges[];
> > +};
>
> Other similar structures use '__packed' but I remember there was some
> disagreement if this is needed or not when everything is properly padded
> (or doesn't require padding like in this case).
>
There are other places where we don't use '__packed' where everything is
properly aligned. But, I will add it as I don't see a problem with it.
- Sunil