]> Git Repo - linux.git/commitdiff
Merge tag 'interrupting_kthread_stop-for-v5.20' of git://git.kernel.org/pub/scm/linux...
authorLinus Torvalds <[email protected]>
Sun, 9 Oct 2022 23:01:59 +0000 (16:01 -0700)
committerLinus Torvalds <[email protected]>
Sun, 9 Oct 2022 23:01:59 +0000 (16:01 -0700)
Pull kthread update from Eric Biederman:
 "Break out of wait loops on kthread_stop()

  This is a small tweak to kthread_stop so it breaks out of
  interruptible waits, that don't explicitly test for kthread_stop.

  These interruptible waits occassionaly occur in kernel threads do to
  code sharing"

* tag 'interrupting_kthread_stop-for-v5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
  signal: break out of wait loops on kthread_stop()

1  2 
kernel/kthread.c

diff --combined kernel/kthread.c
index 28a6b7ab4a0fa8f810387583e6759075c4ab7936,4507004ca01c5f5c85c33d44a915ac167aa48216..f97fd01a29325f6d7f2e6d04ad5f87cb9d3577f3
@@@ -340,7 -340,7 +340,7 @@@ static int kthread(void *_create
  
        self = to_kthread(current);
  
 -      /* If user was SIGKILLed, I release the structure. */
 +      /* Release the structure when caller killed by a fatal signal. */
        done = xchg(&create->done, NULL);
        if (!done) {
                kfree(create);
@@@ -398,7 -398,7 +398,7 @@@ static void create_kthread(struct kthre
        /* We want our own signal handler (we take no signals by default). */
        pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD);
        if (pid < 0) {
 -              /* If user was SIGKILLed, I release the structure. */
 +              /* Release the structure when caller killed by a fatal signal. */
                struct completion *done = xchg(&create->done, NULL);
  
                if (!done) {
@@@ -440,9 -440,9 +440,9 @@@ struct task_struct *__kthread_create_on
         */
        if (unlikely(wait_for_completion_killable(&done))) {
                /*
 -               * If I was SIGKILLed before kthreadd (or new kernel thread)
 -               * calls complete(), leave the cleanup of this structure to
 -               * that thread.
 +               * If I was killed by a fatal signal before kthreadd (or new
 +               * kernel thread) calls complete(), leave the cleanup of this
 +               * structure to that thread.
                 */
                if (xchg(&create->done, NULL))
                        return ERR_PTR(-EINTR);
@@@ -704,6 -704,7 +704,7 @@@ int kthread_stop(struct task_struct *k
        kthread = to_kthread(k);
        set_bit(KTHREAD_SHOULD_STOP, &kthread->flags);
        kthread_unpark(k);
+       set_tsk_thread_flag(k, TIF_NOTIFY_SIGNAL);
        wake_up_process(k);
        wait_for_completion(&kthread->exited);
        ret = kthread->result;
@@@ -876,7 -877,7 +877,7 @@@ fail_task
   *
   * Returns a pointer to the allocated worker on success, ERR_PTR(-ENOMEM)
   * when the needed structures could not get allocated, and ERR_PTR(-EINTR)
 - * when the worker was SIGKILLed.
 + * when the caller was killed by a fatal signal.
   */
  struct kthread_worker *
  kthread_create_worker(unsigned int flags, const char namefmt[], ...)
@@@ -925,7 -926,7 +926,7 @@@ EXPORT_SYMBOL(kthread_create_worker)
   * Return:
   * The pointer to the allocated worker on success, ERR_PTR(-ENOMEM)
   * when the needed structures could not get allocated, and ERR_PTR(-EINTR)
 - * when the worker was SIGKILLed.
 + * when the caller was killed by a fatal signal.
   */
  struct kthread_worker *
  kthread_create_worker_on_cpu(int cpu, unsigned int flags,
@@@ -1050,7 -1051,8 +1051,7 @@@ static void __kthread_queue_delayed_wor
        struct timer_list *timer = &dwork->timer;
        struct kthread_work *work = &dwork->work;
  
 -      WARN_ON_FUNCTION_MISMATCH(timer->function,
 -                                kthread_delayed_work_timer_fn);
 +      WARN_ON_ONCE(timer->function != kthread_delayed_work_timer_fn);
  
        /*
         * If @delay is 0, queue @dwork->work immediately.  This is for
This page took 0.063283 seconds and 4 git commands to generate.