kthread-add-kthread_stop_put.patch removed from -mm tree
The quilt patch titled
Subject: kthread: add kthread_stop_put
has been removed from the -mm tree. Its filename was
kthread-add-kthread_stop_put.patch
This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Andreas Gruenbacher <[email protected]>
Subject: kthread: add kthread_stop_put
Date: Fri, 8 Sep 2023 01:40:48 +0200
Add a kthread_stop_put() helper that stops a thread and puts its task struct. Use it to replace the various instances of kthread_stop() followed by put_task_struct().
Remove the kthread_stop_put() macro in usbip that is similar but doesn't return the result of kthread_stop().
---
drivers/accel/ivpu/ivpu_job.c | 3 +-- drivers/dma-buf/st-dma-fence-chain.c | 12 ++++-------- drivers/dma-buf/st-dma-fence.c | 4 +--- drivers/gpu/drm/i915/gt/selftest_migrate.c | 4 +--- drivers/net/xen-netback/interface.c | 3 +-- drivers/usb/usbip/usbip_common.h | 6 ------ fs/gfs2/ops_fstype.c | 9 +++------ include/linux/kthread.h | 1 + kernel/irq/manage.c | 15 +++++---------- kernel/kthread.c | 18 ++++++++++++++++++ kernel/smpboot.c | 3 +-- mm/damon/core.c | 3 +-- net/core/pktgen.c | 3 +-- 13 files changed, 38 insertions(+), 46 deletions(-)
drivers/accel/ivpu/ivpu_job.c renamed from drivers/accel/ivpu/ivpu_job.c~kthread-add-kthread_stop_put +1 -2
@@ -618,6 +618,5 @@ int ivpu_job_done_thread_init(struct ivpvoid ivpu_job_done_thread_fini (struct ivpu_device *vdev) { -kthread_stop (vdev->job_done_thread); -put_task_struct (vdev->job_done_thread); +kthread_stop_put (vdev->job_done_thread); }
drivers/dma-buf/st-dma-fence.c renamed from drivers/dma-buf/st-dma-fence.c~kthread-add-kthread_stop_put +1 -3
@@ -548,11 +548,9 @@ static int race_signal_callback(void *arfor (i =0 ; i <ARRAY_SIZE (t); i++) {int err; - err =kthread_stop (t[i].task); + err =kthread_stop_put (t[i].task);if (err && !ret) ret = err; - -put_task_struct (t[i].task); } }
drivers/dma-buf/st-dma-fence-chain.c renamed from drivers/dma-buf/st-dma-fence-chain.c~kthread-add-kthread_stop_put +4 -8
@@ -476,10 +476,9 @@ static int find_race(void *arg)for (i =0 ; i < ncpus; i++) {int ret; - ret =kthread_stop (threads[i]); + ret =kthread_stop_put (threads[i]);if (ret && !err) err = ret; -put_task_struct (threads[i]); }kfree (threads);
@@ -591,8 +590,7 @@ static int wait_forward(void *arg)for (i =0 ; i < fc.chain_length; i++)dma_fence_signal (fc.fences[i]); - err =kthread_stop (tsk); -put_task_struct (tsk); + err =kthread_stop_put (tsk); err:fence_chains_fini (&fc);
@@ -621,8 +619,7 @@ static int wait_backward(void *arg)for (i = fc.chain_length; i--; )dma_fence_signal (fc.fences[i]); - err =kthread_stop (tsk); -put_task_struct (tsk); + err =kthread_stop_put (tsk); err:fence_chains_fini (&fc);
@@ -669,8 +666,7 @@ static int wait_random(void *arg)for (i =0 ; i < fc.chain_length; i++)dma_fence_signal (fc.fences[i]); - err =kthread_stop (tsk); -put_task_struct (tsk); + err =kthread_stop_put (tsk); err:fence_chains_fini (&fc);
drivers/gpu/drm/i915/gt/selftest_migrate.c renamed from drivers/gpu/drm/i915/gt/selftest_migrate.c~kthread-add-kthread_stop_put +1 -3
@@ -719,11 +719,9 @@ static int threaded_migrate(struct intelif (IS_ERR_OR_NULL (tsk))continue ; - status =kthread_stop (tsk); + status =kthread_stop_put (tsk);if (status && !err) err = status; - -put_task_struct (tsk); }kfree (thread);
drivers/net/xen-netback/interface.c renamed from drivers/net/xen-netback/interface.c~kthread-add-kthread_stop_put +1 -2
@@ -672,8 +672,7 @@ err:static void xenvif_disconnect_queue (struct xenvif_queue *queue) {if (queue->task) { -kthread_stop (queue->task); -put_task_struct (queue->task); +kthread_stop_put (queue->task); queue->task =NULL ; }
drivers/usb/usbip/usbip_common.h renamed from drivers/usb/usbip/usbip_common.h~kthread-add-kthread_stop_put +0 -6
@@ -298,12 +298,6 @@ struct usbip_device { __k; \ }) -#define kthread_stop_put (k) \ - do { \ - kthread_stop(k); \ - put_task_struct(k); \ - } while (0) -/* usbip_common.c */ void usbip_dump_urb (struct urb *purb);void usbip_dump_header (struct usbip_header *pdu);
fs/gfs2/ops_fstype.c renamed from fs/gfs2/ops_fstype.c~kthread-add-kthread_stop_put +3 -6
@@ -1126,8 +1126,7 @@ static int init_threads(struct gfs2_sbdreturn 0 ; fail: -kthread_stop (sdp->sd_logd_process); -put_task_struct (sdp->sd_logd_process); +kthread_stop_put (sdp->sd_logd_process); sdp->sd_logd_process =NULL ;return error; }
@@ -1135,13 +1134,11 @@ fail:void gfs2_destroy_threads (struct gfs2_sbd *sdp) {if (sdp->sd_logd_process) { -kthread_stop (sdp->sd_logd_process); -put_task_struct (sdp->sd_logd_process); +kthread_stop_put (sdp->sd_logd_process); sdp->sd_logd_process =NULL ; }if (sdp->sd_quotad_process) { -kthread_stop (sdp->sd_quotad_process); -put_task_struct (sdp->sd_quotad_process); +kthread_stop_put (sdp->sd_quotad_process); sdp->sd_quotad_process =NULL ; } }
include/linux/kthread.h renamed from include/linux/kthread.h~kthread-add-kthread_stop_put +1 -0
@@ -86,6 +86,7 @@ void free_kthread_struct(struct task_strvoid kthread_bind (struct task_struct *k,unsigned int cpu);void kthread_bind_mask (struct task_struct *k,const struct cpumask *mask);int kthread_stop (struct task_struct *k); +int kthread_stop_put (struct task_struct *k);bool kthread_should_stop (void );bool kthread_should_park (void );bool kthread_should_stop_or_park (void );
kernel/irq/manage.c renamed from kernel/irq/manage.c~kthread-add-kthread_stop_put +5 -10
@@ -1852,15 +1852,13 @@ out_thread:struct task_struct *t = new->thread; new->thread =NULL ; -kthread_stop (t); -put_task_struct (t); +kthread_stop_put (t); }if (new->secondary && new->secondary->thread) {struct task_struct *t = new->secondary->thread; new->secondary->thread =NULL ; -kthread_stop (t); -put_task_struct (t); +kthread_stop_put (t); } out_mput:module_put (desc->owner);
@@ -1971,12 +1969,9 @@ static struct irqaction *__free_irq(stru* the same bit to a newly requested action. */ if (action->thread) { -kthread_stop (action->thread); -put_task_struct (action->thread); -if (action->secondary && action->secondary->thread) { -kthread_stop (action->secondary->thread); -put_task_struct (action->secondary->thread); - } +kthread_stop_put (action->thread); +if (action->secondary && action->secondary->thread) +kthread_stop_put (action->secondary->thread); }/* Last action releases resources */
kernel/kthread.c renamed from kernel/kthread.c~kthread-add-kthread_stop_put +18 -0
@@ -715,6 +715,24 @@ int kthread_stop(struct task_struct *k) }EXPORT_SYMBOL (kthread_stop); +/** +* kthread_stop_put - stop a thread and put its task struct +* @k: thread created by kthread_create(). +* +* Stops a thread created by kthread_create() and put its task_struct. +* Only use when holding an extra task struct reference obtained by +* calling get_task_struct(). +*/ +int kthread_stop_put (struct task_struct *k) +{ +int ret; + + ret =kthread_stop (k); +put_task_struct (k); +return ret; +} +EXPORT_SYMBOL (kthread_stop_put); +int kthreadd (void *unused) {struct task_struct *tsk = current;
kernel/smpboot.c renamed from kernel/smpboot.c~kthread-add-kthread_stop_put +1 -2
@@ -272,8 +272,7 @@ static void smpboot_destroy_threads(strustruct task_struct *tsk = *per_cpu_ptr (ht->store, cpu);if (tsk) { -kthread_stop (tsk); -put_task_struct (tsk); +kthread_stop_put (tsk); *per_cpu_ptr (ht->store, cpu) =NULL ; } }
mm/damon/core.c renamed from mm/damon/core.c~kthread-add-kthread_stop_put +1 -2
@@ -699,8 +699,7 @@ static int __damon_stop(struct damon_ctxif (tsk) {get_task_struct (tsk);mutex_unlock (&ctx->kdamond_lock); -kthread_stop (tsk); -put_task_struct (tsk); +kthread_stop_put (tsk);return 0 ; }mutex_unlock (&ctx->kdamond_lock);
net/core/pktgen.c renamed from net/core/pktgen.c~kthread-add-kthread_stop_put +1 -2
@@ -3982,8 +3982,7 @@ static void __net_exit pg_net_exit(struclist_for_each_safe (q, n, &list) { t = list_entry(q, struct pktgen_thread, th_list);list_del (&t->th_list); -kthread_stop (t->tsk); -put_task_struct (t->tsk); +kthread_stop_put (t->tsk);kfree (t); }
_
Patches currently in -mm which might be from [email protected] are