mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Samuel Moelius <sam.moelius@trailofbits.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: Samuel Moelius <sam.moelius@trailofbits.com>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Josh Triplett <josh@joshtriplett.org>,
	linux-kernel@vger.kernel.org (open list:TORTURE-TEST MODULES)
Subject: [PATCH] locking/locktorture: reject zero resolved worker threads
Date: Fri,  5 Jun 2026 18:47:05 +0000	[thread overview]
Message-ID: <20260605184705.2490765-1-sam.moelius@trailofbits.com> (raw)

locktorture checks for a zero-worker configuration before it resolves
the default reader count.  For reader-capable lock types, a user can
pass nwriters_stress=0 and leave nreaders_stress at its default -1.
This bypasses the early check, then derives the default real reader
count from the real writer count, leaving both resolved counts at zero.

The module can then load successfully, optionally creating helper
threads such as the stats thread, but no lock-torture worker threads.

Reject the resolved zero-worker state after reader defaults have been
applied.

Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
---
 kernel/locking/locktorture.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c
index e618bcf75e2d..7d553ecd3fab 100644
--- a/kernel/locking/locktorture.c
+++ b/kernel/locking/locktorture.c
@@ -1320,6 +1320,13 @@ static int __init lock_torture_init(void)
 			cxt.nrealreaders_stress = cxt.nrealwriters_stress;
 		}
 
+		if (cxt.nrealwriters_stress == 0 &&
+		    cxt.nrealreaders_stress == 0) {
+			pr_alert("lock-torture: must run at least one locking thread\n");
+			firsterr = -EINVAL;
+			goto unwind;
+		}
+
 		if (nreaders_stress) {
 			cxt.lrsa = kmalloc_objs(*cxt.lrsa,
 						cxt.nrealreaders_stress);
-- 
2.43.0


             reply	other threads:[~2026-06-05 18:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-05 18:47 Samuel Moelius [this message]
2026-06-06  2:46 ` Paul E. McKenney
2026-06-07 14:26   ` Samuel Moelius
2026-06-07 19:11     ` Paul E. McKenney

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=20260605184705.2490765-1-sam.moelius@trailofbits.com \
    --to=sam.moelius@trailofbits.com \
    --cc=dave@stgolabs.net \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    /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®