Messages in this thread | | | From | Linus Torvalds <> | Date | Fri, 2 Mar 2012 16:24:11 -0800 | Subject | Re: Word-at-a-time dcache name accesses (was Re: .. anybody know of any filesystems that depend on the exact VFS 'namehash' implementation?) |
| |
On Fri, Mar 2, 2012 at 4:17 PM, <david@lang.hm> wrote: > > or did some CPUs have efficient char access, but inefficient unaligned word > access?
Tons of CPU's have efficient char accesses but horrible unaligned word accesses. Some are even outright buggy (ie at least some ARM cores) and load crap. Others take a fault.
They just aren't x86, because x86 has traditionally had code with a fair amount of unaligned loads and stores (and not just for historical reasons either: even modern code replaces constant-sized memcpy() etc with direct loads and stores)
For some other architectures, we could just use "get_unaligned()", which fixes things up for them. I could have made that explicit, even if it doesn't matter on x86.
So the bigger portability problem to some degree is the fact that it is limited to little-endian, so even if you have a CPU with good unaligned accesses (some POWER chips do ok, for example, although not all), you'd have to also do something with the mask generation (which currently uses the "(x-1)&~x" trick that means that it generates the mask of the *low bits* - and then assumes that "low bits" means "first bytes" - ie little endian).
Linus
| |