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

Re: gcc 4.5 and TLS



On Sun, Jun 6, 2010 at 20:37, Brad Boyer <flar@allandria.com> wrote:
> On Sun, Jun 06, 2010 at 10:42:40AM +0200, Andreas Schwab wrote:
>> Brad Boyer <flar@allandria.com> writes:
>>
>> > I may be missing something obvious, but why don't we just change the
>> > kernel to allow 2-byte alignment for m68k? The comment in futex.c
>> > just says "natural" alignment but is then hard-coded for sizeof(u32).
>>
>> Natural alignment *is* sizeof.
>
> OK, then I guess my real question is "why does it need alignment"? I
> obviously don't have a good understanding of the futex code, but this
> seems like something that could have pretty significant effects. It
> looks like the need for natural alignment is to avoid alignment
> exceptions in the kernel or something like that, but m68k doesn't
> have such a thing since the hardware always does it. Please let
> me know what I missing here. I even looked at the 68040 UM to see
> if the CAS instruction does anything odd, since I know some other
> chips have some weird limits on atomic instructions.

As Andreas already pointed out:

kernel/futex.c:

| static void get_futex_key_refs(union futex_key *key)
| {
|         if (!key->both.ptr)
|                 return;
|
|         switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) {
|         case FUT_OFF_INODE:
|                 atomic_inc(&key->shared.inode->i_count);
|                break;
|         case FUT_OFF_MMSHARED:
|                 atomic_inc(&key->private.mm->mm_count);
|                 break;
|         }
| }

and include/linux/futex.h:

| /*
|  * Futexes are matched on equal values of this key.
|  * The key type depends on whether it's a shared or private mapping.
|  * Don't rearrange members without looking at hash_futex().
|  *
|  * offset is aligned to a multiple of sizeof(u32) (== 4) by definition.
|  * We use the two low order bits of offset to tell what is the kind of key :
|  *  00 : Private process futex (PTHREAD_PROCESS_PRIVATE)
|  *       (no reference on an inode or mm)
|  *  01 : Shared futex (PTHREAD_PROCESS_SHARED)
|  *      mapped on a file (reference on the underlying inode)
|  *  10 : Shared futex (PTHREAD_PROCESS_SHARED)
|  *       (but private mapping on an mm, and reference taken on it)
| */
|
| #define FUT_OFF_INODE    1 /* We set bit 0 if key has a reference on inode */
| #define FUT_OFF_MMSHARED 2 /* We set bit 1 if key has a reference on mm */

I.e. the futex code uses the two low order bits for its private
purposes (nihil novi sub sole).
Not much we can do about that...

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds


Reply to: