On Mon, 2021-04-26 at 11:50 -0400, Steven Rostedt wrote: > On Mon, 26 Apr 2021 17:38:09 +0200 > Dario Faggioli wrote: > > > > With the PID of the creating process you can tell (e.g., still from > > /proc) the number of the vm-fd, and we have everything to reach TSC > > offsets in debugfs... Isn't that so? > > I'm not sure what you mean here. > So: ps -eT |grep "CPU 0/KVM" PID SPID TTY TIME CMD 7037 7050 ? 00:26:31 CPU 0/KVM That's vCPU 0's host task. It's a thread whose host PID is 7050. With trace_cmd, you'll see kvm_enter events happening in task 7050, so that's indeed a really good way to retrieve such PID. The process that created this vCPU thread is 7037, which in my case is in fact QEMU: ps aux |grep 7037 USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND qemu 7037 336 17.8 63578168 11647320 ? Sl Apr26 1489:18 /usr/bin/qemu-system-x86_64 -name guest=vm-kvm... This QEMU process (7037) is the one that created the VM itself, with the appropriate ioctl, which returned to it the VM-fd: ls -lR /proc/7037/fd/*|grep kvm-vm lrwx------ 1 qemu qemu 64 Apr 26 22:01 /proc/7037/fd/14 -> anon_inode:kvm-vm So, in this case, it's fd 14. And, in fact, in debugfs, we have: ls /sys/kernel/debug/kvm/ -l drwxr-xr-x 34 root root 0 Apr 26 16:41 7037-14 Hope is clearer (and ideally even useful :-P) Regards -- Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <> (Raistlin Majere)