A tale of an impossible bug: big.LITTLE and caching
mono-project.com
A tale of an impossible bug: big.LITTLE and caching
1–10 of 116 posts
Re: A tale of an impossible bug: big.LITTLE and caching
#2Re: A tale of an impossible bug: big.LITTLE and caching
#3From the pseudo code, what is disadvantage that making get_current_cpu_cache_line_size() always get called?
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
#4From the pseudo code, what is disadvantage that making get_current_cpu_cache_line_size() always get called?
Re: A tale of an impossible bug: big.LITTLE and caching
#5From the pseudo code, what is disadvantage that making get_current_cpu_cache_line_size() always get called?
That's a question for the libgcc team. I seriously doubt it to be slow enough to matter.
Re: A tale of an impossible bug: big.LITTLE and caching
#6From the pseudo code, what is disadvantage that making get_current_cpu_cache_line_size() always get called?
An astute reader might realize that computing the cache line on every
invocation is not enough for user space code: It can happen that a process
gets scheduled on a different CPU while executing the __clear_cache
function with a certain cache line size, where it might not be valid
anymore.Re: A tale of an impossible bug: big.LITTLE and caching
#7From the pseudo code, what is disadvantage that making get_current_cpu_cache_line_size() always get called?
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 retur…
Re: A tale of an impossible bug: big.LITTLE and caching
#8Re: A tale of an impossible bug: big.LITTLE and caching
#9Earlier quoted context omitted.
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 retur…
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
#10There is a Linux kernel patchset currently going through review which provides a workaround for this kind of erratum by trapping the CTR_EL0 accesses to the kernel so they can be emulated with the safe correct value: http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg... and it seems to me that that's really the right way to deal with this.