Thread (18 messages) flat view 18 messages, 4 authors, 3d ago
WARM3d

[PATCH v2 5/5] kthread: remove worker->task self assignment

From: Bradley Morgan <hidden>
Date: 2026-09-04 09:40:28
Also in: linux-media, linux-pm, linux-serial, lkml
Subsystem: the rest · Maintainer: Linus Torvalds

All kthread worker users now create their workers with
kthread_create_worker*(), which sets worker->task before the worker
starts. The self assignment in kthread_worker_fn() is dead code now.

Remove the assignment but keep the WARN_ON() as a sanity check for
any OOT users still using the old API.

Suggested-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Bradley Morgan <redacted>
---
 kernel/kthread.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 63beb59b7a3d..643407647e79 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -987,12 +987,10 @@ int kthread_worker_fn(void *worker_ptr)
 	struct kthread_worker *worker = worker_ptr;
 	struct kthread_work *work;
 
-	/*
-	 * FIXME: Update the check and remove the assignment when all kthread
-	 * worker users are created using kthread_create_worker*() functions.
+	/* All workers are created with worker->task set. If this fires,
+	 * the caller is broken.
 	 */
-	WARN_ON(worker->task && worker->task != current);
-	worker->task = current;
+	WARN_ON(worker->task != current);
 
 	if (worker->flags & KTW_FREEZABLE)
 		set_freezable();
-- 
2.47.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help