Page color (sheet coloring)

Source: Internet
Author: User

0) First discuss how the cache line index is positioned.

Given a 32-bit virtual address, how to locate the cache line?
The answer is vipt (virtual indexed, physical taged), which is the physical address as the index of the set of the cache line, which is compared as the tag.

For example: 32k cache 8 is connected, the cache line size is bytes. So there are 64 set (32k/(8 * 64)).

   Physical Address                             5      0   12 Bits->|   | <---page frame--->| Page Offset |    [       TAG          |index |  Offset]   tag   : RAT (real address TAG)   set  index   offset:cache line offset.

(1) First locate set with the physical Address (12..5) 6 bit as index.  (Note: The low 12-bit physical address is the low 12-bit of the virtual address, which is offset within the page, so called ' virtual indexed '). (2) in the face of the set of 8 cache line, with the physical address of [31, 12] altogether 20 bits as the Tag comparison, determine the cache line. (Physical taged)

Here, the lower 12 bits of the address are part of the internal offset of the cache line to locate the specific byte;
The other part as set index. Note that there is a limit to the number of cache sets because the cache line size is bytes, the address is 6 bits low as offset, and the remaining 6 bits in the lower 12 bits as set index, then when the number of cache set exceeds 2^6 (64) What about the one?

  That is, the cache size is too large, how to index? For example: 2m-8way-cache line 64bytes? A total of 4,096 set address low 12 bits in the remaining 6bit is obviously not enough.


1) The big cache is useless? Of course the system Designer is not so stupid. So where do you get the index bit? Isn't there a physical address?
Physical Address to                   A     5      0|<----- -BITS---->|<- ABits->| |<---page frame--->| Page Offset | to              -    A     5      0|<----- -BITS +--->|<- ABits->|[TAG| Index |offset] Here from the physical address borrowed6Bits. ( -, A] Then use ( -,5These bits can be indexed to 4,096 cachesSet。
2) What is page color?
Physical Address to                   A     5      0|<----- -BITS---->|<- ABits->| |<---page frame--->| Page Offset | to              -    A     5      0|<----- -BITS +--->|<- ABits->|[TAG| Index |Offset] ( -, A]: color bits. Remember to borrow it from the physical address.6Bits?They are called color bits. can be used ( A,5) This 6-bit index of continuous -A cacheSetcalled bin. This is equivalent to putting the cacheSetGroup again, each group called bin. At the same time think in a group of cacheSetwith the same color, the name is really not creative. and color bits is used to select Bin. According to the above example, -A cacheSetFor one bin (one color), altogether there are -Color.
3) What is color bits for?

Without color bits, when an address is accessed, the offset in the page is fixed, meaning that the index value of the cache set is fixed.
With color bits, the OS has a say to the cache (because the allocation of the physical page is calculated by the OS, so the color bits OS can also be counted)
So the OS can decide which bin to put an address on.

For example, access to the virtual address 0x12345678 can map physical address 0x30000678, or you can map the physical address 0x30001678
0x30000678 color bits determines that the address is mapped to bin 0
0x30001678 color bits determines that the address is mapped to bin 1

So the OS can map an address to a different color cache set.

4) General L1 cache is small, not color bits, and L2 L3 has color bits

Page color (sheet coloring)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.