History

unify flush_work/flush_work_keventd and rename it to cancel_work_sync

flush_work(wq, work) doesn't need the first parameter, we can use cwq->wq (this was possible from the very beginnig, I missed this). So we can unify flush_work_keventd and flush_work. Also, rename flush_work() to cancel_work_sync() and fix all callers. Perhaps this is not the best name, but "flush_work" is really bad. (akpm: this is why the earlier patches bypassed maintainers)

Oleg Nesterov committed 19 years ago

Commit 28e53bd1 parent 5830c599 files · +41 −40Browse files

Showing the changes to kernel/workqueue.c (1 of 9 files). Show all

Unified · Split

kernel/workqueue.c+17−19
@@ -413,23 +413,23 @@ static void wait_on_work(struct cpu_workqueue_struct *cwq, · 412 unmodified lines
413413 }
414414
415415 /**
416− * flush_work - block until a work_struct's callback has terminated
417− * @wq: the workqueue on which the work is queued
416+ * cancel_work_sync - block until a work_struct's callback has terminated
418417 * @work: the work which is to be flushed
419418 *
420− * flush_work() will attempt to cancel the work if it is queued. If the work's
421− * callback appears to be running, flush_work() will block until it has
422− * completed.
419+ * cancel_work_sync() will attempt to cancel the work if it is queued. If the
420+ * work's callback appears to be running, cancel_work_sync() will block until
421+ * it has completed.
423422 *
424− * flush_work() is designed to be used when the caller is tearing down data
425− * structures which the callback function operates upon. It is expected that,
426− * prior to calling flush_work(), the caller has arranged for the work to not
427− * be requeued.
423+ * cancel_work_sync() is designed to be used when the caller is tearing down
424+ * data structures which the callback function operates upon. It is expected
425+ * that, prior to calling cancel_work_sync(), the caller has arranged for the
426+ * work to not be requeued.
428427 */
429−void flush_work(struct workqueue_struct *wq, struct work_struct *work)
428+void cancel_work_sync(struct work_struct *work)
430429 {
431− const cpumask_t *cpu_map = wq_cpu_map(wq);
432430 struct cpu_workqueue_struct *cwq;
431+ struct workqueue_struct *wq;
432+ const cpumask_t *cpu_map;
433433 int cpu;
434434
435435 might_sleep();
@@ -448,10 +448,13 @@ void flush_work(struct workqueue_struct *wq, struct work_struct *work) · 12 unmodified lines
448448 work_clear_pending(work);
449449 spin_unlock_irq(&cwq->lock);
450450
451+ wq = cwq->wq;
452+ cpu_map = wq_cpu_map(wq);
453+
451454 for_each_cpu_mask(cpu, *cpu_map)
452455 wait_on_work(per_cpu_ptr(wq->cpu_wq, cpu), work);
453456 }
454−EXPORT_SYMBOL_GPL(flush_work);
457+EXPORT_SYMBOL_GPL(cancel_work_sync);
455458
456459
457460 static struct workqueue_struct *keventd_wq;
@@ -540,18 +543,13 @@ void flush_scheduled_work(void) · 82 unmodified lines
540543 }
541544 EXPORT_SYMBOL(flush_scheduled_work);
542545
543−void flush_work_keventd(struct work_struct *work)
544−{
545− flush_work(keventd_wq, work);
546−}
547−EXPORT_SYMBOL(flush_work_keventd);
548−
549546 /**
550547 * cancel_rearming_delayed_work - kill off a delayed work whose handler rearms the delayed work.
551548 * @dwork: the delayed work struct
552549 *
553550 * Note that the work callback function may still be running on return from
554− * cancel_delayed_work(). Run flush_workqueue() or flush_work() to wait on it.
551+ * cancel_delayed_work(). Run flush_workqueue() or cancel_work_sync() to wait
552+ * on it.
555553 */
556554 void cancel_rearming_delayed_work(struct delayed_work *dwork)
557555 {