plist: Make plist debugging raw_spinlock aware
Thomas Gleixner [Tue, 17 Nov 2009 13:46:14 +0000 (14:46 +0100)]
plists are used with spinlocks and raw_spinlocks. Change the plist
debugging to handle both types.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Ingo Molnar <mingo@elte.hu>

include/linux/plist.h
kernel/futex.c
lib/plist.c

index 45926d7..8227f71 100644 (file)
@@ -81,7 +81,8 @@ struct plist_head {
        struct list_head prio_list;
        struct list_head node_list;
 #ifdef CONFIG_DEBUG_PI_LIST
-       spinlock_t *lock;
+       raw_spinlock_t *rawlock;
+       spinlock_t *spinlock;
 #endif
 };
 
@@ -91,9 +92,11 @@ struct plist_node {
 };
 
 #ifdef CONFIG_DEBUG_PI_LIST
-# define PLIST_HEAD_LOCK_INIT(_lock)   .lock = _lock
+# define PLIST_HEAD_LOCK_INIT(_lock)           .spinlock = _lock
+# define PLIST_HEAD_LOCK_INIT_RAW(_lock)       .rawlock = _lock
 #else
 # define PLIST_HEAD_LOCK_INIT(_lock)
+# define PLIST_HEAD_LOCK_INIT_RAW(_lock)
 #endif
 
 #define _PLIST_HEAD_INIT(head)                         \
@@ -107,11 +110,22 @@ struct plist_node {
  */
 #define PLIST_HEAD_INIT(head, _lock)                   \
 {                                                      \
-        _PLIST_HEAD_INIT(head),                         \
+       _PLIST_HEAD_INIT(head),                         \
        PLIST_HEAD_LOCK_INIT(&(_lock))                  \
 }
 
 /**
+ * PLIST_HEAD_INIT_RAW - static struct plist_head initializer
+ * @head:      struct plist_head variable name
+ * @_lock:     lock to initialize for this list
+ */
+#define PLIST_HEAD_INIT_RAW(head, _lock)               \
+{                                                      \
+       _PLIST_HEAD_INIT(head),                         \
+       PLIST_HEAD_LOCK_INIT_RAW(&(_lock))              \
+}
+
+/**
  * PLIST_NODE_INIT - static struct plist_node initializer
  * @node:      struct plist_node variable name
  * @__prio:    initial node priority
@@ -119,13 +133,13 @@ struct plist_node {
 #define PLIST_NODE_INIT(node, __prio)                  \
 {                                                      \
        .prio  = (__prio),                              \
-       .plist = { _PLIST_HEAD_INIT((node).plist) },    \
+       .plist = { _PLIST_HEAD_INIT((node).plist) },    \
 }
 
 /**
  * plist_head_init - dynamic struct plist_head initializer
  * @head:      &struct plist_head pointer
- * @lock:      list spinlock, remembered for debugging
+ * @lock:      spinlock protecting the list (debugging)
  */
 static inline void
 plist_head_init(struct plist_head *head, spinlock_t *lock)
@@ -133,7 +147,24 @@ plist_head_init(struct plist_head *head, spinlock_t *lock)
        INIT_LIST_HEAD(&head->prio_list);
        INIT_LIST_HEAD(&head->node_list);
 #ifdef CONFIG_DEBUG_PI_LIST
-       head->lock = lock;
+       head->spinlock = lock;
+       head->rawlock = NULL;
+#endif
+}
+
+/**
+ * plist_head_init_raw - dynamic struct plist_head initializer
+ * @head:      &struct plist_head pointer
+ * @lock:      raw_spinlock protecting the list (debugging)
+ */
+static inline void
+plist_head_init_raw(struct plist_head *head, raw_spinlock_t *lock)
+{
+       INIT_LIST_HEAD(&head->prio_list);
+       INIT_LIST_HEAD(&head->node_list);
+#ifdef CONFIG_DEBUG_PI_LIST
+       head->rawlock = lock;
+       head->spinlock = NULL;
 #endif
 }
 
index d73ef1f..6af474d 100644 (file)
@@ -1010,7 +1010,7 @@ void requeue_futex(struct futex_q *q, struct futex_hash_bucket *hb1,
                plist_add(&q->list, &hb2->chain);
                q->lock_ptr = &hb2->lock;
 #ifdef CONFIG_DEBUG_PI_LIST
-               q->list.plist.lock = &hb2->lock;
+               q->list.plist.spinlock = &hb2->lock;
 #endif
        }
        get_futex_key_refs(key2);
@@ -1046,7 +1046,7 @@ void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key,
 
        q->lock_ptr = &hb->lock;
 #ifdef CONFIG_DEBUG_PI_LIST
-       q->list.plist.lock = &hb->lock;
+       q->list.plist.spinlock = &hb->lock;
 #endif
 
        wake_up_state(q->task, TASK_NORMAL);
@@ -1394,7 +1394,7 @@ static inline void queue_me(struct futex_q *q, struct futex_hash_bucket *hb)
 
        plist_node_init(&q->list, prio);
 #ifdef CONFIG_DEBUG_PI_LIST
-       q->list.plist.lock = &hb->lock;
+       q->list.plist.spinlock = &hb->lock;
 #endif
        plist_add(&q->list, &hb->chain);
        q->task = current;
index d6c64a8..1471988 100644 (file)
@@ -54,9 +54,11 @@ static void plist_check_list(struct list_head *top)
 
 static void plist_check_head(struct plist_head *head)
 {
-       WARN_ON(!head->lock);
-       if (head->lock)
-               WARN_ON_SMP(!spin_is_locked(head->lock));
+       WARN_ON(!head->rawlock && !head->spinlock);
+       if (head->rawlock)
+               WARN_ON_SMP(!raw_spin_is_locked(head->rawlock));
+       if (head->spinlock)
+               WARN_ON_SMP(!spin_is_locked(head->spinlock));
        plist_check_list(&head->prio_list);
        plist_check_list(&head->node_list);
 }