public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] lib/lwq: fixes for test module hang and unload
@ 2026-03-12 22:14 Josh Law
  2026-03-12 22:14 ` [PATCH v1 1/2] lib/lwq: fix potential kthread_stop() hang in test Josh Law
  2026-03-12 22:14 ` [PATCH v1 2/2] lib/lwq: add missing module_exit for test module Josh Law
  0 siblings, 2 replies; 3+ messages in thread
From: Josh Law @ 2026-03-12 22:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Josh Law

This series contains two fixes for the lib/lwq test module:
1. Fix a potential kthread_stop() hang by checking kthread_should_stop()
   inside the wait_var_event() condition.
2. Add a missing module_exit() declaration to allow the test module
   to be unloaded after insertion.

Josh Law (2):
  lib/lwq: fix potential kthread_stop() hang in test
  lib/lwq: add missing module_exit for test module

 lib/lwq.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v1 1/2] lib/lwq: fix potential kthread_stop() hang in test
  2026-03-12 22:14 [PATCH v1 0/2] lib/lwq: fixes for test module hang and unload Josh Law
@ 2026-03-12 22:14 ` Josh Law
  2026-03-12 22:14 ` [PATCH v1 2/2] lib/lwq: add missing module_exit for test module Josh Law
  1 sibling, 0 replies; 3+ messages in thread
From: Josh Law @ 2026-03-12 22:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Josh Law

From: Josh Law <objecting@objecting.org>

Check kthread_should_stop() in lwq_exercise()'s wait_var_event()
so the thread can exit cleanly when kthread_stop() is called while
the queue is empty.

Signed-off-by: Josh Law <objecting@objecting.org>
---
 lib/lwq.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/lwq.c b/lib/lwq.c
index c1e11ba6f254..1fd2ed612c75 100644
--- a/lib/lwq.c
+++ b/lib/lwq.c
@@ -86,7 +86,10 @@ static int lwq_exercise(void *qv)
 	struct tnode *t;
 
 	for (cnt = 0; cnt < 10000; cnt++) {
-		wait_var_event(q, (t = lwq_dequeue(q, struct tnode, n)) != NULL);
+		wait_var_event(q, (t = lwq_dequeue(q, struct tnode, n)) != NULL ||
+			       kthread_should_stop());
+		if (!t)
+			break;
 		t->c++;
 		if (lwq_enqueue(&t->n, q))
 			wake_up_var(q);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v1 2/2] lib/lwq: add missing module_exit for test module
  2026-03-12 22:14 [PATCH v1 0/2] lib/lwq: fixes for test module hang and unload Josh Law
  2026-03-12 22:14 ` [PATCH v1 1/2] lib/lwq: fix potential kthread_stop() hang in test Josh Law
@ 2026-03-12 22:14 ` Josh Law
  1 sibling, 0 replies; 3+ messages in thread
From: Josh Law @ 2026-03-12 22:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Josh Law

From: Josh Law <objecting@objecting.org>

module_init(lwq_test) is declared without a corresponding module_exit,
preventing the module from being unloaded when built as a module.

Add an empty module_exit handler.

Signed-off-by: Josh Law <objecting@objecting.org>
---
 lib/lwq.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/lwq.c b/lib/lwq.c
index 1fd2ed612c75..cf4d174d6898 100644
--- a/lib/lwq.c
+++ b/lib/lwq.c
@@ -157,5 +157,10 @@ static int lwq_test(void)
 	return 0;
 }
 
+static void lwq_test_exit(void)
+{
+}
+
 module_init(lwq_test);
+module_exit(lwq_test_exit);
 #endif /* CONFIG_LWQ_TEST*/
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-12 22:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 22:14 [PATCH v1 0/2] lib/lwq: fixes for test module hang and unload Josh Law
2026-03-12 22:14 ` [PATCH v1 1/2] lib/lwq: fix potential kthread_stop() hang in test Josh Law
2026-03-12 22:14 ` [PATCH v1 2/2] lib/lwq: add missing module_exit for test module Josh Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox