Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What's the meaning of files in the folder /sys/devices/system/cpu/cpu0/cache/index0? I see these files in the folder:

coherency_line_size  number_of_sets           shared_cpu_list  size  ways_of_associativity
level                physical_line_partition  shared_cpu_map   type
  1. What's the meaning of them?
  2. How could I know whether the L2 cache is shared or not. If it is how could I know which cpu it is shared with?
  3. And what's the meaning of index0 index1 .. index3. Does index3 represent L3 cache and index2 represent L2 cache?

In /sys/devices/system/cpu/cpu0/cache/index3 there are these files:

cache_disable_0      level                    shared_cpu_list  subcaches
cache_disable_1      number_of_sets           shared_cpu_map   type
coherency_line_size  physical_line_partition  size             ways_of_associativity

Why can I not see subcaches in index1 or index2? And shared_cpu_list shows 0_7. Does it mean that this cache is shared with cpu0 to cpu7?

share|improve this question

migrated from Mar 27 '12 at 15:34

This question came from our site for professional and enthusiast programmers.

The meaning of the numbers in index0, index1, etc do not necessarily correspond to levels; they're just numbered. If you want to know what level cache it is, look at the level file. 1 means L1, 2 means L2, 3 means L3. They tend to be numbered lowest level to highest, but I don't know if there's any requirement of this.

To know whether L2 is shared, first determine which cache is L2. Then look at the shared_cpu_list for that cache. It will be startnumber-endnumber of the sharing. (I don't know what it looks like when it isn't shared because my computer only has shared caches, but I'd guess either just a single number or something like "0-0".) For example, on my quad-core, hyperthreaded Sandy Bridge, if I look at the L2's shared_cpu_list, I see "2-3", which tells me that it is shared with cpu2 (which is actually the same physical CPU because of hyperthreading, so it's not really a shared cache).

For my L3 cache, of which there is only one for all caches, I see "0-7", so I assume that means it's shared for all CPU's 0 through 7. I've never seen an underscore in one of those files though.

A few other meanings:

  • type-"Instruction" means it is only used to cache instructions (code), "Data" means it is only used to store data (variables, etc), and "Unified" means there is no such separation and it may store either.
  • coherency_line_size-how many bytes are in a cache line, which is the unit in which memory is read and written to/from main memory.
  • ways_of_associativity-how many different cache slots a given line can be mapped to. Higher is better (it means you're less likely to have a working set that is smaller than cache but can't simultaneously be in cache because lots of data wants to be in the same cache lines), but is hard to implement, especially in the lower-level caches that have to be faster. 8 is pretty common for L1.
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .