All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shaohua Li <shaohua.li@intel.com>
To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org
Cc: mingo@elte.hu, akpm@linux-foundation.org, lenb@kernel.org
Subject: [PATCH 1/2]workqueue:introduce INIT_WORK_KEY()
Date: Fri, 11 Dec 2009 11:04:31 +0800	[thread overview]
Message-ID: <20091211030431.GA7772@sli10-desk.sh.intel.com> (raw)

Introduce INIT_WORK_KEY(). lockdep key is static in a function. If a function
uses INIT_WORK() to initialize works for different workqueue, the works will
share a lockdep key incorrectly and cause lockdep fase alarm sometimes.
Next patch will use the new API to solve one ACPI issue.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
---
 include/linux/workqueue.h |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Index: linux/include/linux/workqueue.h
===================================================================
--- linux.orig/include/linux/workqueue.h	2009-12-10 10:14:56.000000000 +0800
+++ linux/include/linux/workqueue.h	2009-12-10 10:39:30.000000000 +0800
@@ -99,15 +99,20 @@ struct execute_work {
  * to generate better code.
  */
 #ifdef CONFIG_LOCKDEP
-#define INIT_WORK(_work, _func)						\
+#define INIT_WORK_KEY(_work, _func, _key, _key_name) 			\
 	do {								\
-		static struct lock_class_key __key;			\
-									\
 		(_work)->data = (atomic_long_t) WORK_DATA_INIT();	\
-		lockdep_init_map(&(_work)->lockdep_map, #_work, &__key, 0);\
+		lockdep_init_map(&(_work)->lockdep_map, _key_name, 	\
+				&_key, 0);				\
 		INIT_LIST_HEAD(&(_work)->entry);			\
 		PREPARE_WORK((_work), (_func));				\
 	} while (0)
+
+#define INIT_WORK(_work, _func)						\
+	do {								\
+		static struct lock_class_key __key;			\
+		INIT_WORK_KEY(_work, _func, __key, #_work);		\
+	} while (0)
 #else
 #define INIT_WORK(_work, _func)						\
 	do {								\
@@ -115,6 +120,9 @@ struct execute_work {
 		INIT_LIST_HEAD(&(_work)->entry);			\
 		PREPARE_WORK((_work), (_func));				\
 	} while (0)
+
+#define INIT_WORK_KEY(_work, _func, _key, _key_name) 			\
+	INIT_WORK(_work, _func)
 #endif
 
 #define INIT_DELAYED_WORK(_work, _func)				\

                 reply	other threads:[~2009-12-11  3:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091211030431.GA7772@sli10-desk.sh.intel.com \
    --to=shaohua.li@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.