Trouble understanding Virtual cache

  • Thread starter Thread starter Fionn00
  • Start date Start date
  • Tags Tags
    Virtual
Click For Summary

Discussion Overview

The discussion revolves around the concept of virtual cache in computer architecture, particularly in relation to how it differs from physical cache. Participants explore the implications of using virtual addresses for cache operations, the role of memory management units (MMUs), and the efficiency of virtual versus physical caching mechanisms.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant expresses confusion about the meaning and utility of virtual cache, questioning how it operates in relation to physical cache and the MMU.
  • Another participant explains that for most processors, cache addresses are virtual addresses, and if data is in the cache, physical address mapping is unnecessary.
  • A participant seeks clarification on whether accessing cache involves physical addresses or if there is a different mechanism at play, highlighting their difficulty in distinguishing between physical and virtual cache.
  • Further elaboration indicates that X86 processors utilize a translation lookaside buffer (TLB) to translate virtual addresses to physical addresses, and that the handling of cache misses involves additional steps with descriptor tables.
  • One participant asserts that there is almost no difference between physical and virtual caches, emphasizing that the main distinction lies in the surrounding processes and the overhead associated with address translation.
  • It is noted that virtual address caches may be more complex and costly due to the larger address space they must accommodate compared to physical address caches.

Areas of Agreement / Disagreement

Participants express varying levels of understanding regarding the differences between virtual and physical cache, with some agreeing on the operational efficiency of virtual caches while others remain uncertain about the implications and processes involved.

Contextual Notes

Participants discuss the efficiency of virtual versus physical caches, the overhead of address translation, and the potential complexity of virtual address caches without reaching a consensus on the best approach or the implications of each method.

Fionn00
Messages
12
Reaction score
0
Trouble understanding "Virtual cache"

Hi,

I'm having trouble understanding what virtual cache actually means.

I understand that to get a cache hit (physical cache) you index to the cache set and compare all the tags in that set with the tag in the cache address you are looking for.

I also understand how the memory management unit and the Transition look-aside buffer work for virtual memory. Page tables map, virtual addresses of each process, to physical addressees in memory.

But what does virtual cache mean? I mean if you give physical cache addresses a virtual address what are you achieving?
And also do virtual cache addresses get mapped using the same MMU as real memory?

I've read Wikipedia and such but I just can't understand why this would be useful.

Thanks!
 
Technology news on Phys.org
For most processors, the cache addresses are virtual addresses. If the data resides in cache, there's no need to obtain a physical address for that cached data. The conversion from virtual to physical is performed via descriptor tables outside of any cache operations.

On a side note, for memory mapped I/O like DMA that uses physical addresses, the pages of memory for that I/O need to be loaded and locked, then their addresses translated from virtual to physical for the memory mapped I/O to take place. For Windows this is done via a function called MmProbeAndLockPages().
 
Ok thanks, so if the processor wants to access memory, it sends the virtual address to the mmu and the cache which then works out if it resides in cache (it always resides in ram also)?
And if it resides in cache does it then go to the cache using a physical address (set no. , tag and offset) or does it access the cache in some other way? If so then how does physical cache differ?

Basically I can't see the difference between physical and virtual cache.
 
As mentioned in my last post, for most processors, if there is a cache hit, then no physical address mapping takes place, since there's no need to do this if the desired data is in the cache. How the rest of this is done for non-cache hits depends on the processor. X86 processors use a translation look aside buffer cache which is a type of content addressable memory (fully associative) to translate a sub-set of possible virtual addresses to physical addresses. If not in the table, then the descriptor tables that reside in ram are used. If the desired pages are currently not in RAM, then the operating system swaps out pages if needed and swaps in pages from the swap file. The descriptor tables are updated to reflect the updated swapped pages, and the TLB is updated to remove any swapped out pages (it may just be cleared, I don't know if it's possible to partiallly clear out the TLB).

There may be some processors that map virtual to physical addresses first, then use a cache based on physical addresses, but the mapping step would normally increase the overhead, so I'm not sure if any currently produced processors do this.
 
  • Like
Likes   Reactions: 1 person
Fionn00 said:
Basically I can't see the difference between physical and virtual cache.

There is (almost) no difference between those caches. The differences are in what's around them. For caches that are keyed by physical addresses, virtual to physical address translation must always take place before addressing the cache. Even if that is very efficient, it is still extra processing, which requires either more time or more silicon, or both. Caches keyed by virtual addresses eliminate this need, and the virtual to physical address translation is done only when there a real need to access memory.

Now the "almost" bit. Virtual address caches are somewhat more expensive because a typical virtual address space is (much) greater than a typical physical address space. So a virtual address cache needs more address lines, more logic elements and more silicon (more power, too).
 
  • Like
Likes   Reactions: 1 person

Similar threads

Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
8K
Replies
10
Views
4K
Replies
6
Views
4K
Replies
3
Views
3K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 14 ·
Replies
14
Views
6K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K