Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between hardware Event and hardware cache Event in perf?

Tags:

linux

perf

When I typed perf list command, I found there are two kinds of event: Hardware event and Hardware cache Event. What is the difference between the two ?

What is the difference between cache-misses and LLC-misses ? Does cache misses include LLC-misses ?

Does perf tools reduce the total performance when I test a program ?

like image 529
user861491 Avatar asked Dec 17 '12 04:12

user861491


People also ask

What is a perf event?

perf event provides support for kernel software events not provided by hardware. Events such as context switches and page faults are exposed to the user using the same interface as hardware events, allowing easier access by tools. E. New Hardware Features.

What is perf cache misses?

When a program accesses a memory location that is not in the cache, it is called a cache miss. Since the processor then has to wait for the data to be fetched from the next cache level or from main memory before it can continue to execute, cache misses directly influence the performance of the application.

What is L1 Dcache?

L1 is the Level-1 cache, the smallest and fastest one. LLC on the other hand refers to the last level of the cache hierarchy, thus denoting the largest but slowest cache. i vs. d distinguishes instruction cache from data cache. Only L1 is split in this way, other caches are shared between data and instructions.

What is perf record?

Perf is an interface to access the performance monitoring unit (PMU) of a processor and to record and display software events such as page faults. It supports system-wide, per-thread, and KVM virtualization guest monitoring. You can store resulting information in a report.


2 Answers

According to the man page of the perf_event_open system call (used internally by perf user level utilities):

  • hardware events: This indicates one of the "generalized" hardware events provided by the kernel
  • hardware cache events: This indicates a hardware cache event.

More over I am wondering if this has some link with what is called Non architectural and architectural events in [Intel® 64 and IA-32 Architectures Software Developer’s Manual 3B]Intel® 64 and IA-32 Architectures Software Developer’s Manual 3B2.

Regardless of the exact meaning of this categorization, cache-misses as stated here in a previous question and in the man page I mentioned above, represents the number of memory access that could not be served by any of the cache. Said differently, it means the number of cache misses in the last level cache. As a consequence I guess this is the same than LLC-misses, unfortunately I am not able to confirm that on my laptop because LLC-misses is not supported.

Regarding your last question, the overhead incurred by performance monitoring should be very low. Indeed, the overhead is mainly due to reading the counter values, and using perf stat I guess that this reading should be done only once at the end of the execution (considering that counters don't overflow)

like image 95
Manuel Selva Avatar answered Oct 18 '22 19:10

Manuel Selva


Question 2: If I look at ARM kernel code ("arch/arm/kernel/perf_event_v7.c") for perf

cache-misses means ARMV7_PERFCTR_L1_DCACHE_REFILL which means first level data cache miss So LLC probably means Low level Cache misses (L3 probably)

You can look at architecture specific kernel code what value ARMV7_PERFCTR_L1_DCACHE_REFILL has And the technical reference manual to know what exactly that value means. http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388i/BEHCCEAE.html

Question 3: I believe perf reads counters from hardware registers (atleast for HW performance counters)so wont really affect the performance of your code. As it wont really put code hooks inside your code. But some papers say there is 5% performance penalty if you use perf in the code.

like image 38
Milind Dumbare Avatar answered Oct 18 '22 19:10

Milind Dumbare