Supporting guest OS callchain (perf -g) on KVM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

When perf runs on a regular linux, it can collect the current
stacktraces (kernel or user) for each sample. This is a very important
feature, and is utilized by some visualization tools (see, e.g.,
Brendan's post[0]).

As far as I understand, it is not currently implemented in perf [1].

While providing a cross platform, safe solution that works every time
is a challenge, I think we can give a reasonable solution for Linux
guests only.

I think we can, in a portable way, across multiple Linux versions, do
the following:

1) Find out at which stack the guest kernel is.
2) Find out Kernel's text address.
3) Scan the stack up to its maximal size.
4) Record all addresses found in the kernel text segment.

This is more or less what the kernel do when recording its own stack traces[2].

An alternative, more general design is, recording all integers that
looks like addresses in from the location of RIP to the start of the
physical page. This would give you a slightly trimmed stack trace, but
is pretty safe (you'll never get segfault, as RIP must be in a valid
page), and should work across many different guest OS.

I have little experience in the internals of perf or KVM, and would be
happy to any feedback about implementing guest os callchain for KVM.

[0] http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html
[1] https://github.com/torvalds/linux/blob/master/arch/x86/kernel/cpu/perf_event.c#L1968
     /* TODO: We don't support guest os callchain now */
[2] https://github.com/torvalds/linux/blob/master/arch/x86/kernel/dumpstack_64.c#L188
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux