Re: [V2 PATCH] kthread_work: Make lockdep happy

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andy Walls
Date: Tuesday, December 21, 2010 - 5:39 pm

On Tue, 2010-12-21 at 12:40 +0800, Yong Zhang wrote:

Yong,

I have tested your patch with the following patch on top of yours.  I
find the two patches together acceptable in testing in a machine with
both a PVR-350 card and a PVR-500 card installed.

Tested-by: Andy Walls <awalls@md.metrocast.net>
Signed-off-by: Andy Walls <awalls@md.metrocast.net>

Could you please author a [V3 PATCH] adding my changes?  Since the
majority of the change is your work, it should be attributed to you as
the author.


About my additional changes:

I needed the explicit EXPORT_SYMBOL_GPL(__init_kthread_worker),
otherwise the build would fail, because the ivtv module had an
unresolved symbol.

I added the lockdep class name to make it easier to identify the ivtv
module's kthread worker's lock class.  Now one can actually recognize
the lock class in lockdep output strings:

	# cat lockdep | grep itv
	ffffffffa0483a60 FD:    1 BD:    1 ......: (&itv->irq_worker)->lock

Thanks again.

Regards,
Andy


diff --git a/include/linux/kthread.h b/include/linux/kthread.h
index f8b3320..994564a 100644
--- a/include/linux/kthread.h
+++ b/include/linux/kthread.h
@@ -100,13 +100,15 @@ struct kthread_work {
 # define DEFINE_KTHREAD_WORK_ONSTACK(work, fn) DEFINE_KTHREAD_WORK(work, fn)
 #endif
 
-extern void __init_kthread_worker(struct kthread_worker *worker,
-					struct lock_class_key *key);
+void __init_kthread_worker(struct kthread_worker *worker,
+			   struct lock_class_key *key,
+			   const char *lock_class_name);
 
 #define init_kthread_worker(worker)					\
 	do {								\
 		static struct lock_class_key __key;			\
-		__init_kthread_worker((worker), &__key);		\
+		__init_kthread_worker((worker), &__key,			\
+				      "(" #worker ")->lock");		\
 	} while (0)
 
 #define init_kthread_work(work, fn)					\
diff --git a/kernel/kthread.c b/kernel/kthread.c
index f760587..4657ebd 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -266,13 +266,15 @@ int kthreadd(void *unused)
 }
 
 void __init_kthread_worker(struct kthread_worker *worker,
-				struct lock_class_key *key)
+			   struct lock_class_key *key,
+			   const char *lock_class_name)
 {
 	spin_lock_init(&worker->lock);
-	lockdep_set_class(&worker->lock, key);
+	lockdep_set_class_and_name(&worker->lock, key, lock_class_name);
 	INIT_LIST_HEAD(&worker->work_list);
 	worker->task = NULL;
 }
+EXPORT_SYMBOL_GPL(__init_kthread_worker);
 
 /**
  * kthread_worker_fn - kthread function to process kthread_worker


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[V2 PATCH] kthread_work: Make lockdep happy, Yong Zhang, (Mon Dec 20, 9:40 pm)
Re: [V2 PATCH] kthread_work: Make lockdep happy, Tejun Heo, (Tue Dec 21, 5:59 am)
Re: [V2 PATCH] kthread_work: Make lockdep happy, Nicolas Mailhot, (Tue Dec 21, 6:25 am)
Re: [V2 PATCH] kthread_work: Make lockdep happy, Andy Walls, (Tue Dec 21, 9:07 am)
Re: [V2 PATCH] kthread_work: Make lockdep happy, Andy Walls, (Tue Dec 21, 5:39 pm)
Re: [V2 PATCH] kthread_work: Make lockdep happy, Yong Zhang, (Tue Dec 21, 8:12 pm)
[V3 PATCH] kthread_work: Make lockdep happy, Yong Zhang, (Tue Dec 21, 8:23 pm)
Re: [V3 PATCH] kthread_work: Make lockdep happy, Tejun Heo, (Wed Dec 22, 2:33 am)