linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Vineeth Pillai <vineethrp@google.com>
Cc: linux-trace-devel@vger.kernel.org,
	Joel Fernandes <joel@joelfernandes.org>
Subject: Re: [PATCH] trace-cmd: rework of the pid detection of vcpus
Date: Mon, 11 Jul 2022 15:16:55 -0400	[thread overview]
Message-ID: <20220711151655.5a4f4cc0@gandalf.local.home> (raw)
In-Reply-To: <20220504010242.1388192-1-vineethrp@google.com>

On Wed,  4 May 2022 01:02:42 +0000
Vineeth Pillai <vineethrp@google.com> wrote:

> The current detection of vcpu pid is based on the assumption that vcpuid
> is monotonically increasing starting from 0 to max_cpus - 1. But the
> crosvm uses the apic id as the vcpuid if topology is exposed to the
> guest. And apicid can be non-contiguous.
> 
> This patch gets the max apicid from guest and then uses it to detect the
> vcpu pids. Even this approach is not fool proof an it assumes that
> apicid monotonically increases. If we encounter a scenario where it is
> not the case, we might need to implement a mechanism to get a map of
> cpuid to vcpu from the guest and then use that to detect the pid.
> 
> Signed-off-by: Vineeth Pillai <vineethrp@google.com>

If you haven't noticed I have patches that are a workaround that fixes this
issue if the conditions are "right". (I Cc'd you) [1]

The work around is to not depend on the number in debugfs/kvm/vcpuX to
match the CPU of the guest, but instead to match the ordering of the CPUs
of the guest. It also requires that the guest's CPUs are consecutive and
non sparse. That is, if you have vcpu0, vcpu1, vcpu8 and vcpu9 on the
host, then the guest needs to have CPU 0-3 with the mapping of:

 vcpu0 -> CPU 0
 vcpu1 -> CPU 1
 vcpu8 -> CPU 2
 vcpu9 -> CPU 3

and then it works. Of course if this is not true, then it breaks again and
will require some more communication between the host and the guest.

[1] https://lore.kernel.org/all/20220708014244.677826-1-rostedt@goodmis.org/

  parent reply	other threads:[~2022-07-11 19:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04  1:02 [PATCH] trace-cmd: rework of the pid detection of vcpus Vineeth Pillai
2022-05-20 20:08 ` Steven Rostedt
2022-05-23 13:39   ` Vineeth Pillai
2022-05-23 13:47     ` Steven Rostedt
2022-05-24 15:35       ` Vineeth Pillai
2022-05-24 15:53         ` Steven Rostedt
2022-07-11 19:16 ` Steven Rostedt [this message]
2022-07-12 14:17   ` Vineeth Pillai

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=20220711151655.5a4f4cc0@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=joel@joelfernandes.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=vineethrp@google.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).