From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ingo Molnar Subject: Re: KVM PMU virtualization Date: Thu, 25 Feb 2010 17:26:31 +0100 Message-ID: <20100225162631.GA21920@elte.hu> References: <4B86917C.4070102@redhat.com> <4B869ACE.30808@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jes Sorensen , KVM General , Peter Zijlstra , Avi Kivity , Zachary Amsden , Gleb Natapov , ming.m.lin@intel.com, "Zhang, Yanmin" To: Jan Kiszka Return-path: Received: from mx2.mail.elte.hu ([157.181.151.9]:43748 "EHLO mx2.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932800Ab0BYQ0y (ORCPT ); Thu, 25 Feb 2010 11:26:54 -0500 Content-Disposition: inline In-Reply-To: <4B869ACE.30808@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: * Jan Kiszka wrote: > Jes Sorensen wrote: > > Hi, > > > > It looks like several of us have been looking at how to use the PMU > > for virtualization. Rather than continuing to have discussions in > > smaller groups, I think it is a good idea we move it to the mailing > > lists to see what we can share and avoid duplicate efforts. > > > > There are really two separate things to handle: > > > > 1) Add support to perf to allow it to monitor a KVM guest from the > > host. > > > > 2) Allow guests access to the PMU (or an emulated PMU), making it > > possible to run perf on applications running within the guest. > > > > I know some of you have been looking at 1) and I am currently working > > on 2). I have been looking at various approaches, including whether it > > is feasible to share the PMU between the host and multiple guests. For > > now I am going to focus on allowing one guest to take control of the > > PMU, then later hopefully adding support for multiplexing it between > > multiple guests. > > Given that perf can apply the PMU to individual host tasks, I don't see > fundamental problems multiplexing it between individual guests (which can > then internally multiplex it again). In terms of how to expose it to guests, a 'soft PMU' might be a usable approach. Although to Linux guests you could expose much more functionality and an non-PMU-limited number of instrumentation events, via a more intelligent interface. But note that in terms of handling it on the host side the PMU approach is not acceptable: instead it should map to proper perf_events, not try to muck with the PMU itself. That, besides integrating properly with perf usage on the host, will also allow interesting 'PMU' features on guests: you could set up the host side to trace block IO requests (or VM exits) for example, and expose that as 'PMC #0' on the guest side. That's a neat feature: the guest profiling tools would immediately (and transparently) be able to measure VM exits or IO heaviness, on a per guest basis, as seen on the host side. More would be possible too. Thanks, Ingo