From: "Jan Beulich" <jbeulich@novell.com>
To: "Jeremy Fitzhardinge" <jeremy@goop.org>
Cc: "Ingo Molnar" <mingo@elte.hu>, <tglx@linutronix.de>,
<linux-kernel@vger.kernel.org>, <hpa@zytor.com>
Subject: Re: [RFC] x86: bitops asm constraint fixes
Date: Tue, 15 Apr 2008 08:03:11 +0100 [thread overview]
Message-ID: <48046F4F.76E4.0078.0@novell.com> (raw)
In-Reply-To: <48038482.90500@goop.org>
>>> Jeremy Fitzhardinge <jeremy@goop.org> 14.04.08 18:21 >>>
>Jan Beulich wrote:
>>
>> +struct __bits { int _[1UL << (32 - 3 - sizeof(int))]; };
>>
>
>I don't understand what you're doing here. The array can be 1<<(32 - 1)
>bytes (assuming we never allow a 64-bit bit offset). The int array
>makes that 1<<(32 - 1 - log2(sizeof(int))) ints. But I don't see what
>the sizeof(int) is doing in there.
The array really can be only 1<<(32-1) bits (the bit offset is signed,
but I intentionally neglect this here for not further complicating things,
since its meaningless in this context), hence 1<<(32-4) bytes and
1<<(32-6) ints. So the -3 in there represents the bits-to-bytes
conversion, and the sizeof(int) is for the bytes-to-ints one.
>> +
>> #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)
>> /* Technically wrong, but this avoids compilation errors on some gcc
>> versions. */
>> -#define ADDR "=m" (*(volatile long *)addr)
>> -#define BIT_ADDR "=m" (((volatile int *)addr)[nr >> 5])
>> +#define ADDR "=m" (*(volatile long *) addr)
>> +#define BIT_ADDR "=m" (((volatile int *) addr)[nr >> 5])
>> +#define FULL_ADDR "=m" (*(volatile struct __bits *) addr)
>> #else
>> #define ADDR "+m" (*(volatile long *) addr)
>> -#define BIT_ADDR "+m" (((volatile int *)addr)[nr >> 5])
>> +#define BIT_ADDR "+m" (((volatile int *) addr)[nr >> 5])
>> +#define FULL_ADDR "+m" (*(volatile struct __bits *) addr)
>> #endif
>> -#define BASE_ADDR "m" (*(volatile int *)addr)
>> +#define BASE_ADDR "m" (*(volatile int *) addr)
>>
>
>Shouldn't BASE_ADDR also use __bits? Otherwise it won't get write-read
>dependencies right (a read could move before a write).
No, BASE_ADDR is used for the address calculation that the raw bt?
instructions are to use, BIT_ADDR specifies the actual field that
changes. They are always used together (and it's BIT_ADDR that's
responsible for representing the dependency), and always under
__builtin_constant_p(nr) (so we know the compiler doesn't need to
generate extra code for computing the [not needed in the instruction]
second address).
Jan
next prev parent reply other threads:[~2008-04-15 7:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-14 13:31 [RFC] x86: bitops asm constraint fixes Jan Beulich
2008-04-14 16:21 ` Jeremy Fitzhardinge
2008-04-15 7:03 ` Jan Beulich [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-03-28 19:55 Jan Beulich
2008-03-27 8:12 Jan Beulich
2008-03-27 8:41 ` Ingo Molnar
2008-04-14 12:53 ` Jan Beulich
2008-03-13 9:08 Jan Beulich
2008-03-14 7:51 ` H. Peter Anvin
2008-03-14 8:09 ` Jan Beulich
2008-03-14 18:56 ` Jeremy Fitzhardinge
2008-03-17 9:08 ` Jan Beulich
2008-03-14 21:07 ` Chuck Ebbert
2008-03-17 9:16 ` Jan Beulich
2008-03-19 13:19 ` H. Peter Anvin
2008-03-21 13:54 ` Ingo Molnar
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=48046F4F.76E4.0078.0@novell.com \
--to=jbeulich@novell.com \
--cc=hpa@zytor.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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