Magellan Linux

Annotation of /trunk/kernel26-magellan/patches-2.6.17-r6/0008-2.6.17-track_mutexes-1.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 105 - (hide annotations) (download)
Sun Mar 11 16:17:56 2007 UTC (17 years, 2 months ago) by niro
File size: 3785 byte(s)
2.6.17-magellan-r6

1 niro 105 Keep a record of how many mutexes are held by any task. This allows cpu
2     scheduler code to use this information in decision making for tasks that
3     hold contended resources.
4    
5     Signed-off-by: Con Kolivas <kernel@kolivas.org>
6    
7     ---
8     include/linux/init_task.h | 1 +
9     include/linux/sched.h | 1 +
10     kernel/fork.c | 1 +
11     kernel/mutex.c | 25 +++++++++++++++++++++++--
12     4 files changed, 26 insertions(+), 2 deletions(-)
13    
14     Index: linux-ck-dev/include/linux/init_task.h
15     ===================================================================
16     --- linux-ck-dev.orig/include/linux/init_task.h 2006-06-18 15:20:14.000000000 +1000
17     +++ linux-ck-dev/include/linux/init_task.h 2006-06-18 15:23:44.000000000 +1000
18     @@ -120,6 +120,7 @@ extern struct group_info init_groups;
19     .blocked = {{0}}, \
20     .alloc_lock = SPIN_LOCK_UNLOCKED, \
21     .proc_lock = SPIN_LOCK_UNLOCKED, \
22     + .mutexes_held = 0, \
23     .journal_info = NULL, \
24     .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
25     .fs_excl = ATOMIC_INIT(0), \
26     Index: linux-ck-dev/include/linux/sched.h
27     ===================================================================
28     --- linux-ck-dev.orig/include/linux/sched.h 2006-06-18 15:23:38.000000000 +1000
29     +++ linux-ck-dev/include/linux/sched.h 2006-06-18 15:23:44.000000000 +1000
30     @@ -845,6 +845,7 @@ struct task_struct {
31     /* mutex deadlock detection */
32     struct mutex_waiter *blocked_on;
33     #endif
34     + unsigned long mutexes_held;
35    
36     /* journalling filesystem info */
37     void *journal_info;
38     Index: linux-ck-dev/kernel/fork.c
39     ===================================================================
40     --- linux-ck-dev.orig/kernel/fork.c 2006-06-18 15:20:14.000000000 +1000
41     +++ linux-ck-dev/kernel/fork.c 2006-06-18 15:23:44.000000000 +1000
42     @@ -1022,6 +1022,7 @@ static task_t *copy_process(unsigned lon
43     p->io_context = NULL;
44     p->io_wait = NULL;
45     p->audit_context = NULL;
46     + p->mutexes_held = 0;
47     cpuset_fork(p);
48     #ifdef CONFIG_NUMA
49     p->mempolicy = mpol_copy(p->mempolicy);
50     Index: linux-ck-dev/kernel/mutex.c
51     ===================================================================
52     --- linux-ck-dev.orig/kernel/mutex.c 2006-06-18 15:20:14.000000000 +1000
53     +++ linux-ck-dev/kernel/mutex.c 2006-06-18 15:23:44.000000000 +1000
54     @@ -58,6 +58,16 @@ EXPORT_SYMBOL(__mutex_init);
55     static void fastcall noinline __sched
56     __mutex_lock_slowpath(atomic_t *lock_count __IP_DECL__);
57    
58     +static inline void inc_mutex_count(void)
59     +{
60     + current->mutexes_held++;
61     +}
62     +
63     +static inline void dec_mutex_count(void)
64     +{
65     + current->mutexes_held--;
66     +}
67     +
68     /***
69     * mutex_lock - acquire the mutex
70     * @lock: the mutex to be acquired
71     @@ -87,6 +97,7 @@ void fastcall __sched mutex_lock(struct
72     * 'unlocked' into 'locked' state.
73     */
74     __mutex_fastpath_lock(&lock->count, __mutex_lock_slowpath);
75     + inc_mutex_count();
76     }
77    
78     EXPORT_SYMBOL(mutex_lock);
79     @@ -112,6 +123,7 @@ void fastcall __sched mutex_unlock(struc
80     * into 'unlocked' state:
81     */
82     __mutex_fastpath_unlock(&lock->count, __mutex_unlock_slowpath);
83     + dec_mutex_count();
84     }
85    
86     EXPORT_SYMBOL(mutex_unlock);
87     @@ -254,9 +266,14 @@ __mutex_lock_interruptible_slowpath(atom
88     */
89     int fastcall __sched mutex_lock_interruptible(struct mutex *lock)
90     {
91     + int ret;
92     +
93     might_sleep();
94     - return __mutex_fastpath_lock_retval
95     + ret = __mutex_fastpath_lock_retval
96     (&lock->count, __mutex_lock_interruptible_slowpath);
97     + if (likely(!ret))
98     + inc_mutex_count();
99     + return ret;
100     }
101    
102     EXPORT_SYMBOL(mutex_lock_interruptible);
103     @@ -308,8 +325,12 @@ static inline int __mutex_trylock_slowpa
104     */
105     int fastcall mutex_trylock(struct mutex *lock)
106     {
107     - return __mutex_fastpath_trylock(&lock->count,
108     + int ret = __mutex_fastpath_trylock(&lock->count,
109     __mutex_trylock_slowpath);
110     +
111     + if (likely(ret))
112     + inc_mutex_count();
113     + return ret;
114     }
115    
116     EXPORT_SYMBOL(mutex_trylock);