* reorganized struct inode results in unaligned accesses
@ 2011-06-19 16:33 ` Meelis Roos
0 siblings, 0 replies; 10+ messages in thread
From: Meelis Roos @ 2011-06-19 16:33 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Linux Kernel list, sparclinux
A week ago I noticed that in 3.0.0-rc3, sparc64 machines log a lot of
unaligned accesses in different vfs functions in dmesg. I reported but
obviously not well enough. Today I had a look at it and found the
reason.
Commit 13e12d14e2dccc7995b8f15a5678a338ab4e6a8c (vfs: reorganize 'struct
inode' layout a bit) changes i_state to be unsigned int instead of
unsigned long. This is the cause of unaligned accesses on sparc64 and
maybe others. Changing it back to unsigned long fixes the warnings but I
did not look at the layout of the resulting struct - might leave a hole
there.
--
Meelis Roos (mroos@linux.ee)
^ permalink raw reply [flat|nested] 10+ messages in thread
* reorganized struct inode results in unaligned accesses
@ 2011-06-19 16:33 ` Meelis Roos
0 siblings, 0 replies; 10+ messages in thread
From: Meelis Roos @ 2011-06-19 16:33 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Linux Kernel list, sparclinux
A week ago I noticed that in 3.0.0-rc3, sparc64 machines log a lot of
unaligned accesses in different vfs functions in dmesg. I reported but
obviously not well enough. Today I had a look at it and found the
reason.
Commit 13e12d14e2dccc7995b8f15a5678a338ab4e6a8c (vfs: reorganize 'struct
inode' layout a bit) changes i_state to be unsigned int instead of
unsigned long. This is the cause of unaligned accesses on sparc64 and
maybe others. Changing it back to unsigned long fixes the warnings but I
did not look at the layout of the resulting struct - might leave a hole
there.
--
Meelis Roos (mroos@linux.ee)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: reorganized struct inode results in unaligned accesses
2011-06-19 16:33 ` Meelis Roos
@ 2011-06-19 16:51 ` Linus Torvalds
-1 siblings, 0 replies; 10+ messages in thread
From: Linus Torvalds @ 2011-06-19 16:51 UTC (permalink / raw)
To: Meelis Roos; +Cc: Linux Kernel list, sparclinux
On Sun, Jun 19, 2011 at 9:33 AM, Meelis Roos <mroos@linux.ee> wrote:
>
> Commit 13e12d14e2dccc7995b8f15a5678a338ab4e6a8c (vfs: reorganize 'struct
> inode' layout a bit) changes i_state to be unsigned int instead of
> unsigned long. This is the cause of unaligned accesses on sparc64 and
> maybe others. Changing it back to unsigned long fixes the warnings but I
> did not look at the layout of the resulting struct - might leave a hole
> there.
Argh. Gaah, we acces that thing with the bit-ops when we do the
bit_waitqueue() and wait_on_bit() thing.
My bad, and apparently our type checking for the wait-on-bit stuff
isn't as tight as it should be.
Dang. I guess it needs to be made "unsigned long" again. Which is a
shame, because we only use a couple of bits from there, and "struct
inode" really is much too big already.
I do wonder why "wait_on_bit()" takes a "void *", when apparently it
can only handle "unsigned long *" entities. Maybe we could fix the
implementation to really take anything.
Linus
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: reorganized struct inode results in unaligned accesses
@ 2011-06-19 16:51 ` Linus Torvalds
0 siblings, 0 replies; 10+ messages in thread
From: Linus Torvalds @ 2011-06-19 16:51 UTC (permalink / raw)
To: Meelis Roos; +Cc: Linux Kernel list, sparclinux
On Sun, Jun 19, 2011 at 9:33 AM, Meelis Roos <mroos@linux.ee> wrote:
>
> Commit 13e12d14e2dccc7995b8f15a5678a338ab4e6a8c (vfs: reorganize 'struct
> inode' layout a bit) changes i_state to be unsigned int instead of
> unsigned long. This is the cause of unaligned accesses on sparc64 and
> maybe others. Changing it back to unsigned long fixes the warnings but I
> did not look at the layout of the resulting struct - might leave a hole
> there.
Argh. Gaah, we acces that thing with the bit-ops when we do the
bit_waitqueue() and wait_on_bit() thing.
My bad, and apparently our type checking for the wait-on-bit stuff
isn't as tight as it should be.
Dang. I guess it needs to be made "unsigned long" again. Which is a
shame, because we only use a couple of bits from there, and "struct
inode" really is much too big already.
I do wonder why "wait_on_bit()" takes a "void *", when apparently it
can only handle "unsigned long *" entities. Maybe we could fix the
implementation to really take anything.
Linus
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: reorganized struct inode results in unaligned accesses
2011-06-19 16:51 ` Linus Torvalds
@ 2011-06-19 22:35 ` Andi Kleen
-1 siblings, 0 replies; 10+ messages in thread
From: Andi Kleen @ 2011-06-19 22:35 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Meelis Roos, Linux Kernel list, sparclinux
Linus Torvalds <torvalds@linux-foundation.org> writes:
>
> Dang. I guess it needs to be made "unsigned long" again. Which is a
> shame, because we only use a couple of bits from there, and "struct
> inode" really is much too big already.
In the past it was usually enough to just align it to alignof(unsigned
long), not actually make it long. struct page went through this
a long time ago.
This could cause r-m-w races with the next field in theory, but assuming
it's reasonably read-only (ie only set up at inode creation time)
that should be fine.
-Andi
--
ak@linux.intel.com -- Speaking for myself only
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: reorganized struct inode results in unaligned accesses
@ 2011-06-19 22:35 ` Andi Kleen
0 siblings, 0 replies; 10+ messages in thread
From: Andi Kleen @ 2011-06-19 22:35 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Meelis Roos, Linux Kernel list, sparclinux
Linus Torvalds <torvalds@linux-foundation.org> writes:
>
> Dang. I guess it needs to be made "unsigned long" again. Which is a
> shame, because we only use a couple of bits from there, and "struct
> inode" really is much too big already.
In the past it was usually enough to just align it to alignof(unsigned
long), not actually make it long. struct page went through this
a long time ago.
This could cause r-m-w races with the next field in theory, but assuming
it's reasonably read-only (ie only set up at inode creation time)
that should be fine.
-Andi
--
ak@linux.intel.com -- Speaking for myself only
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: reorganized struct inode results in unaligned accesses
2011-06-19 22:35 ` Andi Kleen
@ 2011-06-19 23:01 ` David Miller
-1 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2011-06-19 23:01 UTC (permalink / raw)
To: andi; +Cc: torvalds, mroos, linux-kernel, sparclinux
From: Andi Kleen <andi@firstfloor.org>
Date: Sun, 19 Jun 2011 15:35:30 -0700
> Linus Torvalds <torvalds@linux-foundation.org> writes:
>>
>> Dang. I guess it needs to be made "unsigned long" again. Which is a
>> shame, because we only use a couple of bits from there, and "struct
>> inode" really is much too big already.
>
> In the past it was usually enough to just align it to alignof(unsigned
> long), not actually make it long. struct page went through this
> a long time ago.
Hmmm, can this scheme actually work out properly on both big and
little endian? Because endianness determines whether the bits start
in the "lower addressed" 32-bit word or the "higher addressed" 32-bit
word.
If this trick is being attempted elsewhere, I think it could perhaps
account for some strange bugs :-)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: reorganized struct inode results in unaligned accesses
@ 2011-06-19 23:01 ` David Miller
0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2011-06-19 23:01 UTC (permalink / raw)
To: andi; +Cc: torvalds, mroos, linux-kernel, sparclinux
From: Andi Kleen <andi@firstfloor.org>
Date: Sun, 19 Jun 2011 15:35:30 -0700
> Linus Torvalds <torvalds@linux-foundation.org> writes:
>>
>> Dang. I guess it needs to be made "unsigned long" again. Which is a
>> shame, because we only use a couple of bits from there, and "struct
>> inode" really is much too big already.
>
> In the past it was usually enough to just align it to alignof(unsigned
> long), not actually make it long. struct page went through this
> a long time ago.
Hmmm, can this scheme actually work out properly on both big and
little endian? Because endianness determines whether the bits start
in the "lower addressed" 32-bit word or the "higher addressed" 32-bit
word.
If this trick is being attempted elsewhere, I think it could perhaps
account for some strange bugs :-)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: reorganized struct inode results in unaligned accesses
2011-06-19 23:01 ` David Miller
@ 2011-06-19 23:14 ` Andi Kleen
-1 siblings, 0 replies; 10+ messages in thread
From: Andi Kleen @ 2011-06-19 23:14 UTC (permalink / raw)
To: David Miller; +Cc: andi, torvalds, mroos, linux-kernel, sparclinux
> Hmmm, can this scheme actually work out properly on both big and
> little endian? Because endianness determines whether the bits start
> in the "lower addressed" 32-bit word or the "higher addressed" 32-bit
> word.
True, it needs an ifdef, with the other order in BE. struct page has that iirc.
>
> If this trick is being attempted elsewhere, I think it could perhaps
> account for some strange bugs :-)
Well if you want to be sure better try to get rid of the void *
(I tried early on in x86-64, it caused a lot of warnings all over)
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: reorganized struct inode results in unaligned accesses
@ 2011-06-19 23:14 ` Andi Kleen
0 siblings, 0 replies; 10+ messages in thread
From: Andi Kleen @ 2011-06-19 23:14 UTC (permalink / raw)
To: David Miller; +Cc: andi, torvalds, mroos, linux-kernel, sparclinux
> Hmmm, can this scheme actually work out properly on both big and
> little endian? Because endianness determines whether the bits start
> in the "lower addressed" 32-bit word or the "higher addressed" 32-bit
> word.
True, it needs an ifdef, with the other order in BE. struct page has that iirc.
>
> If this trick is being attempted elsewhere, I think it could perhaps
> account for some strange bugs :-)
Well if you want to be sure better try to get rid of the void *
(I tried early on in x86-64, it caused a lot of warnings all over)
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-06-19 23:14 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-19 16:33 reorganized struct inode results in unaligned accesses Meelis Roos
2011-06-19 16:33 ` Meelis Roos
2011-06-19 16:51 ` Linus Torvalds
2011-06-19 16:51 ` Linus Torvalds
2011-06-19 22:35 ` Andi Kleen
2011-06-19 22:35 ` Andi Kleen
2011-06-19 23:01 ` David Miller
2011-06-19 23:01 ` David Miller
2011-06-19 23:14 ` Andi Kleen
2011-06-19 23:14 ` Andi Kleen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.