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

From: Con Kolivas
Date: Sun Jun 18 2006 - 04:38:02 EST


On Sunday 18 June 2006 18:26, Peter Williams wrote:
> 3. Thanks to suggestions from Con Kolivas with respect to alternative
> methods to reduce the possibility of a task being starved of CPU while
> holding an important system resource, enforcement of caps is now
> quite strict. However, there will still be occasions where caps may be
> exceeded due to this mechanism vetoing enforcement.

I hate to do this to you again but the mutexes held count advice I gave was
slightly off :|
> int fastcall __sched mutex_lock_interruptible(struct mutex *lock)
> {
> + int ret;
> +
> might_sleep();
> - return __mutex_fastpath_lock_retval
> + ret = __mutex_fastpath_lock_retval
> (&lock->count, __mutex_lock_interruptible_slowpath);
> +
> + if (!ret)
> + inc_mutex_count();
> +
> + return ret;
> }
>
> EXPORT_SYMBOL(mutex_lock_interruptible);
> @@ -357,8 +381,13 @@ static inline int __mutex_trylock_slowpa
> */
> int fastcall __sched mutex_trylock(struct mutex *lock)
> {
> - return __mutex_fastpath_trylock(&lock->count,
> + int ret = __mutex_fastpath_trylock(&lock->count,
> __mutex_trylock_slowpath);
> +
> + if (!ret)
> + inc_mutex_count();
> +
> + return ret;

See my track-mutexes-1.patch I recently posted.

int fastcall __sched mutex_lock_interruptible(struct mutex *lock)
{
+ int ret;
+
might_sleep();
- return __mutex_fastpath_lock_retval
+ ret = __mutex_fastpath_lock_retval
(&lock->count, __mutex_lock_interruptible_slowpath);
+ if (likely(!ret))
+ inc_mutex_count();
+ return ret;
}

EXPORT_SYMBOL(mutex_lock_interruptible);
@@ -308,8 +325,12 @@ static inline int __mutex_trylock_slowpa
*/
int fastcall mutex_trylock(struct mutex *lock)
{
- return __mutex_fastpath_trylock(&lock->count,
+ int ret = __mutex_fastpath_trylock(&lock->count,
__mutex_trylock_slowpath);
+
+ if (likely(ret))
+ inc_mutex_count();
+ return ret;
}

Note the if !ret in mutex_lock_interruptible vs the if ret in mutex_trylock(

I really should have given you the original debugging code that went with it,
sorry.

--
-ck
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/