News for hackers. Stuff that matters.
Re:A tale of an impossible bug: big.LITTLE and caching by JoshTriplett on Monday September 12, 2016 @01:59PM (#12482037)
Performance. get_current_cpu_cache_line_size would need to run some code to determine the cache line size, and that code takes longer to run than using a cached value.

Along similar lines, if you have an optimized routine using specific CPU instructions, you don't want to call CPUID (or equivalent) on every call to find out if you have those instructions; you want to call it once and cache the answer. If it can return different answers on different CPUs in the same system, you need to use a different mechanism instead, such as asking the OS for the least common denominator features of available CPUs, or notifying the OS that you need to run on one of the more capable CPUs that has the feature you need.

Re:A tale of an impossible bug: big.LITTLE and caching by cm2187 on Monday September 12, 2016 @02:04PM (#12482073)
Stupid question but does that work in a virtualised environment where your program can be live-migrated to another physical machine with a different CPU?
Re:A tale of an impossible bug: big.LITTLE and caching by tcas on Monday September 12, 2016 @02:09PM (#12482133)
I believe virtual machines will typically alter the CPUID a bit: https://tech.mendix.com/linux/2016/08/18/xen-cpuid-masking/

You'll choose a lowest common denominator of features sets.

Re:A tale of an impossible bug: big.LITTLE and caching by Someone on Monday September 12, 2016 @02:39PM (#12482444)
As others said, one typically pretends to run a fixed CPU on all CPUs.

Also, for this specific case, I doubt migration will keep around the contents of the cache lines and their 'dirty' bits (corollary: it will be possible to reliably detect a move, if one is willing to continuously run code that detects cache-line timing differences)

Re:A tale of an impossible bug: big.LITTLE and caching by mjg59 on Monday September 12, 2016 @02:06PM (#12482095)
Nope. There's not really any alternative other than "Don't do that", or limit migration to machines that have a superset of the instructions on the original machine.
Re:A tale of an impossible bug: big.LITTLE and caching by pm215 on Monday September 12, 2016 @02:12PM (#12482156)
Usually you configure the VM to only report CPUID values corresponding to lowest-common-denominator features on everything you might want to migrate to. Then as long as the guest code plays nicely and looks at the CPUID feature flags to see what it can use, it'll migrate happily. QEMU has support for this, for instance.
Re:A tale of an impossible bug: big.LITTLE and caching by cm2187 on Monday September 12, 2016 @02:08PM (#12482121)
I presume that AWS or Azure wouldn't do that?