mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fushuai Wang <wangfushuai@baidu.com>
To: <tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
	<dave.hansen@linux.intel.com>, <x86@kernel.org>, <hpa@zytor.com>,
	<linux-kernel@vger.kernel.org>
Cc: <gpiccoli@igalia.com>, <peterz@infradead.org>,
	<davydov-max@yandex-team.ru>, <martin.petersen@oracle.com>,
	<jani.nikula@intel.com>, <joel.granados@kernel.org>,
	<xin@zytor.com>, <linux-doc@vger.kernel.org>,
	Fushuai Wang <wangfushuai@baidu.com>
Subject: [PATCH RESEND] x86/split_lock: Make split lock mitigation sleep duration configurable
Date: Tue, 28 Oct 2025 17:43:33 +0800	[thread overview]
Message-ID: <20251028094333.49841-1-wangfushuai@baidu.com> (raw)

Commit 727209376f49 ("x86/split_lock: Add sysctl to control the misery
mode") introduce a sysctl 'sysctl_sld_mitigate' to control the misery
mode for split lock detection (0 to disable, 1 to enable). However,
when enabled, the sleep duration for split lockers was fixed at 10 ms.

This patch extands 'sysctl_sld_mitigate' to allow configuring the sleep
duration in milliseconds. Now, when 'sysctl_sld_mitigate' is set to
N (N > 0), split lockers will sleep for N milliseconds.

Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
---
The last email wasn't delivered. So resend it.

 Documentation/admin-guide/sysctl/kernel.rst | 4 ++--
 arch/x86/kernel/cpu/bus_lock.c              | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst
index f3ee807b5d8b..92e34041ea73 100644
--- a/Documentation/admin-guide/sysctl/kernel.rst
+++ b/Documentation/admin-guide/sysctl/kernel.rst
@@ -1472,8 +1472,8 @@ increase system exposure to denial of service attacks from split lock users.
 = ===================================================================
 0 Disable the mitigation mode - just warns the split lock on kernel log
   and exposes the system to denials of service from the split lockers.
-1 Enable the mitigation mode (this is the default) - penalizes the split
-  lockers with intentional performance degradation.
+N Enable the mitigation mode (default is 10) - penalizes the split lockers
+  by suspending their execution for N milliseconds.
 = ===================================================================
 
 
diff --git a/arch/x86/kernel/cpu/bus_lock.c b/arch/x86/kernel/cpu/bus_lock.c
index 981f8b1f0792..a5f0ad1b5c24 100644
--- a/arch/x86/kernel/cpu/bus_lock.c
+++ b/arch/x86/kernel/cpu/bus_lock.c
@@ -46,7 +46,7 @@ static const struct {
 
 static struct ratelimit_state bld_ratelimit;
 
-static unsigned int sysctl_sld_mitigate = 1;
+static unsigned int sysctl_sld_mitigate = 10;
 static DEFINE_SEMAPHORE(buslock_sem, 1);
 
 #ifdef CONFIG_PROC_SYSCTL
@@ -58,7 +58,7 @@ static const struct ctl_table sld_sysctls[] = {
 		.mode           = 0644,
 		.proc_handler	= proc_douintvec_minmax,
 		.extra1         = SYSCTL_ZERO,
-		.extra2         = SYSCTL_ONE,
+		.extra2         = SYSCTL_INT_MAX,
 	},
 };
 
@@ -252,9 +252,9 @@ static void split_lock_warn(unsigned long ip)
 	if (saved_sld_mitigate) {
 		/*
 		 * misery factor #1:
-		 * sleep 10ms before trying to execute split lock.
+		 * sleep 'saved_sld_mitigate' ms before trying to execute split lock.
 		 */
-		if (msleep_interruptible(10) > 0)
+		if (msleep_interruptible(saved_sld_mitigate) > 0)
 			return;
 		/*
 		 * Misery factor #2:
-- 
2.36.1


             reply	other threads:[~2025-10-28  9:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-28  9:43 Fushuai Wang [this message]
2025-10-30 19:10 ` Borislav Petkov
2025-10-31  5:38   ` Fushuai Wang
     [not found]   ` <20251031024631.86616-1-wangfushuai@baidu.com>
2025-10-31 11:05     ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251028094333.49841-1-wangfushuai@baidu.com \
    --to=wangfushuai@baidu.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=davydov-max@yandex-team.ru \
    --cc=gpiccoli@igalia.com \
    --cc=hpa@zytor.com \
    --cc=jani.nikula@intel.com \
    --cc=joel.granados@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xin@zytor.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®