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

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


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.