Re: [PATCH v5 12/18] x86/split_lock: Enable #AC for split lock by default

From: Dave Hansen
Date: Tue Mar 12 2019 - 19:43:29 EST


On 3/12/19 4:00 PM, Fenghua Yu wrote:
> Split locked access locks bus and degradates overall memory access

Either "split locked accesses lock" or "A split lock access locks".

s/degradates/degrades/

> performance. When split lock detection feature is enumerated, we want to

^ the

Also, you need to go back and remove all the "we"'s. Our friendly x86
maintainers prefer phrasing this like:

When split lock detection feature is enumerated, enable the
feature...

> enable the feature by default to find any split lock issue and then fix
> the issue.

Generally, the changelogs here are passable but pretty rough. They have
a ton of issues like this and I'm sure they can be improved. I'm sure
that with some love an attention they can be brought up to the highest
standards.

> +#define DISABLE_SPLIT_LOCK_DETECT 0
> +#define ENABLE_SPLIT_LOCK_DETECT 1

These are a bit overkill, but oh well.

> +static int split_lock_detect_val;
> +
> /*
> * Just in case our CPU detection goes bad, or you have a weird system,
> * allow a way to override the automatic disabling of MPX.
> @@ -161,10 +166,35 @@ static bool bad_spectre_microcode(struct cpuinfo_x86 *c)
> return false;
> }
>
> +static u32 new_sp_test_ctl_val(u32 test_ctl_val)
> +{
> + /* Change the split lock setting. */
> + if (split_lock_detect_val == DISABLE_SPLIT_LOCK_DETECT)
> + test_ctl_val &= ~TEST_CTL_ENABLE_SPLIT_LOCK_DETECT;
> + else
> + test_ctl_val |= TEST_CTL_ENABLE_SPLIT_LOCK_DETECT;
> +
> + return test_ctl_val;
> +}
> +
> +static void init_split_lock_detect(struct cpuinfo_x86 *c)
> +{
> + if (cpu_has(c, X86_FEATURE_SPLIT_LOCK_DETECT)) {
> + u32 l, h;
> +
> + rdmsr(MSR_TEST_CTL, l, h);
> + l = new_sp_test_ctl_val(l);
> + wrmsr(MSR_TEST_CTL, l, h);
> + pr_info_once("#AC for split lock is enabled\n");
> + }
> +}

Please make sure you've removed all the "#AC for split lock"
nomenclature in these patches. It's acronym nonsense and there's no
reason to be so oblique. Just say "split lock detection enabled". This
also needs a proper prefix, like "x86/intel:". Look around for examples.