Annotation of /trunk/kernel26-tinyalx/patches-2.6.21-r14/0005-2.6.21-track_mutexes-1.patch
Parent Directory | Revision Log
Revision 453 -
(hide annotations)
(download)
Fri Jan 25 23:34:48 2008 UTC (16 years, 8 months ago) by niro
File size: 3847 byte(s)
Fri Jan 25 23:34:48 2008 UTC (16 years, 8 months ago) by niro
File size: 3847 byte(s)
-tiny-alx 2.6.21-tinyalx-r14
1 | niro | 453 | 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-2.6.21-ck2/include/linux/init_task.h | ||
15 | =================================================================== | ||
16 | --- linux-2.6.21-ck2.orig/include/linux/init_task.h 2007-05-14 19:30:30.000000000 +1000 | ||
17 | +++ linux-2.6.21-ck2/include/linux/init_task.h 2007-05-14 19:30:31.000000000 +1000 | ||
18 | @@ -137,6 +137,7 @@ extern struct group_info init_groups; | ||
19 | .signal = {{0}}}, \ | ||
20 | .blocked = {{0}}, \ | ||
21 | .alloc_lock = __SPIN_LOCK_UNLOCKED(tsk.alloc_lock), \ | ||
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-2.6.21-ck2/include/linux/sched.h | ||
27 | =================================================================== | ||
28 | --- linux-2.6.21-ck2.orig/include/linux/sched.h 2007-05-14 19:30:31.000000000 +1000 | ||
29 | +++ linux-2.6.21-ck2/include/linux/sched.h 2007-05-14 19:30:31.000000000 +1000 | ||
30 | @@ -1005,6 +1005,7 @@ struct task_struct { | ||
31 | struct held_lock held_locks[MAX_LOCK_DEPTH]; | ||
32 | unsigned int lockdep_recursion; | ||
33 | #endif | ||
34 | + unsigned long mutexes_held; | ||
35 | |||
36 | /* journalling filesystem info */ | ||
37 | void *journal_info; | ||
38 | Index: linux-2.6.21-ck2/kernel/fork.c | ||
39 | =================================================================== | ||
40 | --- linux-2.6.21-ck2.orig/kernel/fork.c 2007-05-03 22:20:57.000000000 +1000 | ||
41 | +++ linux-2.6.21-ck2/kernel/fork.c 2007-05-14 19:30:31.000000000 +1000 | ||
42 | @@ -1060,6 +1060,7 @@ static struct task_struct *copy_process( | ||
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-2.6.21-ck2/kernel/mutex.c | ||
51 | =================================================================== | ||
52 | --- linux-2.6.21-ck2.orig/kernel/mutex.c 2007-02-05 22:52:04.000000000 +1100 | ||
53 | +++ linux-2.6.21-ck2/kernel/mutex.c 2007-05-14 19:30:31.000000000 +1000 | ||
54 | @@ -60,6 +60,16 @@ EXPORT_SYMBOL(__mutex_init); | ||
55 | static void fastcall noinline __sched | ||
56 | __mutex_lock_slowpath(atomic_t *lock_count); | ||
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 | @@ -89,6 +99,7 @@ void inline fastcall __sched mutex_lock( | ||
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 | @@ -114,6 +125,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 | @@ -283,9 +295,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 | @@ -340,8 +357,12 @@ static inline int __mutex_trylock_slowpa | ||
104 | */ | ||
105 | int fastcall __sched 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); |