linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
Cc: Dario Faggioli <dfaggioli@suse.com>,
	Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: Re: [PATCH v2] trace-cmd: Find PID of host-guest task from tracing vsock connection
Date: Fri, 7 May 2021 07:58:34 -0400	[thread overview]
Message-ID: <20210507075834.43497e77@gandalf.local.home> (raw)
In-Reply-To: <CAPpZLN48irG2cuPZi4+RAORbkxpnHudNf1wdXBdjYDmr4e8bhw@mail.gmail.com>

On Fri, 7 May 2021 07:20:15 +0300
Tzvetomir Stoyanov <tz.stoyanov@gmail.com> wrote:

> As Dario said, we can get the guest from the /proc/{kvm_exit task
> ID}/status - the Tgid written there is the guest, the host task which
> runs that guest.

Maybe I'm not understanding the question.

> Doesn't a VMExit always happen in the thread that runs the vCPU anyway?

The problem is that we do not know what Tgid we are looking for. If you
have 10 guests, you have 10 different Tgid's that are running those guests.
How do you know which guest is attached to the cid you are looking for?
There's currently no way to find that mapping. In fact, that's why I posted
this patch:


  https://lore.kernel.org/kvm/20210505163855.32dad8e7@gandalf.local.home/


So you trace the kvm exit, and all 10 guests were active at that time, and
you have 100 threads that called kvm exit. Now how do you find the pid of
the task that owns the cid you are looking for, especially if each guest
has their own cid?

Oh, and the guest is run by a fork of qemu that has some other name! So you
can not rely on looking at the thread's cmdline.

If you look at the code I have, I use the wake ups to find the thread of
the task that is woken up by the current task.

 my-task:

    start tracing kvm_exit and sched_waking

    connect to cid I want.
    my_task -> wakes up vhost-worker
    vhost-worker -> wakes up guest thread with cid I want
    guest-thread -> does kvm_exit

    stop tracing.

    Follow the wake ups to find that guest-thread pid

    Now look at /proc/guest-thread-pid/status
    and get the Tgid of the task in /debug/kvm.

That's what this patch does.

Again, how else can you map the cid to the guest thread? That's the missing
link that following the wake ups give you.

-- Steve

  reply	other threads:[~2021-05-07 11:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-06 21:14 [PATCH v2] trace-cmd: Find PID of host-guest task from tracing vsock connection Steven Rostedt
2021-05-07  0:32 ` Dario Faggioli
2021-05-07  1:40   ` Steven Rostedt
2021-05-07  4:20     ` Tzvetomir Stoyanov
2021-05-07 11:58       ` Steven Rostedt [this message]
2021-05-07 12:48         ` Dario Faggioli
2021-05-07 13:13           ` Steven Rostedt

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=20210507075834.43497e77@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=dfaggioli@suse.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=tz.stoyanov@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).