Re: [PATCH v7 10/21] x86/split_lock: Define per CPU variable to cache MSR TEST_CTL

From: Thomas Gleixner
Date: Thu Apr 18 2019 - 02:32:11 EST


On Wed, 17 Apr 2019, Fenghua Yu wrote:
> On Thu, Apr 18, 2019 at 12:14:12AM +0200, Thomas Gleixner wrote:
> > On Wed, 17 Apr 2019, Fenghua Yu wrote:
> > > +DEFINE_PER_CPU(u64, msr_test_ctl_cache);
> > > +EXPORT_PER_CPU_SYMBOL_GPL(msr_test_ctl_cache);
> >
> > Contrary to things like cpufeatures or MSR bits, it's pretty useless to
> > have a separate patch for this. Please fold this into the place which
> > actualy uses it.
>
> Can I fold this patch into the KVM patch 0013 which first uses (reads) the
> variable? But the variable will be set in later patches when enabling split
> lock feature (patch 0014) and when enabling/disabling split lock feature
> (patch 0015).
>
> Is this a right sequence to fit the variable in the patch set?

As I said in the other reply, you are assuming that the content of that MSR
is 0. Which might be true now, but is that true in a year from now?

So you really want to at least initialize the variable by reading the MSR
_before_ you make use of it in KVM.

Thanks,

tglx