[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A KernelShark plugin for Xen traces analysis


  • To: Steven Rostedt <rostedt@xxxxxxxxxxx>, Giuseppe Eletto <giuseppe.eletto@xxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 14 Apr 2021 11:07:33 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0LC4EL6UtO6m71mh8ggyTrKDXYvhZDr87O/S0qcivkQ=; b=RTL6Yk73StAfU4Pzkq/gs2kjtqjGmnOjmN13tYgasWS0YwfpyAOtc3CUwT2gvPR0xj6KRodUotx6SwBrZFHdNGFIR9RhJxMFnGTv2SlSMo6WixPRC3lBbtHL3+jFniKaiPZejIMM5ziyetoqW5AD6NKF8jHj+mCHd10P0jigFvUPThl9V7uMIiob8vhJZ9Ds9ANTKFq4A8w9G/ZVrDsxSvytVFT0taQ32b2dCsqAZMoiDyaVCwqpnVrnbPn87MzeAEf1XB+l8cTnLx2c/iex+lK3Q15fOF78Nro8yWWLt9CSrawws+znsg/UvpIANjk0u/Mn28MECMNZGrv8j0bFGQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J+a7+CNEKGwhkHYHYdqZ4tZr+fpTfL3SoOQKfJZEfMjCwnAK5RYgO+P/J3OPCMe8Vsf6nnsVgp2AuZUuph0xtoS1oa9QHZE+AMqZX06RAlCSgC8LsDznNToFdj5C0b6O0iWfCb/Q5oLu4JmKj+AviSivJCGIoLqWw3jVmHV+mrNgW/E5+HniQ2NoWlju12/fx6M5yeDkDv6Ml2/5CR7YTQ0/JqsebwZQUZDrvf0+J1I/VgO+glbb9zjjjy7b7NIZCgScARh5Kg6pn0UDta5jaqMLtPpd6dtSlrFLyFy0Drq6TC55JKO9c4kpEqzKK7VjBccpT1sMpQO1D5MNGVW2CA==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <linux-trace-devel@xxxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Dario Faggioli <dfaggioli@xxxxxxxx>, Enrico Bini <enrico.bini@xxxxxxxx>
  • Delivery-date: Wed, 14 Apr 2021 10:07:47 +0000
  • Ironport-hdrordr: A9a23:fyEyK6GqtRkHpEC3pLqFY5TXdLJzesId70hD6mlYcjYQWtCEls yogfQQ3QL1jjFUY307hdWcIsC7L0/03aVepa0cJ62rUgWjgmunK4l+8ZDvqgeOJwTXzcQY76 tpdsFFZOHYJURmjMr8/QmzG8shxt7Cy6yzmeLC1R5WLT1CQYsI1XYcNi+wFEpqSA5aQb8wE5 SB7sRKzgDQB0g/RMK9G3UDQqz/vNXNjp3relorABQg5QmIg1qTmcHHOjKf2QoTVC4K/Kc6/Q H+4nDEz4iAk9X+8B/T0GfP849b8eGB9vJvDNGB4/JlUQnEpR2vYO1aKtu/lRAz5Nqi8VM71O TLyi1QQvhbz1P0UiWLrQD22w/muQxemUPK7VODm3PsrYjYaVsBerJ8rLlUeBfY9EYs1esUuM kgshP7xvgneS/opyjz68PFUBtnjCOP0B0fuNUekmBFVs8mYKJRxLZvj399KosKHy7x9ekcYZ BTJfzbjcwmFG+yU2rUpS1GztCqQx0Ib227a3lHkMmU3z9KpWt+3ksVyecO901whK4Vet1q4f /JPb9vk6wLZsgKbbhlDONEesevDHfRKCi8f166EBDCLuUqKnjNo5n47PEc4/yrQoUByN8XlI 7aWF1VmGYucyvVeIOz9awO1iqIbHS2XDzrxM0bzYN+oKfASL3iNjDGYEwykuO7ys9vQfHzar KWAtZ7EvXjJWzhFcJixAvlQaRfLnEYT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SnTwt2G8sVxeGKL/a3FtQtskrqfCD2l9ThaLM/v7Vv0934 /VvijJqduZWgCbUiJbAVwI1RPyatW35rSMf4ukE9IuMEq2AEdyeHUwSOoHobY4f0cmvOYnmOyK 4P+xOu9PUhxmOX79TAdpWvKv9U+Bmirhnc9c5eDJZF2Lj6uv7XnzCF8uB6OhGqVTyqPWWu+c6z gyw=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 13/04/2021 16:46, Steven Rostedt wrote:
> Hi Giuseppe,
>
> On Tue, 13 Apr 2021 16:28:36 +0200
> Giuseppe Eletto <giuseppe.eletto@xxxxxxxxxxxx> wrote:
>
>> Hello,
>> I want to share with you a new plugin developed by me, under the
>> supervision of Dario Faggioli, which allows the new version of KernelShark
>> (the v2-beta) to open and view the Xen traces created using the "xentrace" 
>> tool.
>>
>> In fact, KernelShark is a well known tool for graphical visualization
>> Linux kernel traces, obtained via "ftrace" and "trace-cmd". Anyway thanks
>> to its modular architecture, it is now possible to implement plugins which
>> open and display traces with arbitrary format, for example, as in in
>> this case, traces of the Xen hypervisor.
> I'm guessing you have trace events coming from Xen itself?
>
>
>> For more information on how to build the plugin and/or
>> to view the source code I leave the repository below:
>> https://github.com/giuseppe998e/kernelshark-xentrace-plugin
>>
>>
>> In short:
>>
>> $ sudo apt install git build-essential libjson-c-dev
>> $ git clone --recurse-submodules
>> https://github.com/giuseppe998e/kernelshark-xentrace-plugin.git
>> $ cd kernelshark-xentrace-plugin/
>> $ make
>>
>> $ export XEN_CPUHZ=3G # Sets the CPU frequency ((G)hz/(M)hz/(K)hz/hz)
>> $ kernelshark -p out/ks-xentrace.so trace.xen
>>
>>
>> You will need the development version of KernelShark, available here:
>> https://git.kernel.org/pub/scm/utils/trace-cmd/kernel-shark.git
> This will soon be the main repository, as we are going to deprecate the
> version in the trace-cmd.git repo soon. And because libtracecmd 1.0 has
> already been released.
>
>
>> A screenshot of the plugin in action is available here:
>> https://github.com/giuseppe998e/kernelshark-xentrace-plugin/raw/master/.github/img/ks-xentrace.png
>>
>> I'm happy to receive whatever feedback you may have about it,
>> and to answer any question.
>>
> Thanks for doing this. What would be nice is to have the xen traces along
> side the linux tracing. Perhaps we can update trace-cmd agent to work with
> Xen as well. Does xen implement vsock or some other way to communicate
> between the guests and the Dom0 kernel? If not, we should add one. The you
> could do the following:
>
>  1. On each guest, run as root: trace-cmd agent --xen
>  2. On Dom0 run: trace-cmd record -e (events on Dom0) \
>      --xen (commands to do tracing in Xen HV) \
>      -A <guest-name1> -e (events on guest)
>
> And then you would get a trace.dat file for Dom0 and the guest, and also
> have a trace file for Xen (however that is done). And then on KernelShark,
> we have a KVM plugin in development that does this. But you can do the same
> with Xen.
>
> For KVM, we have:
>
>  1. On each guest: trace-cmd agent
>  2. On the host: trace-cmd record -e kvm -e sched -e irq \
>       -A guest-name -e all
>     The above produces trace.dat for the host trace, and 
>      trace-<guest-name>.dat for the guest.
>  3. kernelshark trace.dat -a trace-Fedora21.dat
>
> (I have a guest called Fedora21).
>
>   http://rostedt.org/private/kernelshark-kvm.png
>
> Where you can see the kvm hypervisor task KVM-2356 is the host task running
> the guest VCPU 0, and you see the switch between the two.
>
> Perhaps we can do something like that with Xen as well. The plugin is still
> in the works, but should be published soon. And when it is, you could use
> that as a template for Xen.

A possibly tangential question.  Where does KernelShark's idea of CPUs
(i.e. real logical threads) come from?

In a Xen system, dom0 is just a VM, and particularly on larger servers,
may not be as many vcpus as the system has logical threads.

This causes major problems for `perf` support under Xen, which assumes
that the kernel's idea of CPUs matches that of the system.

When rendering a trace including Xen data, Xen can provide the real
system CPUs, and dom0 wants to be rendered as a VM under Xen, similar to
trace-Fedora21 in your screenshot above.  (Obviously, if you're doing
nested virt, things need to start nesting.)

~Andrew




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.