public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Gautham R Shenoy <ego@in.ibm.com>
To: Gautham R Shenoy <ego@in.ibm.com>
Cc: rusty@rustcorp.com.au, torvalds@osdl.org, mingo@elte.hu,
	akpm@osdl.org, linux-kernel@vger.kernel.org, paulmck@us.ibm.com,
	vatsa@in.ibm.com, dipankar@in.ibm.com, gaughen@us.ibm.com,
	arjan@linux.intel.org, davej@redhat.com,
	venkatesh.pallipadi@intel.com, kiran@scalex86.org
Subject: [PATCH 5/5] lock_cpu_hotplug: Redesign - Lockdep support for lightweight lock_cpu_hotplug.
Date: Thu, 26 Oct 2006 16:28:31 +0530	[thread overview]
Message-ID: <20061026105831.GF11803@in.ibm.com> (raw)
In-Reply-To: <20061026105731.GE11803@in.ibm.com>

Add lockdep support to (refcount+waitqueue) implementation of
lock_cpu_hotplug.

Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>

---
 kernel/cpu.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+)

Index: hotplug/kernel/cpu.c
===================================================================
--- hotplug.orig/kernel/cpu.c
+++ hotplug/kernel/cpu.c
@@ -23,6 +23,7 @@
 #include <linux/types.h>
 #include <linux/wait.h>
 #include <linux/rcupdate.h>
+#include <linux/lockdep.h>
 
 static __cpuinitdata RAW_NOTIFIER_HEAD(cpu_chain);
 
@@ -61,6 +62,9 @@ static struct {
 	spinlock_t lock;
 	wait_queue_head_t read_queue;
 	wait_queue_head_t write_queue;
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+	struct lockdep_map dep_map;
+#endif
 } cpu_hotplug;
 
 DEFINE_PER_CPU(int, refcount) = {0};
@@ -83,6 +87,16 @@ static inline int nr_readers(void)
 	return count;
 }
 
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+static inline void cpu_hotplug_lockdep_init(void)
+{
+	static struct lock_class_key __key;
+	lockdep_init_map(&cpu_hotplug.dep_map, "cpu-hotplug-lock", &__key, 0);
+}
+#else
+	#define cpu_hotplug_lockdep_init() do { } while (0);
+#endif
+
 #ifdef CONFIG_HOTPLUG_CPU
 void __init cpu_hotplug_init(void)
 {
@@ -90,6 +104,7 @@ void __init cpu_hotplug_init(void)
 	spin_lock_init(&cpu_hotplug.lock);
 	init_waitqueue_head(&cpu_hotplug.read_queue);
 	init_waitqueue_head(&cpu_hotplug.write_queue);
+	cpu_hotplug_lockdep_init();
 }
 
 static void slow_path_reader_lock(void);
@@ -105,6 +120,7 @@ static void slow_path_reader_unlock(void
 */
 void lock_cpu_hotplug(void)
 {
+	rwlock_acquire_read(&cpu_hotplug.dep_map, 0, 0, _RET_IP_);
 	preempt_disable();
 	if (likely(!writer_exists())) {
 		per_cpu(refcount, smp_processor_id())++;
@@ -118,6 +134,7 @@ EXPORT_SYMBOL_GPL(lock_cpu_hotplug);
 
 void unlock_cpu_hotplug(void)
 {
+	rwlock_release(&cpu_hotplug.dep_map, 1, _RET_IP_);
 	preempt_disable();
 	if (likely(!writer_exists())) {
 		per_cpu(refcount, smp_processor_id())--;
@@ -135,6 +152,8 @@ static void cpu_hotplug_begin(void)
 {
 	DECLARE_WAITQUEUE(wait, current);
 
+	rwlock_acquire(&cpu_hotplug.dep_map, 0, 0, _RET_IP_);
+
 	spin_lock(&cpu_hotplug.lock);
 	if (likely(cpu_hotplug.status == NO_WRITERS)) {
 		cpu_hotplug.status = WRITER_WAITING;
@@ -165,6 +184,7 @@ static void cpu_hotplug_begin(void)
 
 static void cpu_hotplug_done(void)
 {
+	rwlock_release(&cpu_hotplug.dep_map, 1, _RET_IP_);
 	spin_lock(&cpu_hotplug.lock);
 
 	if (!list_empty(&cpu_hotplug.write_queue.task_list))
-- 
Gautham R Shenoy
Linux Technology Center
IBM India.
"Freedom comes with a price tag of responsibility, which is still a bargain,
because Freedom is priceless!"

  reply	other threads:[~2006-10-26 10:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-26 10:48 [RFC 0/5] lock_cpu_hotplug: Redesign - A "lightweight" scalable version Gautham R Shenoy
2006-10-26 10:50 ` [PATCH 1/5] lock_cpu_hotplug:Redesign - Fix coding style issues in cpufreq Gautham R Shenoy
2006-10-26 10:53   ` [PATCH 2/5] lock_cpu_hotplug:Redesign - remove lock_cpu_hotplug from hot-cpu_callback path " Gautham R Shenoy
2006-10-26 10:55     ` [PATCH 3/5] lock_cpu_hotplug:Redesign - Use lock_cpu_hotplug in workqueue.c instead of workqueue_mutex Gautham R Shenoy
2006-10-26 10:57       ` [PATCH 4/5] lock_cpu_hotplug: Redesign - Lightweight implementation of lock_cpu_hotplug Gautham R Shenoy
2006-10-26 10:58         ` Gautham R Shenoy [this message]
2006-10-26 21:14         ` Paul Jackson
2006-10-27  3:49           ` Gautham R Shenoy

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=20061026105831.GF11803@in.ibm.com \
    --to=ego@in.ibm.com \
    --cc=akpm@osdl.org \
    --cc=arjan@linux.intel.org \
    --cc=davej@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=gaughen@us.ibm.com \
    --cc=kiran@scalex86.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulmck@us.ibm.com \
    --cc=rusty@rustcorp.com.au \
    --cc=torvalds@osdl.org \
    --cc=vatsa@in.ibm.com \
    --cc=venkatesh.pallipadi@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox