Re: [PATCH RESEND v3] x86/split_lock: fix delayed detection enabling

From: Guilherme G. Piccoli
Date: Wed Nov 20 2024 - 14:17:13 EST


On 13/11/2024 11:23, Maksim Davydov wrote:
> If the warn mode with disabled mitigation mode is used, then on each
> CPU where the split lock occurred detection will be disabled in order to
> make progress and delayed work will be scheduled, which then will enable
> detection back. Now it turns out that all CPUs use one global delayed
> work structure. This leads to the fact that if a split lock occurs on
> several CPUs at the same time (within 2 jiffies), only one CPU will
> schedule delayed work, but the rest will not. The return value of
> schedule_delayed_work_on() would have shown this, but it is not checked
> in the code.
>
> A diagram that can help to understand the bug reproduction:
> https://lore.kernel.org/all/2cd54041-253b-4e78-b8ea-dbe9b884ff9b@xxxxxxxxxxxxxx/
>
> In order to fix the warn mode with disabled mitigation mode, delayed work
> has to be a per-CPU.
>
> v3 -> v2:
> * place and time of the per-CPU structure initialization were changed.
> initcall doesn't seem to be a good place for it, so deferred
> initialization is used.
>
> Fixes: 727209376f49 ("x86/split_lock: Add sysctl to control the misery mode")
> Signed-off-by: Maksim Davydov <davydov-max@xxxxxxxxxxxxxx>
> ---
> arch/x86/kernel/cpu/intel.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)


Hi Maksim, thanks for resubmitting again. I think that is indeed a valid
fix, but what I've also noticed is that recently (as in this week) the
code changed from the intel.c file to a more generic one, since AMD is
enabling split lock detection in their CPUs apparently [0].

So, I'd suggest you to rebase against 6.13-rc, that would likely
increase the chances of a merge. Once you do that, I can try to test it
as well, though I don't personally have an Intel CPU with that feature
(but some friends have it).

Cheers,


Guilherme


[0] https://lore.kernel.org/r/ZzuBNj4JImJGUNJc@xxxxxxxxx/