tools headers UAPI: Synch KVM's svm.h header with the kernel
[linux-2.6-microblaze.git] / kernel / kthread.c
index 6b0a30a..5b37a85 100644 (file)
@@ -1162,14 +1162,14 @@ static bool __kthread_cancel_work(struct kthread_work *work)
  * modify @dwork's timer so that it expires after @delay. If @delay is zero,
  * @work is guaranteed to be queued immediately.
  *
- * Return: %true if @dwork was pending and its timer was modified,
- * %false otherwise.
+ * Return: %false if @dwork was idle and queued, %true otherwise.
  *
  * A special case is when the work is being canceled in parallel.
  * It might be caused either by the real kthread_cancel_delayed_work_sync()
  * or yet another kthread_mod_delayed_work() call. We let the other command
- * win and return %false here. The caller is supposed to synchronize these
- * operations a reasonable way.
+ * win and return %true here. The return value can be used for reference
+ * counting and the number of queued works stays the same. Anyway, the caller
+ * is supposed to synchronize these operations a reasonable way.
  *
  * This function is safe to call from any context including IRQ handler.
  * See __kthread_cancel_work() and kthread_delayed_work_timer_fn()
@@ -1181,13 +1181,15 @@ bool kthread_mod_delayed_work(struct kthread_worker *worker,
 {
        struct kthread_work *work = &dwork->work;
        unsigned long flags;
-       int ret = false;
+       int ret;
 
        raw_spin_lock_irqsave(&worker->lock, flags);
 
        /* Do not bother with canceling when never queued. */
-       if (!work->worker)
+       if (!work->worker) {
+               ret = false;
                goto fast_queue;
+       }
 
        /* Work must not be used with >1 worker, see kthread_queue_work() */
        WARN_ON_ONCE(work->worker != worker);
@@ -1205,8 +1207,11 @@ bool kthread_mod_delayed_work(struct kthread_worker *worker,
         * be used for reference counting.
         */
        kthread_cancel_delayed_work_timer(work, &flags);
-       if (work->canceling)
+       if (work->canceling) {
+               /* The number of works in the queue does not change. */
+               ret = true;
                goto out;
+       }
        ret = __kthread_cancel_work(work);
 
 fast_queue: