From: "H. Peter Anvin" <hpa@zytor.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jan Beulich <JBeulich@novell.com>,
a.p.zijlstra@chello.nl, mingo@elte.hu, tglx@linutronix.de,
mingo@redhat.com, npiggin@suse.de, linux-kernel@vger.kernel.org
Subject: Re: [tip:core/locking] locking, x86: Slightly shorten __ticket_spin_trylock()
Date: Wed, 02 Dec 2009 09:58:41 -0800 [thread overview]
Message-ID: <4B16AAD1.7090900@zytor.com> (raw)
In-Reply-To: <alpine.LFD.2.00.0912020938330.2872@localhost.localdomain>
On 12/02/2009 09:48 AM, Linus Torvalds wrote:
>
> Hmm. Odd. I just checked:
>
> _Bool myfunction(char val)
> {
> return val;
> }
>
> and compiling it with
>
> gcc -O2 -S -m32 -mregparm=3 -fomit-frame-pointer t.c
>
> I get
>
> myfunction:
> testb %al, %al
> setne %al
> ret
>
> which only sets the low 8 bits. So my gcc actually seems to think that
> _Bool is just 8 bits, at least for return values, and then upper 24 bits
> are undefined. It also generates 'testb' for a test of a return value.
>
Damn. I stand corrected :-/ I just tested it on x86-64, and gcc 4.4.1
actually *violates the documented ABI* for x86-64.
> So it so happens that I think Jan's patch would have worked - except for
> the PV_OPS mess. _Bool does act like a 'char' on x86 at least with gcc. I
> still think that it's fundamentally wrong to use 'bool' because of how
> subtly it can act.
I personally think using "bool" for C values is a good thing -- people
have a very nasty tendency to come up with the clever idea of "oh, there
is this flag which is 'int'... well, in this special case let's set it
to -1 or 2", and of course there is absolutely no way to know, globally,
that this value once in a blue moon gets set to a bizarre value. I have
seen this a number of times in the kernel. It doesn't mean one should
pass it to assembly code.
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
prev parent reply other threads:[~2009-12-02 17:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-27 15:09 [PATCH] x86: slightly shorten __ticket_spin_trylock() Jan Beulich
2009-12-02 10:45 ` [tip:core/locking] locking, x86: Slightly " tip-bot for Jan Beulich
2009-12-02 13:29 ` Ingo Molnar
2009-12-02 14:06 ` Jan Beulich
2009-12-02 14:12 ` Avi Kivity
2009-12-02 14:25 ` Jan Beulich
2009-12-02 14:36 ` Avi Kivity
2009-12-02 14:59 ` Jan Beulich
2009-12-02 14:21 ` Ingo Molnar
2009-12-02 14:57 ` Jan Beulich
2009-12-02 15:33 ` Linus Torvalds
2009-12-02 15:26 ` Linus Torvalds
2009-12-02 16:24 ` Jan Beulich
2009-12-02 16:56 ` Linus Torvalds
2009-12-02 17:05 ` Linus Torvalds
2009-12-02 17:23 ` H. Peter Anvin
2009-12-02 17:48 ` Linus Torvalds
2009-12-02 17:58 ` H. Peter Anvin [this message]
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=4B16AAD1.7090900@zytor.com \
--to=hpa@zytor.com \
--cc=JBeulich@novell.com \
--cc=a.p.zijlstra@chello.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=npiggin@suse.de \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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