Re: [PATCH v10 6/6] x86/split_lock: Enable split lock detection by kernel parameter
From: Luck, Tony
Date: Fri Nov 22 2019 - 19:31:08 EST
On Fri, Nov 22, 2019 at 04:27:15PM +0100, Peter Zijlstra wrote:
This all looks dubious on an HT system .... three snips
from your patch:
> +static bool __sld_msr_set(bool on)
> +{
> + u64 test_ctrl_val;
> +
> + if (rdmsrl_safe(MSR_TEST_CTRL, test_ctrl_val))
> + return false;
> +
> + if (on)
> + test_ctrl_val |= MSR_TEST_CTRL_SPLIT_LOCK_DETECT;
> + else
> + test_ctrl_val &= ~MSR_TEST_CTRL_SPLIT_LOCK_DETECT;
> +
> + if (wrmsrl_safe(MSR_TEST_CTRL, test_ctrl_val))
> + return false;
> +
> + return true;
> +}
> +void switch_sld(struct task_struct *prev)
> +{
> + __sld_set_msr(true);
> + clear_tsk_thread_flag(current, TIF_CLD);
> +}
> @@ -654,6 +654,9 @@ void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p)
> /* Enforce MSR update to ensure consistent state */
> __speculation_ctrl_update(~tifn, tifn);
> }
> +
> + if (tifp & _TIF_SLD)
> + switch_sld(prev_p);
> }
Don't you have some horrible races between the two logical
processors on the same core as they both try to set/clear the
MSR that is shared at the core level?
-Tony