Re: [PATCH v2 2/2] locking/pvqspinlock, hv: Enable PV qspinlock for Hyper-V

From: Yi Sun
Date: Tue Sep 25 2018 - 03:14:56 EST


On 18-09-21 17:02:54, Michael Kelley (EOSG) wrote:
> From: Yi Sun <yi.y.sun@xxxxxxxxxxxxxxx> Sent: Friday, September 21, 2018 12:25 AM
> > +
> > +#define pr_fmt(fmt) "hv: " fmt
>
> Other Hyper-V messages use "Hyper-V: " as the prefix, not "hv: ". Take
> a quick look at 'dmesg' output for reference.
>
Will modify this. Thanks!

> > +
> > +#include <linux/kernel_stat.h>
> > +#include <linux/spinlock.h>
> > +#include <linux/debugfs.h>
> > +#include <linux/log2.h>
> > +#include <linux/gfp.h>
>
> Some of these #includes look like they might be leftovers from
> some other code. Please check and see whether kernel_stat.h,
> debugsfs.h, log2.h, and gfp.h are actually needed.
>
Sure, I will check them.

> > +static void hv_qlock_wait(u8 *byte, u8 val)
> > +{
> > + unsigned long msr_val;
> > +
> > + if (READ_ONCE(*byte) != val)
> > + return;
> > +
> > + /*
> > + * Read HV_X64_MSR_GUEST_IDLE MSR can trigger the guest's
> > + * transition to the idle power state which can be exited
> > + * by an IPI even if IF flag is disabled.
> > + */
> > + if (ms_hyperv.features & HV_X64_MSR_GUEST_IDLE_AVAILABLE)
>
> I can't see a case where this test is actually needed. hv_qlock_wait()
> can only get called if the flag is set when hv_init_spinlocks() is run, and
> the flag value doesn't change after it is set.
>
Yes, it is redundant. Will remove it.

> > + rdmsrl(HV_X64_MSR_GUEST_IDLE, msr_val);
> > +}
>
> Michael