Hi,
I wanted to investigate the possibility of CAR usage for older Intel processors, thereby reducing ROMCC usage and compilation time substantially. However, there are some properties of caches I'd like to understand better. The following article is what I'm basing my questions on: http://www.linuxjournal.com/article/7105
Please fact-check the following sentences and point out if they contain any errors. Thanks.
As long as cache lines are not evicted or invalidated, it should be safe to use the address range they are covering for CAR. Their content may be written to memory, but their content will not be fetched from memory.
Eviction of a given line A can only happen if the processor reads from a memory location having the same cache index as A but an address differing from A. This is called aliasing.
Thus, by making sure no two memory locations with the same cacheline index are cacheable, eviction will not happen.
The formula to determine the minimum distance between aliasing addresses is cachelinesize*2^indexlength
For n-way associative caches, the minimum distance between aliasing addresses is associativityways*cachelinesize*2^indexlength if you make sure that no more than n memory ranges (each with cache line size) with the same index are marked as cacheable.
Invalidation only happens on WBINVD, INVD and CLFLUSH. Hardware outside the CPU may trigger invalidation as well.
If all of the above is true, it should be possible to use CAR on every processor which has a fine-grained memory range cache control like MTRR. Simply make sure the cacheable area is smaller than cache size and smaller than the minimum aliasing distance, switch caches on and be happy. (External hardware may need to be told it should not trigger invalidation.) Is it really that easy?
Regards, Carl-Daniel
On Wed, Apr 8, 2009 at 8:03 AM, Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net wrote:
If all of the above is true, it should be possible to use CAR on every processor which has a fine-grained memory range cache control like MTRR. Simply make sure the cacheable area is smaller than cache size and smaller than the minimum aliasing distance, switch caches on and be happy. (External hardware may need to be told it should not trigger invalidation.) Is it really that easy?
Eswar, the guy who got us over the hard parts of CAR, indicated that it was really that easy; that all you needed to know about CAR was in Vol. III, you just had to know how to read it (in particular, that CD does not mean Cache Disable).
ron
On Wed, 8 Apr 2009 08:06:37 -0700, ron minnich rminnich@gmail.com wrote:
On Wed, Apr 8, 2009 at 8:03 AM, Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net wrote:
If all of the above is true, it should be possible to use CAR on every processor which has a fine-grained memory range cache control like MTRR. Simply make sure the cacheable area is smaller than cache size and smaller than the minimum aliasing distance, switch caches on and be happy. (External hardware may need to be told it should not trigger invalidation.) Is it really that easy?
Eswar, the guy who got us over the hard parts of CAR, indicated that it was really that easy; that all you needed to know about CAR was in Vol. III, you just had to know how to read it (in particular, that CD does not mean Cache Disable).
From past discusions wasn't CAR originally designed on an Intel processor?
Pentium 1 or something?
On Wed, Apr 8, 2009 at 8:29 AM, Joseph Smith joe@settoplinux.org wrote:
From past discusions wasn't CAR originally designed on an Intel processor? Pentium 1 or something?
I think but am not sure in the microprocessor world it originated with the Power PC. Most good ideas of this kind seem to start with IBM ...
ron
On Wed, 8 Apr 2009 08:49:03 -0700, ron minnich rminnich@gmail.com wrote:
On Wed, Apr 8, 2009 at 8:29 AM, Joseph Smith joe@settoplinux.org wrote:
From past discusions wasn't CAR originally designed on an Intel
processor?
Pentium 1 or something?
I think but am not sure in the microprocessor world it originated with the Power PC. Most good ideas of this kind seem to start with IBM ...
Oh ok. Ack that! I work with IBM's all day long, and not on the PC level :-)
On Wed, Apr 8, 2009 at 9:03 AM, Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net wrote:
If all of the above is true, it should be possible to use CAR on every processor which has a fine-grained memory range cache control like MTRR. Simply make sure the cacheable area is smaller than cache size and smaller than the minimum aliasing distance, switch caches on and be happy. (External hardware may need to be told it should not trigger invalidation.) Is it really that easy?
Yes, but you want to use the CD bit trick to be safe as Ron mentioned. Once you set a range cachable, validated the tags, and then set CD disabled. That region of cache will continue to be used since the tags are valid but it won't get flushed because no new tags will be allocated. As you pointed out instructions can cause the flush but it won't happen automatically. The Geode is actually very close to older Intel processors but uses RCONFs intead of MTRRs.
Marc
On Wed, 8 Apr 2009 10:27:20 -0600, Marc Jones marcj303@gmail.com wrote:
The Geode is actually very close to older Intel processors but uses RCONFs intead of MTRRs.
It sounds like the Geode CAR code may be a good starting point?
On Wed, Apr 8, 2009 at 11:26 AM, Joseph Smith joe@settoplinux.org wrote:
On Wed, 8 Apr 2009 10:27:20 -0600, Marc Jones marcj303@gmail.com wrote:
The Geode is actually very close to older Intel processors but uses RCONFs intead of MTRRs.
It sounds like the Geode CAR code may be a good starting point?
Actually Eswar's original code is a good starting point, and his slides lay it out really well. I believe it was validated initially on an older machine, but that was years ago and memory has faded .
ron
On Thu, 9 Apr 2009 07:23:12 -0700, ron minnich rminnich@gmail.com wrote:
On Wed, Apr 8, 2009 at 11:26 AM, Joseph Smith joe@settoplinux.org
wrote:
On Wed, 8 Apr 2009 10:27:20 -0600, Marc Jones marcj303@gmail.com
wrote:
The Geode is actually very close to older Intel processors but uses RCONFs intead of MTRRs.
It sounds like the Geode CAR code may be a good starting point?
Actually Eswar's original code is a good starting point, and his slides lay it out really well. I believe it was validated initially on an older machine, but that was years ago and memory has faded .
Wow your right :-) Carl-Daniel, did you see the doc? He even talks about MTRR's. http://www.coreboot.org/images/6/6c/LBCar.pdf