Skip to contentSkip to conversation

Cache aliasing

DISCUSSION John Newlin 2 participants 2 messages Feb 25, 2003 – Feb 26, 2003

lore
Share & tools
lore
#0 lore raw

I'm working on a port of Linux to a processor that has virutally indexed caches that are larger than the page size. This brings up the documented feature of cache aliasing.

As I am looking over how other ports (sh-4, sparc64 etc) have solved the problem, it made me wonder if this is the best way to solve the problem.

Would it make more sense to just always ensure that your virtual and physical pages had matching "color" bits?

For example, in the memory allocator, you would have to pass in the vaddr that you wanted to map to physical space, and then the memory allocator would find a physical page of the correct color.

And in the case where you are mirroring a user page into kernel space, you would have to choose a virtual address of the correct colour. On architectures like x86 where cache aliasing is never a concern, this code could be optimized away.

The benefits would be, any architecture that has cache aliasing wouldn't have to go through hoops to keep memory coherent, and depending on how often memory is flushed in the caches it might give some performance boost.

-John

#1 lore raw
Quoted 2 lines · John Newlin

Would it make more sense to just always ensure that your virtual and physical pages had matching "color" bits?

No, it's actually very difficult to solve the problem this way.

The reason being that there is always a fixed "kernel virtual color" every physical page has. So essentially, if you colored userspace, you could only put into user virtual address with color X only pages that also have kernel virtual color X.