Re: [PATCH v9 08/12] kthread: Detect when a kthread work is used by more workers
From: Tejun Heo
Date: Mon Jun 20 2016 - 16:12:58 EST
Hello,
On Thu, Jun 16, 2016 at 01:17:27PM +0200, Petr Mladek wrote:
> diff --git a/kernel/kthread.c b/kernel/kthread.c
> index 567ec49b4872..8e9548649c86 100644
> --- a/kernel/kthread.c
> +++ b/kernel/kthread.c
> @@ -574,6 +574,9 @@ EXPORT_SYMBOL_GPL(__kthread_init_worker);
> * The works are not allowed to keep any locks, disable preemption or interrupts
> * when they finish. There is defined a safe point for freezing when one work
> * finishes and before a new one is started.
> + *
> + * Also the works must not be handled by more workers at the same time, see also
^
than one
> + * kthread_queue_work().
> */
> int kthread_worker_fn(void *worker_ptr)
> {
> @@ -710,12 +713,21 @@ kthread_create_worker_on_cpu(int cpu, const char namefmt[], ...)
> }
> EXPORT_SYMBOL(kthread_create_worker_on_cpu);
>
> +static void kthread_insert_work_sanity_check(struct kthread_worker *worker,
> + struct kthread_work *work)
> +{
> + lockdep_assert_held(&worker->lock);
> + WARN_ON_ONCE(!list_empty(&work->node));
> + /* Do not use a work with more workers, see kthread_queue_work() */
^
ditto, maybe just say ">1 workers"?
Looks good otherwise.
Thanks.
--
tejun