mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
kthread: add kthread_stop_put
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(). [agruenba@redhat.com: fix kerneldoc comment] Link: https://lkml.kernel.org/r/20230911111730.2565537-1-agruenba@redhat.com [akpm@linux-foundation.org: document kthread_stop_put()'s argument] Link: https://lkml.kernel.org/r/20230907234048.2499820-1-agruenba@redhat.com Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
ed5378a387
commit
6309727ef2
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user