linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dario Faggioli <dfaggioli@suse.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Tzvetomir Stoyanov <tz.stoyanov@gmail.com>,
	Joel Fernandes <joelaf@google.com>,
	"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>,
	Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: Re: Instructions for clock sync for tracing host/guest
Date: Mon, 26 Apr 2021 18:10:43 +0200	[thread overview]
Message-ID: <9c7968f1bc98a12754ea129906e727b9c344f06c.camel@suse.com> (raw)
In-Reply-To: <20210426115014.34db8808@gandalf.local.home>

[-- Attachment #1: Type: text/plain, Size: 1749 bytes --]

On Mon, 2021-04-26 at 11:50 -0400, Steven Rostedt wrote:
> On Mon, 26 Apr 2021 17:38:09 +0200
> Dario Faggioli <dfaggioli@suse.com> 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/
-------------------------------------------------------------------
<<This happens because _I_ choose it to happen!>> (Raistlin Majere)

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-04-26 16:10 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAJWu+opJEtyXyhYnKL1iNzhfSCYRZN4PD50igckVvQV8416HEQ@mail.gmail.com>
     [not found] ` <CAPpZLN5pTxjnrQ=x0Kq7sGko+GSVv5gPTjSgETvO9kX1hgNCpQ@mail.gmail.com>
     [not found]   ` <20210418080435.3c3e2d24@oasis.local.home>
     [not found]     ` <CAJWu+oqG9T5v_2q+crsrsPe9GMcG0OSW7kcZ5ea=r1L07WKZJA@mail.gmail.com>
     [not found]       ` <CAPpZLN7MDoFYaJZG1+_4gUpYwt2RfAMfB=BDvGYch2eOfS342Q@mail.gmail.com>
     [not found]         ` <CAJWu+oosbOV=cigwfkNBLSpaMt3RExWLap3u+4G7pkYqQy_EXw@mail.gmail.com>
     [not found]           ` <CAPpZLN7=e+TL5WY7RKAo9Hm6AJGDygneqUWwoNnZexx+=KrxsQ@mail.gmail.com>
     [not found]             ` <CAJWu+op2bU+-z6W_+XB0v2g__oGXj8Be2WWDg36E9uaCjNp+HA@mail.gmail.com>
     [not found]               ` <CAJWu+orm+tm3C=MSF=p9eC1qgfE_pXzA2B0CiXgVXFemVRiVtA@mail.gmail.com>
     [not found]                 ` <CAJWu+opzT20OprG-8L_Lvv2DaJzF-ROaKnEWX8wjrbagPpwVzA@mail.gmail.com>
     [not found]                   ` <CAJWu+oqJk+BE2q=CjtAZJko-kJCS0Kyqwor_FVM3fu-X-rRRkg@mail.gmail.com>
     [not found]                     ` <20210422153845.3e6e9304@gandalf.local.home>
     [not found]                       ` <CAJWu+ooTVfprhd49__0H_61Fz_rSQA53n-VM6e1eEr8cTZ5aYQ@mail.gmail.com>
     [not found]                         ` <20210422154830.52f3e4f5@gandalf.local.home>
     [not found]                           ` <CAJWu+oqYWv5OHTLrC+oa7Y+LOe7AHumhtyVP8TC2LkK2=_JjPA@mail.gmail.com>
     [not found]                             ` <20210422160313.2eee1f77@gandalf.local.home>
     [not found]                               ` <CAJWu+ooZ9UptDBdii7dj=ui7dhiseOqZJE1CqMhP-Zy98QueXA@mail.gmail.com>
     [not found]                                 ` <CAJWu+opsWVBDA8R-wVhhn2G_6h1LsMwzRDE=gMruZpFG+AH5zQ@mail.gmail.com>
     [not found]                                   ` <CAJWu+oo8W9TVexZhhOs4P-DW1bH5DSjAzuV8QZMxvt9XHbRnJg@mail.gmail.com>
2021-04-23  8:16                                     ` Instructions for clock sync for tracing host/guest Tzvetomir Stoyanov
     [not found]                                       ` <CAJWu+orjdLAdcUJKWj6f8gUtXUzBcvJEPeKjtVZ7P+EpiptF0w@mail.gmail.com>
2021-04-23 11:33                                         ` Steven Rostedt
2021-04-23 15:49                                           ` Joel Fernandes
2021-04-26 10:58                                         ` Tzvetomir Stoyanov
2021-04-26 12:44                                           ` Steven Rostedt
2021-04-26 12:59                                             ` Tzvetomir Stoyanov
2021-04-26 14:11                                               ` Dario Faggioli
2021-04-26 14:51                                                 ` Steven Rostedt
2021-04-26 15:02                                                   ` Tzvetomir Stoyanov
2021-04-26 15:31                                                     ` Steven Rostedt
2021-04-26 15:37                                                       ` Steven Rostedt
2021-04-26 15:44                                                       ` Dario Faggioli
2021-04-26 15:38                                                     ` Dario Faggioli
2021-04-26 15:50                                                       ` Steven Rostedt
2021-04-26 16:10                                                         ` Dario Faggioli [this message]
2021-04-25 18:29                                       ` Steven Rostedt
2021-04-26 10:39                                         ` Tzvetomir Stoyanov
2021-04-26 12:56                                           ` Steven Rostedt
2021-04-26 13:24                                             ` Dario Faggioli
2021-04-26 13:51                                               ` Tzvetomir Stoyanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9c7968f1bc98a12754ea129906e727b9c344f06c.camel@suse.com \
    --to=dfaggioli@suse.com \
    --cc=joelaf@google.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tz.stoyanov@gmail.com \
    --cc=y.karadz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).