I'm using perf to measure tlb misses of a userspace process. Then, when a system call comes, I want to read userspace misses, i have a syscall handler at the kernel and i need to read or extract from kernel module. (I don't want to use strace). I examined the task_struct and saw a variable named perf_event_ctxp. I wonder if it would be possible for me to read the miss numbers from here, I couldn't find any information in the documentation. or do you have any idea where I can read the counter values specific to a process on the kernel side (started with perf).
1
votes
1 Answers
0
votes
First, there is a flag for measuring only in-kernel events. From perf-record(1),
--all-kernel
Configure all used events to run in kernel space.
Next, there are several hardware events on x86 for different kinds of TLB misses. For example, on my machine, the following hardware events are available:
# perf list
...
dTLB-load-misses
dTLB-loads
dTLB-store-misses
dTLB-stores
iTLB-load-misses
iTLB-loads
...
So, you can use any of these events, and the --all-kernel flag. For example, if you want to measure the number of dTLB load and store misses in the kernel for ls(1), the following command should suffice:
perf record --all-kernel -e dTLB-store-misses -e dTLB-load-misses -- ls