Messages in this thread Patch in this message | | | Date | Thu, 26 Oct 2006 16:28:31 +0530 | From | Gautham R Shenoy <> | Subject | [PATCH 5/5] lock_cpu_hotplug: Redesign - Lockdep support for lightweight lock_cpu_hotplug. |
| |
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!" - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |