public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	linux-kernel@vger.kernel.org
Cc: Jiri Kosina <jikos@jikos.cz>, Andrew Morton <akpm@osdl.org>,
	Arjan van de Ven <arjan@infradead.org>,
	Dave Jones <davej@redhat.com>, Ingo Molnar <mingo@elte.hu>
Subject: [PATCH 2/2] serio: lockdep annotation for ps2dev->cmd_mutex and serio->lock
Date: Tue, 26 Sep 2006 13:31:52 +0200	[thread overview]
Message-ID: <20060926113748.833215000@chello.nl> (raw)
In-Reply-To: 20060926113150.294656000@chello.nl

[-- Attachment #1: serio-lockdep.patch --]
[-- Type: text/plain, Size: 2749 bytes --]

Based ideas from Jiri Kosina, this patch tracks the nesting depth
and uses the new lockdep_set_class_and_subclass() annotation to store
this information in the lock objects.

Signed-of-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 drivers/input/serio/libps2.c |    4 ++++
 drivers/input/serio/serio.c  |    9 ++++++++-
 include/linux/serio.h        |    1 +
 3 files changed, 13 insertions(+), 1 deletion(-)

Index: linux-2.6-mm/drivers/input/serio/libps2.c
===================================================================
--- linux-2.6-mm.orig/drivers/input/serio/libps2.c	2006-09-26 10:25:22.000000000 +0200
+++ linux-2.6-mm/drivers/input/serio/libps2.c	2006-09-26 10:34:49.000000000 +0200
@@ -280,6 +280,8 @@ int ps2_schedule_command(struct ps2dev *
 	return 0;
 }
 
+static struct lock_class_key ps2_mutex_key;
+
 /*
  * ps2_init() initializes ps2dev structure
  */
@@ -287,6 +289,8 @@ int ps2_schedule_command(struct ps2dev *
 void ps2_init(struct ps2dev *ps2dev, struct serio *serio)
 {
 	mutex_init(&ps2dev->cmd_mutex);
+	lockdep_set_class_and_subclass(&ps2dev->cmd_mutex, &ps2_mutex_key,
+				       serio->depth);
 	init_waitqueue_head(&ps2dev->wait);
 	ps2dev->serio = serio;
 }
Index: linux-2.6-mm/drivers/input/serio/serio.c
===================================================================
--- linux-2.6-mm.orig/drivers/input/serio/serio.c	2006-09-26 10:25:22.000000000 +0200
+++ linux-2.6-mm/drivers/input/serio/serio.c	2006-09-26 10:34:04.000000000 +0200
@@ -521,6 +521,8 @@ static void serio_release_port(struct de
 	module_put(THIS_MODULE);
 }
 
+static struct lock_class_key serio_lock_key;
+
 /*
  * Prepare serio port for registration.
  */
@@ -538,8 +540,13 @@ static void serio_init_port(struct serio
 		 "serio%ld", (long)atomic_inc_return(&serio_no) - 1);
 	serio->dev.bus = &serio_bus;
 	serio->dev.release = serio_release_port;
-	if (serio->parent)
+	if (serio->parent) {
 		serio->dev.parent = &serio->parent->dev;
+		serio->depth = serio->parent->depth + 1;
+	} else
+		serio->depth = 0;
+	lockdep_set_class_and_subclass(&serio->lock, &serio_lock_key,
+				       serio->depth);
 }
 
 /*
Index: linux-2.6-mm/include/linux/serio.h
===================================================================
--- linux-2.6-mm.orig/include/linux/serio.h	2006-09-26 10:25:22.000000000 +0200
+++ linux-2.6-mm/include/linux/serio.h	2006-09-26 10:34:04.000000000 +0200
@@ -41,6 +41,7 @@ struct serio {
 	void (*stop)(struct serio *);
 
 	struct serio *parent, *child;
+	unsigned int depth;		/* level of nesting in serio hierarchy */
 
 	struct serio_driver *drv;	/* accessed from interrupt, must be protected by serio->lock and serio->sem */
 	struct mutex drv_mutex;		/* protects serio->drv so attributes can pin driver */

--


  parent reply	other threads:[~2006-09-26 11:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-26 11:31 [PATCH 0/2] serio lockdep annotation Peter Zijlstra
2006-09-26 11:31 ` [PATCH 1/2] lockdep: lockdep_set_class_and_subclass Peter Zijlstra
2006-09-26 11:54   ` Ingo Molnar
2006-09-26 12:20     ` Dmitry Torokhov
2006-09-26 11:31 ` Peter Zijlstra [this message]
2006-09-26 13:21   ` [PATCH 2/2] serio: lockdep annotation for ps2dev->cmd_mutex and serio->lock Jiri Kosina
2006-09-26 13:36     ` Peter Zijlstra
2006-09-26 13:30       ` Ingo Molnar

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=20060926113748.833215000@chello.nl \
    --to=a.p.zijlstra@chello.nl \
    --cc=akpm@osdl.org \
    --cc=arjan@infradead.org \
    --cc=davej@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jikos@jikos.cz \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox