aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Jackson <pj@sgi.com>2005-09-12 07:30:30 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-12 12:16:27 -0400
commitb3426599af9524104be6938bcb1fcaab314781c7 (patch)
treec6d354bddb5b8cd298d139b60a9257ebd8323b90
parentf24ec7f6c6278c0ea4c00efe96d50b1e66796c44 (diff)
[PATCH] cpuset semaphore depth check optimize
Optimize the deadlock avoidance check on the global cpuset semaphore cpuset_sem. Instead of adding a depth counter to the task struct of each task, rather just two words are enough, one to store the depth and the other the current cpuset_sem holder. Thanks to Nikita Danilov for the idea. Signed-off-by: Paul Jackson <pj@sgi.com> [ We may want to change this further, but at least it's now a totally internal decision to the cpusets code ] Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--include/linux/sched.h1
-rw-r--r--kernel/cpuset.c13
2 files changed, 9 insertions, 5 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index ed3bb19d1337..38c8654aaa96 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -785,7 +785,6 @@ struct task_struct {
785 short il_next; 785 short il_next;
786#endif 786#endif
787#ifdef CONFIG_CPUSETS 787#ifdef CONFIG_CPUSETS
788 short cpuset_sem_nest_depth;
789 struct cpuset *cpuset; 788 struct cpuset *cpuset;
790 nodemask_t mems_allowed; 789 nodemask_t mems_allowed;
791 int cpuset_mems_generation; 790 int cpuset_mems_generation;
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 407b5f0a8c8e..79866bc6b3a1 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -180,6 +180,8 @@ static struct super_block *cpuset_sb = NULL;
180 */ 180 */
181 181
182static DECLARE_MUTEX(cpuset_sem); 182static DECLARE_MUTEX(cpuset_sem);
183static struct task_struct *cpuset_sem_owner;
184static int cpuset_sem_depth;
183 185
184/* 186/*
185 * The global cpuset semaphore cpuset_sem can be needed by the 187 * The global cpuset semaphore cpuset_sem can be needed by the
@@ -200,16 +202,19 @@ static DECLARE_MUTEX(cpuset_sem);
200 202
201static inline void cpuset_down(struct semaphore *psem) 203static inline void cpuset_down(struct semaphore *psem)
202{ 204{
203 if (current->cpuset_sem_nest_depth == 0) 205 if (cpuset_sem_owner != current) {
204 down(psem); 206 down(psem);
205 current->cpuset_sem_nest_depth++; 207 cpuset_sem_owner = current;
208 }
209 cpuset_sem_depth++;
206} 210}
207 211
208static inline void cpuset_up(struct semaphore *psem) 212static inline void cpuset_up(struct semaphore *psem)
209{ 213{
210 current->cpuset_sem_nest_depth--; 214 if (--cpuset_sem_depth == 0) {
211 if (current->cpuset_sem_nest_depth == 0) 215 cpuset_sem_owner = NULL;
212 up(psem); 216 up(psem);
217 }
213} 218}
214 219
215/* 220/*