lib/lwq: fixes for test module hang and unload
cover lib/lwq: fixes for test module hang and unload
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(-)
Signature · 1 line
2.34.1
PATCH 1/2 lib/lwq: fix potential kthread_stop() hang in test
From: Josh Law <[email protected]>
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.
--- lib/lwq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
lib/lwq.c +4 -1
@@ -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);
Signature · 1 line
2.34.1
PATCH 2/2 lib/lwq: add missing module_exit for test module
In reply to Josh LawFrom: Josh Law <[email protected]>
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.
--- lib/lwq.c | 5 +++++ 1 file changed, 5 insertions(+)
lib/lwq.c +5 -0
@@ -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*/
Signature · 1 line
2.34.1