[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <875zgzmz5e.fsf@nanos.tec.linutronix.de>
Date: Sat, 25 Jan 2020 14:41:33 +0100
From: Thomas Gleixner <tglx@...utronix.de>
To: "Luck\, Tony" <tony.luck@...el.com>
Cc: Arvind Sankar <nivedita@...m.mit.edu>,
"Christopherson\, Sean J" <sean.j.christopherson@...el.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
"Yu\, Fenghua" <fenghua.yu@...el.com>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
H Peter Anvin <hpa@...or.com>,
"Raj\, Ashok" <ashok.raj@...el.com>,
"Shankar\, Ravi V" <ravi.v.shankar@...el.com>,
linux-kernel <linux-kernel@...r.kernel.org>, x86 <x86@...nel.org>
Subject: Re: [PATCH v15] x86/split_lock: Enable split lock detection by kernel
Tony,
"Luck, Tony" <tony.luck@...el.com> writes:
> +
> +void switch_to_sld(struct task_struct *prev, struct task_struct *next)
> +{
> + bool prevflag = test_tsk_thread_flag(prev, TIF_SLD);
> + bool nextflag = test_tsk_thread_flag(next, TIF_SLD);
> +
> + /*
> + * If we are switching between tasks that have the same
> + * need for split lock checking, then the MSR is (probably)
> + * right (modulo the other thread messing with it.
> + * Otherwise look at whether the new task needs split
> + * lock enabled.
> + */
> + if (prevflag != nextflag)
> + __sld_msr_set(nextflag);
> +}
> diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
> index 839b5244e3b7..b34d359c4e39 100644
> --- a/arch/x86/kernel/process.c
> +++ b/arch/x86/kernel/process.c
> @@ -650,6 +650,8 @@ 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);
> }
> +
> + switch_to_sld(prev_p, next_p);
This really wants to follow the logic of the other TIF checks.
if ((tifp ^ tifn) & _TIF_SLD)
switch_to_sld(tifn);
and
void switch_to_sld(tifn)
{
__sld_msr_set(tif & _TIF_SLD);
}
That reuses tifp, tifn which are ready to consume there and calls only
out of line when the bits differ. The xor/and combo turned out to result
in the most efficient code.
Thanks,
tglx
Powered by blists - more mailing lists