[PATCH] x86/split_lock: Zap the unwieldy switch-case in sld_state_show()

From: Borislav Petkov

Date: Sun Jan 04 2026 - 14:19:44 EST


On Tue, Dec 16, 2025 at 02:11:51AM +0800, Rong Zhang wrote:
> sld_state_show() has a dead kmsg formatting:
>
> if (A) {
> ...
> } else if (B) {
> pr_info(... A ? str1 : str2 ...);
> }
>
> where A is always false in the second block, implied by the "if (A)
> else" pattern. Hence, str2 is always used.
>
> This seems to be some mysterious legacy inherited from the earlier patch
> revisions of commit ebb1064e7c2e ("x86/traps: Handle #DB for bus lock").
> Earlier revisions [1] did enable both sld and bld at the same time to
> detect non-WB bus_locks when split_lock_detect=fatal, but that's no
> longer true in the merged revision.
>
> Remove it and translate the pr_info() into its equivalent form.
>
> [1]: https://lore.kernel.org/r/20201121023624.3604415-3-fenghua.yu@xxxxxxxxx/
>
> Signed-off-by: Rong Zhang <i@xxxxxxxx>
> ---
> arch/x86/kernel/cpu/bus_lock.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)

While staring at this, that sld_state_show() function looks like it needs
a good scrubbin'. Here's a first attempt ontop:

---