mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RESEND PATCH 0/5] kthread: remove worker->task self-assignment
@ 2026-08-29 16:11 Bradley Morgan
  2026-08-29 16:13 ` [PATCH 1/5] media: ivtv: convert to kthread_run_worker Bradley Morgan
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Bradley Morgan @ 2026-08-29 16:11 UTC (permalink / raw)
  To: linux-kernel; +Cc: brads

From: Bradley Morgan <brads@mainlining.org>

Resent as a proper series with cover letter. The first send went out as
five separate threads instead of one.

kthread_worker_fn() has carried a FIXME for a decade: it assigns
worker->task = current because the old kthread_run(kthread_worker_fn)
callers never told the worker what task it was. The new
kthread_create_worker*() API sets worker->task before the worker even
starts, so the self-assignment is dead code.

Four drivers were still on the old API. Convert them, then remove the
FIXME.

No functional change intended.

Bradley Morgan (5):
  media: ivtv: convert to kthread_run_worker
  net: encx24j600: convert to kthread_run_worker
  tty: sc16is7xx: convert to kthread_run_worker
  cpufreq: schedutil: convert to kthread_create_worker
  kthread: remove worker->task self-assignment

 drivers/media/pci/ivtv/ivtv-driver.c    | 11 ++++-------
 drivers/media/pci/ivtv/ivtv-driver.h    |  3 +--
 drivers/net/ethernet/microchip/encx24j600.c | 12 ++++--------
 drivers/tty/serial/sc16is7xx.c        | 17 +++++++----------
 kernel/sched/cpufreq_schedutil.c       | 14 +++++--------
 kernel/kthread.c                      |  7 -------
 6 files changed, 21 insertions(+), 63 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH 1/5] media: ivtv: convert to kthread_run_worker
@ 2026-08-29 15:55 Bradley Morgan
  0 siblings, 0 replies; 7+ messages in thread
From: Bradley Morgan @ 2026-08-29 15:55 UTC (permalink / raw)
  To: Andy Walls; +Cc: Mauro Carvalho Chehab, linux-media, linux-kernel, brads

From: Bradley Morgan <brads@mainlining.org>

Embedding a kthread_worker and running kthread_worker_fn yourself is
the old way. Convert ivtv to kthread_run_worker(), dropping the
separate irq_worker_task pointer.

This is part of removing the worker->task self-assignment in
kthread_worker_fn().

Signed-off-by: Bradley Morgan <brads@mainlining.org>
---
 drivers/media/pci/ivtv/ivtv-driver.c | 14 ++++++--------
 drivers/media/pci/ivtv/ivtv-driver.h |  3 +--
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
index b9ea56ec9593..6f0e0e46deb5 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.c
+++ b/drivers/media/pci/ivtv/ivtv-driver.c
@@ -703,15 +703,13 @@ static int ivtv_init_struct1(struct ivtv *itv)
 	spin_lock_init(&itv->lock);
 	spin_lock_init(&itv->dma_reg_lock);
 
-	kthread_init_worker(&itv->irq_worker);
-	itv->irq_worker_task = kthread_run(kthread_worker_fn, &itv->irq_worker,
-					   "%s", itv->v4l2_dev.name);
-	if (IS_ERR(itv->irq_worker_task)) {
+	itv->irq_worker = kthread_run_worker(0, "%s", itv->v4l2_dev.name);
+	if (IS_ERR(itv->irq_worker)) {
 		IVTV_ERR("Could not create ivtv task\n");
 		return -1;
 	}
 	/* must use the FIFO scheduler as it is realtime sensitive */
-	sched_set_fifo(itv->irq_worker_task);
+	sched_set_fifo(itv->irq_worker->task);
 
 	kthread_init_work(&itv->irq_work, ivtv_irq_work_handler);
 
@@ -1232,7 +1230,7 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
 	v4l2_ctrl_handler_free(&itv->cxhdl.hdl);
 	exit_ivtv_i2c(itv);
 free_worker:
-	kthread_stop(itv->irq_worker_task);
+	kthread_destroy_worker(itv->irq_worker);
 err:
 	if (retval == 0)
 		retval = -ENODEV;
@@ -1372,8 +1370,8 @@ static void ivtv_remove(struct pci_dev *pdev)
 	timer_shutdown_sync(&itv->dma_timer);
 
 	/* Kill irq worker */
-	kthread_flush_worker(&itv->irq_worker);
-	kthread_stop(itv->irq_worker_task);
+	kthread_flush_worker(itv->irq_worker);
+	kthread_destroy_worker(itv->irq_worker);
 
 	ivtv_streams_cleanup(itv);
 	ivtv_udma_free(itv);
diff --git a/drivers/media/pci/ivtv/ivtv-driver.h b/drivers/media/pci/ivtv/ivtv-driver.h
index 000e8beecc7c..091bc44f13bc 100644
--- a/drivers/media/pci/ivtv/ivtv-driver.h
+++ b/drivers/media/pci/ivtv/ivtv-driver.h
@@ -668,8 +668,7 @@ struct ivtv {
 	/* Interrupts & DMA */
 	u32 irqmask;                    /* active interrupts */
 	u32 irq_rr_idx;                 /* round-robin stream index */
-	struct kthread_worker irq_worker;		/* kthread worker for PIO/YUV/VBI actions */
-	struct task_struct *irq_worker_task;		/* task for irq_worker */
+	struct kthread_worker *irq_worker;		/* kthread worker for PIO/YUV/VBI actions */
 	struct kthread_work irq_work;	/* kthread work entry */
 	spinlock_t dma_reg_lock;        /* lock access to DMA engine registers */
 	int cur_dma_stream;		/* index of current stream doing DMA (-1 if none) */
-- 
2.47.3


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

end of thread, other threads:[~2026-08-29 16:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-29 16:11 [RESEND PATCH 0/5] kthread: remove worker->task self-assignment Bradley Morgan
2026-08-29 16:13 ` [PATCH 1/5] media: ivtv: convert to kthread_run_worker Bradley Morgan
2026-08-29 16:15 ` [PATCH 2/5] net: encx24j600: " Bradley Morgan
2026-08-29 16:16 ` [PATCH 3/5] tty: sc16is7xx: " Bradley Morgan
2026-08-29 16:17 ` [PATCH 4/5] cpufreq: schedutil: convert to kthread_create_worker Bradley Morgan
2026-08-29 16:18 ` [PATCH] kthread: remove worker->task self-assignment Bradley Morgan
  -- strict thread matches above, loose matches on Subject: below --
2026-08-29 15:55 [PATCH 1/5] media: ivtv: convert to kthread_run_worker Bradley Morgan

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®