Obtaining the CPU L2 shared memory percentual of usage on Linux machine

cn flag

On Linux based systems, how can I estimate or maybe read the CPU L2 shared memory % of usage?

anx avatar
fr flag
What is the use of unused CPU caches? You will more likely get a useful answer if you [edit] your question to include the specific *problem* you are trying to solve through estimating or measuring whatever it is you are asking for.
cn flag

You can not because it is a metric without any sense. The result will be 100% ALL THE TIME (outside a cache flush or the computer starting).

Cache is used on a LRU (Last Recently Used) method. L2 cache will run full at computer start (when the boot loader runs) and then stay at 100% utilization.

A better metric - one that does make sense actually - would be "% of requests that trigger a load". Means, what percent of queries can be answered from the cached data (or, as I said, trigger a load from the next cache/RAM).

But unless you have a cache flush (memory barrier) - the cache will never be not fully utilized as it would make no sense to waste it. It can contain old data not used anymore, but it will be utilized.


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.