linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <peterz@infradead.org>,
	Linux-Arch <linux-arch@vger.kernel.org>
Subject: [patch 13/23] plist: Make plist debugging raw_spinlock aware
Date: Sun, 06 Dec 2009 18:02:57 -0000	[thread overview]
Message-ID: <20091206111957.806855005@linutronix.de> (raw)
In-Reply-To: 20091206110944.492100233@linutronix.de

[-- Attachment #1: plist-make-core-lock-aware.patch --]
[-- Type: text/plain, Size: 4593 bytes --]

plists are used with spinlocks and raw_spinlocks. Change the plist
debugging to handle both types.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/plist.h |   43 +++++++++++++++++++++++++++++++++++++------
 kernel/futex.c        |    6 +++---
 lib/plist.c           |    8 +++++---
 3 files changed, 45 insertions(+), 12 deletions(-)

Index: linux-2.6-tip/include/linux/plist.h
===================================================================
--- linux-2.6-tip.orig/include/linux/plist.h
+++ linux-2.6-tip/include/linux/plist.h
@@ -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,
 	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: linux-2.6-tip/kernel/futex.c
===================================================================
--- linux-2.6-tip.orig/kernel/futex.c
+++ linux-2.6-tip/kernel/futex.c
@@ -1004,7 +1004,7 @@ void requeue_futex(struct futex_q *q, st
 		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);
@@ -1040,7 +1040,7 @@ void requeue_pi_wake_futex(struct futex_
 
 	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);
@@ -1388,7 +1388,7 @@ static inline void queue_me(struct futex
 
 	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: linux-2.6-tip/lib/plist.c
===================================================================
--- linux-2.6-tip.orig/lib/plist.c
+++ linux-2.6-tip/lib/plist.c
@@ -54,9 +54,11 @@ static void plist_check_list(struct list
 
 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);
 }

  parent reply	other threads:[~2009-12-06 18:02 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-06 18:01 [patch 00/23] locking: name space cleanup and -rt spinlock annotation Thomas Gleixner
2009-12-06 18:01 ` [patch 01/23] locking: Reorder functions in spinlock.c Thomas Gleixner
2009-12-06 18:01   ` Thomas Gleixner
2009-12-06 18:01 ` [patch 02/23] locking: Split rwlock from spinlock headers Thomas Gleixner
2009-12-07 17:28   ` Arnd Bergmann
2009-12-06 18:02 ` [patch 03/23] locking: Separate rwlock api from spinlock api Thomas Gleixner
2009-12-06 18:02   ` Thomas Gleixner
2009-12-06 18:02 ` [patch 04/23] locking: Convert raw_spinlock to arch_spinlock Thomas Gleixner
2009-12-06 18:10   ` Linus Torvalds
2009-12-06 18:19     ` Ingo Molnar
2009-12-06 18:02 ` [patch 05/23] locking: Rename __RAW_SPIN_LOCK_UNLOCKED to __ARCH_SPIN_LOCK_UNLOCKED Thomas Gleixner
2009-12-06 18:02   ` Thomas Gleixner
2009-12-06 18:02 ` [patch 06/23] locking: Convert __raw_spin* functions to arch_spin* Thomas Gleixner
2009-12-06 18:02 ` [patch 07/23] locking: Convert raw_rwlock to arch_rwlock Thomas Gleixner
2009-12-06 18:02   ` Thomas Gleixner
2009-12-06 18:02 ` [patch 08/23] locking: Convert raw_rwlock functions " Thomas Gleixner
2009-12-06 18:02   ` Thomas Gleixner
2009-12-06 18:02 ` [patch 09/23] locking: Implement new raw_spinlock Thomas Gleixner
2009-12-08 13:33   ` Yong Zhang
2009-12-06 18:02 ` [patch 10/23] locking: Further name space cleanups Thomas Gleixner
2009-12-06 18:02 ` [patch 11/23] locking: Cleanup the name space completely Thomas Gleixner
2009-12-06 18:02 ` [patch 12/23] bkl: Fixup core_lock fallout Thomas Gleixner
2009-12-06 18:02 ` Thomas Gleixner [this message]
2009-12-06 18:02   ` [patch 13/23] plist: Make plist debugging raw_spinlock aware Thomas Gleixner
2009-12-07  1:21   ` Frederic Weisbecker
2009-12-06 18:03 ` [patch 14/23] sched: Convert rq->lock to raw_spinlock Thomas Gleixner
2009-12-06 18:03   ` Thomas Gleixner
2009-12-06 18:03 ` [patch 15/23] sched: Convert rt_runtime_lock " Thomas Gleixner
2009-12-06 18:03   ` Thomas Gleixner
2009-12-06 18:03 ` [patch 16/23] sched: Convert cpupri lock " Thomas Gleixner
2009-12-06 18:03   ` Thomas Gleixner
2009-12-06 18:03 ` [patch 17/23] sched: Convert pi_lock " Thomas Gleixner
2009-12-06 18:03   ` Thomas Gleixner
2009-12-06 18:03 ` [patch 18/23] rtmutes: Convert rtmutex.lock " Thomas Gleixner
2009-12-06 18:03   ` Thomas Gleixner
2009-12-06 18:03 ` [patch 19/23] smp: Convert smplocks to raw_spinlocks Thomas Gleixner
2009-12-06 18:03 ` [patch 20/23] genirq: Convert irq_desc.lock to raw_spinlock Thomas Gleixner
2009-12-06 18:03   ` Thomas Gleixner
2009-12-06 18:03 ` [patch 21/23] hrtimers: Convert to raw_spinlocks Thomas Gleixner
2009-12-06 18:03 ` [patch 22/23] perf_event: Convert to raw_spinlock Thomas Gleixner
2009-12-06 18:03   ` Thomas Gleixner
2009-12-06 18:03 ` [patch 23/23] debugobjects: Convert to raw_spinlocks Thomas Gleixner

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=20091206111957.806855005@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.org \
    /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;
as well as URLs for NNTP newsgroup(s).