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>,
	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, 07 May 2021 02:32:05 +0200	[thread overview]
Message-ID: <f4c372f2138151299588b702567827a61954f775.camel@suse.com> (raw)
In-Reply-To: <20210506171400.7c00b731@gandalf.local.home>

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

On Thu, 2021-05-06 at 17:14 -0400, Steven Rostedt wrote:
> Searching for the qemu task to find what task the CID is for is not a
> reliable method, as the qemu executable may be called different names
> on
> different systems, and qemu may not even be used.
> 
> Instead, trace the sched_waking and kvm_exit events and do a vsock
> connection to the CID. By doing so, you can find the task that runs the
> guest.
> 
>  trace-cmd wakes up "vhost-<pid>"
>  vhost-<pid> wakes up "CPUX/KVM"
>  CPUX/KVM calls "kvm_exit"
> 
This may very well be me, but I don't get why we need to follow the
wakeup chains.

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

I mean, just by tracing 'kvm:kvm_exit', I get:

 <...>-74350 [003] 903542.374465: kvm_exit:             reason MSR_WRITE rip 0xffffffffac4757d4 info 0 0
 <...>-74355 [012] 903542.374465: kvm_exit:             reason MSR_WRITE rip 0xffffffffac4757d4 info 0 0
 <...>-74350 [003] 903542.374470: kvm_exit:             reason MSR_WRITE rip 0xffffffffac4757d4 info 0 0
 <...>-74355 [012] 903542.374470: kvm_exit:             reason MSR_WRITE rip 0xffffffffac4757d4 info 0 0
 <...>-74355 [012] 903542.374485: kvm_exit:             reason MSR_WRITE rip 0xffffffffac4757d4 info 0 0
 <...>-74355 [012] 903542.374487: kvm_exit:             reason HLT rip 0xffffffffacca465d info 0 0
 <...>-74350 [003] 903542.374488: kvm_exit:             reason MSR_WRITE rip 0xffffffffac4757d4 info 0 0
 <...>-74350 [003] 903542.374490: kvm_exit:             reason HLT rip 0xffffffffacca465d info 0 0
 <...>-74341 [126] 903542.374813: kvm_exit:             reason MSR_WRITE rip 0xffffffffac4757d4 info 0 0

This tells us already that 74341, 74350 and 74355 are the pids of some
vcpu threads on the host.

At this point, /proc will tell us that these are in fact vcpus of the
same VM, and which is the PID of the thread group leader that we want
to use in /sys/kernel/debug/kvm:

grep Tgid /proc/{74341,74350,74355}/status
/proc/74341/status:Tgid:        74306
/proc/74350/status:Tgid:        74306
/proc/74355/status:Tgid:        74306

ls /sys/kernel/debug/kvm/
74306-19

What am I missing?

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-05-07  0:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-06 21:14 Steven Rostedt
2021-05-07  0:32 ` Dario Faggioli [this message]
2021-05-07  1:40   ` Steven Rostedt
2021-05-07  4:20     ` Tzvetomir Stoyanov
2021-05-07 11:58       ` Steven Rostedt
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=f4c372f2138151299588b702567827a61954f775.camel@suse.com \
    --to=dfaggioli@suse.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --subject='Re: [PATCH v2] trace-cmd: Find PID of host-guest task from tracing vsock connection' \
    /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

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).