Re: 2.6.15-git7 oopses in ext3 during LTP runs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On St 11-01-06 22:27:55, Arjan van de Ven wrote:
> > We expect the lock to be held on entry.  Hence we expect mutex_trylock()
> > to return zero.
> 
> you are correct, and the x86-64 mutex.h is buggy
> 
> --- linux-2.6.15/include/asm-x86_64/mutex.h.org	2006-01-11 22:25:37.000000000 +0100
> +++ linux-2.6.15/include/asm-x86_64/mutex.h	2006-01-11 22:25:43.000000000 +0100
> @@ -104,7 +104,7 @@
>  static inline int
>  __mutex_fastpath_trylock(atomic_t *count, int (*fail_fn)(atomic_t *))
>  {
> -	if (likely(atomic_cmpxchg(count, 1, 0)) == 1)
> +	if (likely(atomic_cmpxchg(count, 1, 0) == 1))
>  		return 1;
>  	else
>  		return 0;
> 
> changes the asm to be the correct one for me.
> This is odd/evil though..

likely is the evil part here. What about this? Should make this bug
impossible to do....

Signed-off-by: Pavel Machek <[email protected]>

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -59,8 +59,8 @@ extern void __chk_io_ptr(void __iomem *)
  * specific implementations come from the above header files
  */
 
-#define likely(x)	__builtin_expect(!!(x), 1)
-#define unlikely(x)	__builtin_expect(!!(x), 0)
+#define likely(x)	(__builtin_expect(!!(x), 1))
+#define unlikely(x)	(__builtin_expect(!!(x), 0))
 
 /* Optimization barrier */
 #ifndef barrier
diff --git a/kernel/sched.c b/kernel/sched.c
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -367,7 +367,7 @@ repeat_lock_task:
 	local_irq_save(*flags);
 	rq = task_rq(p);
 	spin_lock(&rq->lock);
-	if (unlikely(rq != task_rq(p))) {
+	if unlikely(rq != task_rq(p)) {
 		spin_unlock_irqrestore(&rq->lock, *flags);
 		goto repeat_lock_task;
 	}
@@ -751,7 +751,7 @@ static int recalc_task_prio(task_t *p, u
 	else
 		sleep_time = (unsigned long)__sleep_time;
 
-	if (likely(sleep_time > 0)) {
+	if likely(sleep_time > 0) {
 		/*
 		 * User tasks that sleep a long time are categorised as
 		 * idle and will get just interactive status to stay active &
@@ -876,7 +876,7 @@ static void resched_task(task_t *p)
 
 	assert_spin_locked(&task_rq(p)->lock);
 
-	if (unlikely(test_tsk_thread_flag(p, TIF_NEED_RESCHED)))
+	if unlikely(test_tsk_thread_flag(p, TIF_NEED_RESCHED))
 		return;
 
 	set_tsk_thread_flag(p, TIF_NEED_RESCHED);


-- 
Thanks, Sharp!
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux