title: Find out how many hardware performance counters a CPU has
body: <p>On an Intel or AMD x86-64 system running Linux, where/how can I find out the number of hardware performance counters that my CPU has?</p>
  
  <p>I would like to use the Linux <code>perf</code> tool to gather hardware performance counter data while executing some applications. The perf wiki's <a href="https://perf.wiki.kernel.org/index.php/Tutorial" rel="noreferrer">tutorial</a> says that if I specify (using the <code>-e</code> flag to <code>perf stat</code> or <code>perf record</code>) more hardware events than there are performance counters in my CPU, then these events will be multiplexed over the counters during the execution, allowing them to all be tracked during a single <code>perf</code> command, but possibly reducing accuracy because not all counters are active all the time. (Note that I am concerned with hardware events here, such as for cache and TLB behavior - I know that a large/unlimited number of kernel software tracepoints can be tracked without inaccuracy).</p>
  
  <p>If I find out my processor model, is there an Intel/AMD website where I can find this information? Is there a simple command that I can run on the system to check the number of hardware counters? I've examined the output of <code>cat /proc/cpuinfo</code> and <code>x86info -a</code>, but couldn't find this information.</p>