Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1429107
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v9 06/12] kthread: Add kthread_drain_worker() |
| Date | 2016-06-22 23:00 +0200 |
| Message-ID | <rMXpD-8nQ-1@gated-at.bofh.it> (permalink) |
| References | <rKDv3-7Hj-3@gated-at.bofh.it> <rKDv4-7Hj-31@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, Jun 16, 2016 at 01:17:25PM +0200, Petr Mladek wrote:
> +/**
> + * kthread_drain_worker - drain a kthread worker
> + * @worker: worker to be drained
> + *
> + * Wait until there is no work queued for the given kthread worker.
> + * @worker is flushed repeatedly until it becomes empty. The number
> + * of flushing is determined by the depth of chaining and should
> + * be relatively short. Whine if it takes too long.
> + *
> + * The caller is responsible for blocking all users of this kthread
> + * worker from queuing new works. Also it is responsible for blocking
> + * the already queued works from an infinite re-queuing!
This, I really dislike that. And it makes the kthread_destroy_worker()
from the next patch unnecessarily fragile.
Why not add a kthread_worker::blocked flag somewhere and refuse/WARN
kthread_queue_work() when that is set.
> + */
> +void kthread_drain_worker(struct kthread_worker *worker)
> +{
> + int flush_cnt = 0;
> +
> + spin_lock_irq(&worker->lock);
> +
> + while (!list_empty(&worker->work_list)) {
> + spin_unlock_irq(&worker->lock);
> +
> + kthread_flush_worker(worker);
> + WARN_ONCE(flush_cnt++ > 10,
> + "kthread worker %s: kthread_drain_worker() isn't complete after %u tries\n",
> + worker->task->comm, flush_cnt);
> +
> + spin_lock_irq(&worker->lock);
> + }
> +
> + spin_unlock_irq(&worker->lock);
> +}
> +EXPORT_SYMBOL(kthread_drain_worker);
> --
> 1.8.5.6
>
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH v9 06/12] kthread: Add kthread_drain_worker() Petr Mladek <pmladek@suse.com> - 2016-06-16 13:20 +0200 Re: [PATCH v9 06/12] kthread: Add kthread_drain_worker() Tejun Heo <tj@kernel.org> - 2016-06-20 22:00 +0200 Re: [PATCH v9 06/12] kthread: Add kthread_drain_worker() Peter Zijlstra <peterz@infradead.org> - 2016-06-22 23:00 +0200
csiph-web