From: Jesper Juhl <jesper.juhl@gmail.com>
To: Pavel Machek <pavel@suse.cz>
Cc: Arjan van de Ven <arjan@infradead.org>,
Andrew Morton <akpm@osdl.org>,
ak@suse.de, linux-kernel@vger.kernel.org, sct@redhat.com,
mingo@elte.hu
Subject: Re: 2.6.15-git7 oopses in ext3 during LTP runs
Date: Wed, 11 Jan 2006 23:47:53 +0100 [thread overview]
Message-ID: <9a8748490601111447s25ee4f68vace2077eae05b6ae@mail.gmail.com> (raw)
In-Reply-To: <20060111224013.GA8277@elf.ucw.cz>
On 1/11/06, Pavel Machek <pavel@suse.cz> wrote:
> 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 <pavel@suse.cz>
>
> 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)) {
This is confusing to read. Why not keep the parenthesis around
(unlikely(...)) ? Yes, it's an extra set of parenthesis that are not
strictly needed now that you've added them to the likely/unlikely
macros, but they don't do any harm either and make the code less
surprising to read... I know that I at least think *BUG* at once
when I read a line like
if unlikely(rq != task_rq(p)) {
and then when I find that it actually compiles fine I go dig for the
reason for that, find the macro and see that all is well, but that
just wasted a lot of time.
--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
next prev parent reply other threads:[~2006-01-11 22:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-11 20:26 2.6.15-git7 oopses in ext3 during LTP runs Andi Kleen
2006-01-11 20:46 ` Andrew Morton
2006-01-11 20:55 ` Arjan van de Ven
2006-01-11 21:07 ` Andrew Morton
2006-01-11 21:27 ` Arjan van de Ven
2006-01-11 22:19 ` Ingo Molnar
2006-01-11 22:40 ` Pavel Machek
2006-01-11 22:44 ` David S. Miller
2006-01-12 0:30 ` Ingo Molnar
2006-01-11 22:47 ` Jesper Juhl [this message]
2006-01-12 8:51 ` Pavel Machek
2006-01-12 0:55 ` 2.6.15-git7 oopses in ext3 during LTP runs II - more problems Andi Kleen
2006-01-12 1:14 ` Andrew Morton
2006-01-12 1:25 ` Andi Kleen
2006-01-11 21:25 ` 2.6.15-git7 oopses in ext3 during LTP runs Jan Engelhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9a8748490601111447s25ee4f68vace2077eae05b6ae@mail.gmail.com \
--to=jesper.juhl@gmail.com \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=arjan@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=pavel@suse.cz \
--cc=sct@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).