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

Re: MySQL on T2000



I think you misunderstand the compiler option, which is fine, because it applies to Solaris. Because accessing unaligned memory raises a hardware error which forces a kernel context switch, you can mitigate the risk of this by assuming that any k-aligned object is actually only j-aligned, j < k, and perform k / j loads instead. This reduces performance compared to a full k-sized load, but it's better than nothing. You correctly understood this part -- HOWEVER, if you STILL get an unaligned load error, the kernel can transparently handle this for you if you opt-in. Most likely if you're developing new code, you will opt-out, because it's better to find performance issues like this while still developing, but if you inherit x86 code that does terrible things, then it may save developer time to just save "whatever, just emulate it". In such a case, you will generate a hardware trap, but the process will not get a SIGBUS -- the difference is subtle but important. Again, this is a feature of Solaris/SPARC -- using -xmemalign[n]i

The point of my previous post was to show that the default Linux behavior (for me) was (in kernel mode) to simple emulate the load with multiple smaller loads. I wouldn't be surprised if there was a way to enable unaligned load fixups automatically in Linux -- probably a kernel option or runtime configuration. Short version -> Not getting SIGBUS is NOT proof that unaligned loads are not happening.

Patrick


On Fri, Jan 31, 2014 at 3:59 PM, brian m. carlson <sandals@crustytoothpaste.net> wrote:
On Fri, Jan 31, 2014 at 03:50:37PM -0600, Patrick Baggett wrote:
> Yes, it does [1], and so does Solaris using SunPro CC using -xmemalign [2]

Okay, what's happening here is that someone is forcing the compiler to
generate multiple aligned loads for pointers that are not properly
aligned, so that an unaligned load doesn't happen.  In the first case,
that's because the kernel has functions to mark where unaligned accesses
would otherwise occur.

Regardless, if userland tries to perform an unaligned load, the process
will get a SIGBUS.

--
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187


Reply to: