Re: [PATCH v9 08/12] kthread: Detect when a kthread work is used by more workers
From: Tejun Heo <tj@kernel.org>
Date: 2016-06-20 20:12:55
Also in:
linux-mm, lkml
Hello, On Thu, Jun 16, 2016 at 01:17:27PM +0200, Petr Mladek wrote:
quoted hunk ↗ jump to hunk
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
quoted hunk ↗ jump to hunk
+ * 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 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>