Re: [PATCH 1/4] sched: Add CPU rate soft caps

From: Peter Williams
Date: Sun Jun 18 2006 - 21:20:41 EST


As pointed out by Con Kolivas there is an error in the mutex count part of this code and an opportunity to increase efficiency with use of the likely() macro. The attached patch addresses these issues.

Signed-off-by: Peter Williams <pwil3058@xxxxxxxxxxxxxx>

--
Peter Williams pwil3058@xxxxxxxxxxxxxx

"Learning, n. The kind of ignorance distinguishing the studious."
-- Ambrose Bierce
---
kernel/mutex.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Index: MM-2.6.17-rc6-mm2/kernel/mutex.c
===================================================================
--- MM-2.6.17-rc6-mm2.orig/kernel/mutex.c 2006-06-19 09:57:03.000000000 +1000
+++ MM-2.6.17-rc6-mm2/kernel/mutex.c 2006-06-19 09:57:55.000000000 +1000
@@ -319,7 +319,7 @@ int fastcall __sched mutex_lock_interrup
ret = __mutex_fastpath_lock_retval
(&lock->count, __mutex_lock_interruptible_slowpath);

- if (!ret)
+ if (likely(!ret))
inc_mutex_count();

return ret;
@@ -380,7 +380,7 @@ int fastcall __sched mutex_trylock(struc
int ret = __mutex_fastpath_trylock(&lock->count,
__mutex_trylock_slowpath);

- if (!ret)
+ if (likely(ret))
inc_mutex_count();

return ret;