mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Bill Huey (hui)" <bill.huey@gmail.com>
To: "Gregory Haskins" <ghaskins@novell.com>, mingo@elte.hu
Cc: a.p.zijlstra@chello.nl, tglx@linutronix.de, rostedt@goodmis.org,
	linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	kevin@hilman.org, cminyard@mvista.com, dsingleton@mvista.com,
	dwalker@mvista.com, npiggin@suse.de, dsaxena@plexity.net,
	ak@suse.de, pavel@ucw.cz, acme@redhat.com, gregkh@suse.de,
	sdietrich@novell.com, pmorreale@novell.com, mkohari@novell.com
Subject: Re: [PATCH RT 1/6] lockstat measurement extensions
Date: Thu, 13 Mar 2008 17:07:49 -0700	[thread overview]
Message-ID: <9810cff90803131707v4fb3197fv396b8a5e8ae32b4d@mail.gmail.com> (raw)
In-Reply-To: <9810cff90803131703t3626d83fq727b04242f407c13@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 80 bytes --]

Function parameter extension macros and function prototype redefinitions.

bill

[-- Attachment #2: patch0.diff --]
[-- Type: application/octet-stream, Size: 7020 bytes --]

--- linux-2.6.24/include/linux/lockdep.h	2008-02-25 15:32:05.000000000 -0800
+++ linux-2.6.24.working/include/linux/lockdep.h	2008-03-13 14:02:43.000000000 -0700
@@ -19,6 +19,8 @@
 #include <linux/debug_locks.h>
 #include <linux/stacktrace.h>
 
+//#include <linux/rtmutex_common.h>
+
 /*
  * Lock-class usage-state bits:
  */
@@ -143,6 +145,10 @@
 
 struct lock_class_stats {
 	unsigned long			contention_point[4];
+#ifdef CONFIG_LOCK_STAT
+	unsigned long			spinnable;
+	unsigned long			stolen;
+#endif
 	struct lock_time		read_waittime;
 	struct lock_time		write_waittime;
 	struct lock_time		read_holdtime;
@@ -347,57 +353,190 @@
 
 #endif /* !LOCKDEP */
 
-#ifdef CONFIG_LOCK_STAT
+/*
+ * lockstat contention tracking is pushed down into the rtmutex implementation
+ * CONFIG_PREEMPT_RT instead.
+ */
+#if !defined(CONFIG_PREEMPT_RT) && defined(CONFIG_LOCK_STAT)
+
+extern void lock_note_contended(struct lockdep_map *lock, unsigned long ip);
+extern void lock_note_acquired(struct lockdep_map *lock);
+extern void lock_note_stolen(struct lockdep_map *lock);
+
+#define RET_IP_DECL	unsigned long _ip
+#define __RET_IP_DECL	, RET_IP_DECL
+#define __RET_IP_PARAM	, _ip
 
-extern void lock_contended(struct lockdep_map *lock, unsigned long ip);
-extern void lock_acquired(struct lockdep_map *lock);
+#define DEP_MAP_DECL	struct lockdep_map *_dep_map
+#define __DEP_MAP_DECL	, DEP_MAP_DECL
+#define DEP_MAP_PARAM	_dep_map
+#define __DEP_MAP_PARAM , DEP_MAP_PARAM
+
+#define LOCKDEP_TS_DECL
+#define __LOCKDEP_TS_DECL
+#define __LOCKDEP_TS_PARAM
+#define __LOCKDEP_TS_NULL
+
+#define LOCKDEP_PARAMS DEP_MAP_PARAM __RET_IP_PARAM
+#define __LOCKDEP_PARAMS , LOCKDEP_PARAMS
+#define __LOCKDEP_DECLS , DEP_MAP_DECL __RET_IP_DECL
+
+#define LOCKDEP_PARAMS_L0	NULL, _RET_IP_
+#define __LOCKDEP_PARAMS_L0	, LOCKDEP_PARAMS_L0
+
+#define LOCKDEP_PARAMS_SEM(lock)
+#define __LOCKDEP_PARAMS_SEM(lock)
+
+#define LOCKDEP_PARAMS_RWSEM(lock)
+#define __LOCKDEP_PARAMS_RWSEM(lock)
+
+#define LOCKDEP_PARAMS_MUTEX(lock)
+#define __LOCKDEP_PARAMS_MUTEX(lock)
 
 #define LOCK_CONTENDED(_lock, try, lock)			\
 do {								\
 	if (!try(_lock)) {					\
-		lock_contended(&(_lock)->dep_map, _RET_IP_);	\
+		lock_note_contended(&(_lock)->dep_map, _RET_IP_);	\
 		lock(_lock);					\
 	}							\
-	lock_acquired(&(_lock)->dep_map);			\
+	lock_note_acquired(&(_lock)->dep_map);			\
 } while (0)
 
-#define LOCK_CONTENDED_RT(_lock, f_try, f_lock)			\
+#define LOCK_CONTENDED_COMPAT(_lock, try, lock)			\
+do {								\
+	if (!try(_lock)) {					\
+		lock_note_contended(&(_lock)->dep_map, _RET_IP_);	\
+		lock(_lock);					\
+	}							\
+	lock_note_acquired(&(_lock)->dep_map);			\
+} while (0)
+
+#define LOCK_CONTENDED_RT(_lock, f_try, f_lock, ip)		\
 do {								\
 	if (!f_try(&(_lock)->lock)) {				\
-		lock_contended(&(_lock)->dep_map, _RET_IP_);	\
+		lock_note_contended(&(_lock)->dep_map, _RET_IP_);	\
 		f_lock(&(_lock)->lock);				\
 	}							\
-	lock_acquired(&(_lock)->dep_map);			\
+	lock_note_acquired(&(_lock)->dep_map);			\
 } while (0)
 
 
-#define LOCK_CONTENDED_RT_RET(_lock, f_try, f_lock)		\
+#define LOCK_CONTENDED_RT_RET(_lock, f_try, f_lock, ip)		\
 ({								\
  	int ret = 0;						\
 	if (!f_try(&(_lock)->lock)) {				\
-		lock_contended(&(_lock)->dep_map, _RET_IP_);	\
+		lock_note_contended(&(_lock)->dep_map, _RET_IP_);	\
 		ret = f_lock(&(_lock)->lock);			\
 	}							\
 	if (!ret)						\
-		lock_acquired(&(_lock)->dep_map);		\
+		lock_note_acquired(&(_lock)->dep_map);		\
  	ret;							\
 })
 
-#else /* CONFIG_LOCK_STAT */
+#else /* !defined(CONFIG_PREEMPT_RT) && defined(CONFIG_LOCK_STAT) */
+
+#if defined(CONFIG_PREEMPT_RT) && defined(CONFIG_LOCK_STAT)
+
+extern void lock_note_contended(struct lockdep_map *_dep_map, unsigned long _ip, struct task_struct *_owner);
+extern void lock_note_acquired(struct lockdep_map *lock);
+extern void lock_note_stolen(struct lockdep_map *lock);
+
+#define RET_IP_DECL	unsigned long _ip
+#define __RET_IP_DECL	, RET_IP_DECL
+#define __RET_IP_PARAM	, ip
+
+#define DEP_MAP_DECL	struct lockdep_map *_dep_map
+#define __DEP_MAP_DECL	, DEP_MAP_DECL
+#define DEP_MAP_PARAM	_dep_map
+#define __DEP_MAP_PARAM , DEP_MAP_PARAM
+
+#define LOCKDEP_TS_DECL		struct task_struct *_owner
+#define __LOCKDEP_TS_DECL	, LOCKDEP_TS_DECL
+#define __LOCKDEP_TS_PARAM	, _owner
+#define __LOCKDEP_TS_NULL	, NULL
+
+//#define LOCKDEP_PARAMS	 (struct task_struct *) ((unsigned long)_owner & (unsigned long) ~0x3), _dep_map, _ip
+#define LOCKDEP_PARAMS	 rt_mutex_real_owner(lock), _dep_map, _ip
+
+#define __LOCKDEP_PARAMS , LOCKDEP_PARAMS
+//#define __LOCKDEP_DECLS  , DEP_MAP_DECL, RET_IP_DECL
+#define __LOCKDEP_DECLS  , struct task_struct *_owner, DEP_MAP_DECL, RET_IP_DECL
+
+#define LOCKDEP_PARAMS_L0		current, NULL, _RET_IP_
+#define __LOCKDEP_PARAMS_L0		, LOCKDEP_PARAMS_L0
+
+#define LOCKDEP_PARAMS_SEM(lock)	LOCKDEP_PARAMS_L0
+#define __LOCKDEP_PARAMS_SEM(lock)	, LOCKDEP_PARAMS_L0
 
-#define lock_contended(lockdep_map, ip) do {} while (0)
-#define lock_acquired(lockdep_map) do {} while (0)
+#define LOCKDEP_PARAMS_RWSEM(lock)	LOCKDEP_PARAMS_L0
+#define __LOCKDEP_PARAMS_RWSEM(lock)	, LOCKDEP_PARAMS_L0
+
+#define LOCKDEP_PARAMS_MUTEX(lock)	LOCKDEP_PARAMS_L0
+#define __LOCKDEP_PARAMS_MUTEX(lock)	, LOCKDEP_PARAMS_L0
+
+#define LOCK_CONTENDED(_lock, try, lock)			\
+do {								\
+	if (!try(_lock)) {					\
+		lock_note_contended((struct task_struct *) &(_lock)->owner, \
+						&(_lock)->dep_map, \
+						_RET_IP_); \
+		lock(_lock);					\
+	}							\
+	lock_note_acquired(&(_lock)->dep_map);			\
+} while (0)
+
+#define LOCK_CONTENDED_COMPAT(_lock, try, lock)			\
+do {								\
+	if (!try(_lock)) {					\
+		lock_note_contended(NULL, &(_lock)->dep_map, _RET_IP_); \
+		lock(_lock);					\
+	}							\
+	lock_note_acquired(&(_lock)->dep_map);			\
+} while (0)
+
+#define LOCK_CONTENDED_RT(_lock, f_try, f_lock) \
+	f_lock(&(_lock)->lock, NULL, &(_lock)->dep_map, _RET_IP_)
+
+#define LOCK_CONTENDED_RT_RET(_lock, f_try, f_lock) \
+	f_lock(&(_lock)->lock, NULL, NULL, _RET_IP_)
+
+#elif /*defined(CONFIG_PREEMPT_RT) && */!defined(CONFIG_LOCK_STAT)
+/*#elif !defined(CONFIG_PREEMPT_RT) && !defined(CONFIG_LOCK_STAT) */
+
+#define lock_note_contended(lockdep_map, ip) do {} while (0)
+#define lock_note_acquired(lockdep_map) do {} while (0)
+
+#define __RET_IP_DECL
+#define __RET_IP_PARAM
+
+#define __TASK_STRUCT_LOCK_DECL
+#define __TASK_STRUCT_LOCK_PARAM
+#define __TASK_STRUCT_LOCK_PARAM2 lock,
 
 #define LOCK_CONTENDED(_lock, try, lock) \
 	lock(_lock)
 
+#define LOCK_CONTENDED_COMPAT(_lock, try, lock) \
+	lock(_lock)
+
 #define LOCK_CONTENDED_RT(_lock, f_try, f_lock) \
 	f_lock(&(_lock)->lock)
 
 #define LOCK_CONTENDED_RT_RET(_lock, f_try, f_lock) \
 	f_lock(&(_lock)->lock)
 
-#endif /* CONFIG_LOCK_STAT */
+#else
+#error
+#endif
+
+/*
+ * ac	(c1)
+ * a	(c2)
+ * ab	(c2)
+ * abc	(c2)
+ */
+
+#endif /* !defined(CONFIG_PREEMPT_RT) && defined(CONFIG_LOCK_STAT) */
 
 #if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_GENERIC_HARDIRQS)
 extern void early_init_irq_lock_class(void);

  reply	other threads:[~2008-03-14  0:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-14  0:03 [PATCH RT 0/6] " Bill Huey (hui)
2008-03-14  0:07 ` Bill Huey (hui) [this message]
2008-03-14  0:09   ` [PATCH RT 2/6] " Bill Huey (hui)
2008-03-14  0:12     ` [PATCH RT 3/6] " Bill Huey (hui)
2008-03-14  0:15       ` [PATCH RT 4/6] " Bill Huey (hui)
2008-03-14  0:18         ` [PATCH RT 5/6] " Bill Huey (hui)
2008-03-14  0:19           ` [PATCH RT 6/6] " Bill Huey (hui)
2008-03-14  0:26 ` [PATCH RT 0/6] " Bill Huey (hui)
2008-03-14  0:40   ` Bill Huey (hui)

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=9810cff90803131707v4fb3197fv396b8a5e8ae32b4d@mail.gmail.com \
    --to=bill.huey@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=ak@suse.de \
    --cc=cminyard@mvista.com \
    --cc=dsaxena@plexity.net \
    --cc=dsingleton@mvista.com \
    --cc=dwalker@mvista.com \
    --cc=ghaskins@novell.com \
    --cc=gregkh@suse.de \
    --cc=kevin@hilman.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mkohari@novell.com \
    --cc=npiggin@suse.de \
    --cc=pavel@ucw.cz \
    --cc=pmorreale@novell.com \
    --cc=rostedt@goodmis.org \
    --cc=sdietrich@novell.com \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®