[lkml]   [2010]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] kthread_worker: Initialize dynamically allocated spinlock properly for lockdep
init_kthread_worker(), via KTHREAD_WORKER_INIT(), used an
initializer for static spin_lock objects, SPIN_LOCK_UNLOCKED, on
a dynamically allocated kthread_worker object's internal spinlock_t.
This causes lockdep to gripe:

INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.

To keep lockdep happy, use spin_lock_init() for dynamically
allocated kthread_worker objects' internal spinlock_t.

Reported-by: Nicolas <>
Signed-off-by: Andy Walls <>

Cc: Tejun Heo <>
Cc: Jarod Wilson <>
Cc: Ingo Molnar <>
Cc: Mauro Carvalho Chehab <>
Cc: Hans Verkuil <>

diff --git a/include/linux/kthread.h b/include/linux/kthread.h
index 685ea65..e65d0b1 100644
--- a/include/linux/kthread.h
+++ b/include/linux/kthread.h
@@ -83,7 +83,13 @@ struct kthread_work {

static inline void init_kthread_worker(struct kthread_worker *worker)
- *worker = (struct kthread_worker)KTHREAD_WORKER_INIT(*worker);
+ /*
+ * Lockdep complains if a dynamically allocated worker's spinlock_t
+ * is initialzed using SPIN_LOCK_UNLOCKED.
+ */
+ spin_lock_init(&worker->lock);
+ INIT_LIST_HEAD(&worker->work_list);
+ worker->task = NULL;

static inline void init_kthread_work(struct kthread_work *work,

 \ /
  Last update: 2010-12-19 14:53    [W:0.118 / U:0.292 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site