lock stat for 2.6.19-rt1
PATCH 1/4 lock stat for 2.6.19-rt1
This hooks into the preexisting lock definitions in the -rt kernel and hijacks parts of lockdep for the object hash key.
bill
============================================================
linux/mutex.h +8 -2
@@ -15,6 +15,7 @@#include <linux/rt_lock.h> #include <linux/linkage.h> #include <linux/lockdep.h> +#include <linux/lock_stat.h> #include <asm/atomic.h>
@@ -35,7 +36,8 @@ extern void }extern void -_mutex_init (struct mutex *lock,char *name,struct lock_class_key *key); +_mutex_init(struct mutex *lock, char *name, struct lock_class_key *key + __COMMA_LOCK_STAT_NOTE_PARAM_DECL); extern void __lockfunc _mutex_lock(struct mutex *lock); extern int __lockfunc _mutex_lock_interruptible(struct mutex *lock);
@@ -56,11 +58,15 @@ extern void __lockfunc _mutex_unlock(str# define mutex_lock_nested (l, s) _mutex_lock(l)#endif +#define __mutex_init (l,n) __rt_mutex_init(&(l)->mutex, \ + n \ + __COMMA_LOCK_STAT_NOTE) +# define mutex_init (mutex) \ do { \ static struct lock_class_key __key; \ \ - _mutex_init((mutex), #mutex, &__key); \ + _mutex_init((mutex), #mutex, &__key __COMMA_LOCK_STAT_NOTE); \ } while (0)#else
============================================================
linux/rt_lock.h +13 -9
@@ -13,6 +13,7 @@#include <linux/rtmutex.h> #include <asm/atomic.h> #include <linux/spinlock_types.h> +#include <linux/lock_stat.h> #ifdef CONFIG_PREEMPT_RT /*
@@ -28,8 +29,8 @@ typedef struct {#ifdef CONFIG_DEBUG_RT_MUTEXES # define __SPIN_LOCK_UNLOCKED (name) \ - (spinlock_t) { { .wait_lock = _RAW_SPIN_LOCK_UNLOCKED(name) \ - , .save_state = 1, .file = __FILE__, .line = __LINE__ } } + (spinlock_t) { .lock = { .wait_lock = _RAW_SPIN_LOCK_UNLOCKED(name) \ + , .save_state = 1, .file = __FILE__, .line = __LINE__ __COMMA_LOCK_STAT_INITIALIZER} }#else # define __SPIN_LOCK_UNLOCKED (name) \ (spinlock_t) { { .wait_lock = _RAW_SPIN_LOCK_UNLOCKED(name) } }
@@ -92,7 +93,7 @@ typedef struct {# ifdef CONFIG_DEBUG_RT_MUTEXES # define __RW_LOCK_UNLOCKED (name) (rwlock_t) \ { .lock = { .wait_lock = _RAW_SPIN_LOCK_UNLOCKED(name), \ - .save_state = 1, .file = __FILE__, .line = __LINE__ } } + .save_state = 1, .file = __FILE__, .line = __LINE__ __COMMA_LOCK_STAT_INITIALIZER } }# else # define __RW_LOCK_UNLOCKED (name) (rwlock_t) \ { .lock = { .wait_lock = _RAW_SPIN_LOCK_UNLOCKED(name) } }
@@ -139,14 +140,16 @@ struct semaphore name = \*/ #define DECLARE_MUTEX_LOCKED COMPAT_DECLARE_MUTEX_LOCKED -extern void fastcall __sema_init(struct semaphore *sem, int val, char *name, char *file, int line); +extern void fastcall __sema_init(struct semaphore *sem, int val, char *name + __COMMA_LOCK_STAT_FN_DECL,char *_file,int _line);#define rt_sema_init (sem, val) \ - __sema_init(sem, val, #sem, __FILE__, __LINE__) + __sema_init(sem, val, #sem __COMMA_LOCK_STAT_NOTE_FN, __FILE__, __LINE__) -extern void fastcall __init_MUTEX(struct semaphore *sem, char *name, char *file, int line); +extern void fastcall __init_MUTEX(struct semaphore *sem, char *name + __COMMA_LOCK_STAT_FN_DECL,char *_file,int _line);#define rt_init_MUTEX (sem) \ - __init_MUTEX(sem, #sem, __FILE__, __LINE__) + __init_MUTEX(sem, #sem __COMMA_LOCK_STAT_NOTE_FN, __FILE__, __LINE__)extern void there_is_no_init_MUTEX_LOCKED_for_RT_semaphores (void );
@@ -247,13 +250,14 @@ extern void fastcall __rt_rwsem_init(str struct rw_semaphore lockname = __RWSEM_INITIALIZER(lockname) extern void fastcall __rt_rwsem_init(struct rw_semaphore *rwsem, char *name, -struct lock_class_key *key); + struct lock_class_key *key + __COMMA_LOCK_STAT_NOTE_PARAM_DECL);# define rt_init_rwsem (sem) \ do { \ static struct lock_class_key __key; \ \ - __rt_rwsem_init((sem), #sem, &__key); \ + __rt_rwsem_init((sem), #sem, &__key __COMMA_LOCK_STAT_NOTE); \ } while (0) extern void fastcall rt_down_write(struct rw_semaphore *rwsem);
============================================================
linux/rtmutex.h +33 -3
@@ -15,6 +15,7 @@#include <linux/linkage.h> #include <linux/plist.h> #include <linux/spinlock_types.h> +#include <linux/lock_stat.h> /* * The rt_mutex structure
@@ -33,6 +34,9 @@ struct rt_mutex {int line;void *magic;#endif +#ifdef CONFIG_LOCK_STAT +struct lock_stat *lock_stat; +#endif };struct rt_mutex_waiter ;
@@ -54,11 +58,13 @@ struct hrtimer_sleeper;#ifdef CONFIG_DEBUG_RT_MUTEXES # define __DEBUG_RT_MUTEX_INITIALIZER (mutexname) \ , .name = #mutexname, .file = __FILE__, .line = __LINE__ -# define rt_mutex_init (mutex) __rt_mutex_init(mutex, __FUNCTION__) +# define rt_mutex_init (mutex) __rt_mutex_init(mutex, __FUNCTION__ \ + __COMMA_LOCK_STAT_NOTE_DECL_FLLN)extern void rt_mutex_debug_task_free (struct task_struct *tsk);#else # define __DEBUG_RT_MUTEX_INITIALIZER (mutexname) -# define rt_mutex_init (mutex) __rt_mutex_init(mutex, NULL) +# define rt_mutex_init (mutex) __rt_mutex_init(mutex, NULL \ + __COMMA_LOCK_STAT_NOTE_DECL_FLLN)# define rt_mutex_debug_task_free (t) do { } while (0)#endif
@@ -66,6 +72,7 @@ struct hrtimer_sleeper; { .wait_lock = RAW_SPIN_LOCK_UNLOCKED(mutexname) \ , .wait_list = PLIST_HEAD_INIT(mutexname.wait_list, mutexname.wait_lock) \ , .owner = NULL \ + __COMMA_LOCK_STAT_INITIALIZER \ __DEBUG_RT_MUTEX_INITIALIZER(mutexname)}#define DEFINE_RT_MUTEX (mutexname) \
@@ -82,10 +89,19 @@ static inline int rt_mutex_is_locked(strreturn lock->owner !=NULL ; } -extern void __rt_mutex_init (struct rt_mutex *lock,const char *name); +extern void __rt_mutex_init (struct rt_mutex *lock, + const char *name + __COMMA_LOCK_STAT_NOTE_PARAM_DECL); +#ifdef CONFIG_LOCK_STAT +extern void __rt_mutex_init_annotated (struct rt_mutex *lock,const char *name, +LOCK_STAT_NOTE_PARAM_DECL , +struct lock_stat *lsobject); +#endif +extern void rt_mutex_destroy (struct rt_mutex *lock);extern void rt_mutex_lock (struct rt_mutex *lock); +extern int rt_mutex_lock_interruptible (struct rt_mutex *lock,int detect_deadlock); extern int rt_mutex_timed_lock(struct rt_mutex *lock,
@@ -96,6 +112,20 @@ extern void rt_mutex_unlock(struct rt_muextern void rt_mutex_unlock (struct rt_mutex *lock); +#ifdef CONFIG_LOCK_STAT +extern void rt_mutex_lock_with_ip (struct rt_mutex *lock, +unsigned long ip); +extern int rt_mutex_lock_interruptible_with_ip (struct rt_mutex *lock, +int detect_deadlock, +unsigned long ip); +extern int rt_mutex_timed_lock_with_ip (struct rt_mutex *lock, +struct hrtimer_sleeper *timeout, +int detect_deadlock, +unsigned long ip); +extern int rt_mutex_trylock_with_ip (struct rt_mutex *lock, +unsigned long ip); +#endif +#ifdef CONFIG_RT_MUTEXES # define INIT_RT_MUTEXES (tsk) \ .pi_waiters = PLIST_HEAD_INIT(tsk.pi_waiters, tsk.pi_lock), \
============================================================
linux/spinlock.h +56 -4
106 lines not on this page · raw message
============================================================
linux/wait.h +1 -1
@@ -81,7 +81,7 @@ extern void init_waitqueue_head(wait_queextern void init_waitqueue_head (wait_queue_head_t *q); -#ifdef CONFIG_LOCKDEP +#if defined(CONFIG_LOCKDEP ) || defined(CONFIG_LOCK_STAT )# define __WAIT_QUEUE_HEAD_INIT_ONSTACK (name) \ ({ init_waitqueue_head(&name); name; })# define DECLARE_WAIT_QUEUE_HEAD_ONSTACK (name) \
============================================================
main.c +1 -0
@@ -608,6 +608,7 @@ asmlinkage void __init start_kernel(void#ifdef CONFIG_PROC_FS proc_root_init ();#endif +lock_stat_sys_init ();//--billh cpuset_init ();taskstats_init_early ();delayacct_init ();
PATCH 2/4 lock stat (rt/rtmutex.c mods) for 2.6.19-rt1
Mods to rt.c and rtmutex.c
bill
============================================================
main.c +1 -0
@@ -608,6 +608,7 @@ asmlinkage void __init start_kernel(void#ifdef CONFIG_PROC_FS proc_root_init ();#endif +lock_stat_sys_init ();//--billh cpuset_init ();taskstats_init_early ();delayacct_init ();
============================================================
rt.c +133 -30
346 lines not on this page · raw message
============================================================
rtmutex.c +211 -27
449 lines not on this page · raw message
PATCH 3/4 lock stat (rt/rtmutex.c mods) for 2.6.19-rt1
Rudimentary annotations to the lock initializers to avoid the binary tree search before attachment. For things like inodes that are created and destroyed constantly this might be useful to get around some overhead.
Sorry, about the patch numbering order. I think I screwed up on it.
bill
============================================================
xtensa/platform-iss/network.c +2 -0
@@ -648,6 +648,8 @@ static int iss_net_configure(int index, .have_mac = 0, }); +spin_lock_init (&lp->lock); +/* * Try all transport protocols. * Note: more protocols can be added by adding '&& !X_init(lp, eth)'.
============================================================
dcache.c +1 -1
@@ -884,7 +884,7 @@ struct dentry *d_alloc(struct dentry * patomic_set (&dentry->d_count,1 ); dentry->d_flags =DCACHE_UNHASHED ; -spin_lock_init (&dentry->d_lock); +spin_lock_init_annotated (&dentry->d_lock, &_lock_stat_d_alloc_entry); dentry->d_inode =NULL ; dentry->d_parent =NULL ; dentry->d_sb =NULL ;
============================================================
xfs/support/ktrace.c +1 -0
@@ -162,6 +162,7 @@ ktrace_enter(ASSERT (ktp !=NULL ); +spin_lock_init (&wrap_lock);//--billh /* * Grab an entry by pushing the index up to the next one. */
============================================================
linux/eventpoll.h +2 -1
@@ -15,6 +15,7 @@#define _LINUX_EVENTPOLL_H#include <linux/types.h> +#include <linux/lock_stat.h> /* Valid opcodes to issue to sys_epoll_ctl() */
@@ -55,7 +56,7 @@ static inline void eventpoll_init_file(sstatic inline void eventpoll_init_file (struct file *file) {INIT_LIST_HEAD (&file->f_ep_links); -spin_lock_init (&file->f_ep_lock); +spin_lock_init_annotated (&file->f_ep_lock, &_lock_stat_eventpoll_init_file_entry); }
============================================================
tipc/node.c +1 -1
@@ -77,7 +77,7 @@ struct node *tipc_node_create(u32 addr)memset (n_ptr,0 ,sizeof (*n_ptr)); n_ptr->addr = addr; -spin_lock_init (&n_ptr->lock); +spin_lock_init (&n_ptr->lock);INIT_LIST_HEAD (&n_ptr->nsub); n_ptr->owner = c_ptr;tipc_cltr_attach_node (c_ptr, n_ptr);
Re: [PATCH 3/4] lock stat (rt/rtmutex.c mods) for 2.6.19-rt1
Quoted 6 lines · Bill Huey
Rudimentary annotations to the lock initializers to avoid the binary tree search before attachment. For things like inodes that are created and destroyed constantly this might be useful to get around some overhead.
Sorry, about the patch numbering order. I think I screwed up on it.
I also screwed up on the title for the email contents. Sorry about that.
bill