title: Detecting Cache Misses and Hits Pragmatically in Linux
body: <p>I know this is platform-specific question, however, I would like to do some run-time analysis of an application to detect cache misses and hits.  I know cachegrind, a tool for valgrind, and of vtune, and that a slew of other profiling utilities exist.  However, I am interested, in implementing my own version of cache-miss detection.  I know cachegrind acts as a cache-simulator.  Without hacking apart the kernel, how can I detect a cache-miss pragmatically?  I have a feeling this is nearly impossible for a user-land application, but I had to ask anyways.</p>