Desperado17
Desperado17

Reputation: 1015

How does perf sample kernel stacks?

As far as I know perf is able to sample a full callstack for every process/thread even if it currently is inside the kernel. Since perf is running in userspace I assume, I want to know how it gets access to the kernel part of the stack of a different process/thread.

The purpose is to write an application that can sample callstacks of other processes/threads even if they currently are in kernel.

Regards

Upvotes: 0

Views: 299

Answers (1)

Zulan
Zulan

Reputation: 22670

perf consists of two parts. The userspace tools, and the perf_event_open syscall.

Generally, the stack sampling is done by the kernel through the syscall. You can write an application with also uses perf_event_open - by default kernel samples are included (exclude_kernel==0).

Upvotes: 1

Related Questions