public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [Proposal] QEMU-KVM Interface for granting Performance Monitor to guests
@ 2011-04-12  7:29 Bhushan Bharat-R65777
  2011-04-12 14:39 ` Avi Kivity
  0 siblings, 1 reply; 5+ messages in thread
From: Bhushan Bharat-R65777 @ 2011-04-12  7:29 UTC (permalink / raw)
  To: kvm@vger.kernel.org; +Cc: bharatb.yadav@gmail.com

Hi All,

The proposal is to about defining the qemu-kvm interface for reserving the performance monitor for guest(guests) in Embedded Power Architecture. The plan is to reserve the Performance Monitor for guest/s on guest boot-up and will be released only on guest reset/exit. If a Performance Monitor reserved by host then it can't be reserved for guest and vice-versa. So when Performance monitor is reserved by host then performance monitor can't be used by guests and if reserved by guest then it should not be used by host.

Note: This proposal is not about partitioning the performance monitor counters between host and guest. This requires substantial work in existing performance monitor code in Linux so may be planned as future work.

	 1) Add a qemu command line parameter (example --reserve-perfmon)

       2)    If the above command line parameter is present then QEMU will make a IOCTL call to reserve PM for guest.
            Define a new IOCTL (KVM_RESERVE_PERFMON).

       3)   KVM will reserve the PerfMon.
       	There is nothing like per core reservation on powerpc platform and also I feel that it does not make much sense.
       	int reserve_pmc_hardware(perf_irq_t new_perf_irq)
       	This reservation just attach new interrupt handler passed in this call. So Passing NULL or empty function will work because the interrupt is not going to be taken by host in any case. This will just allow host perfmon reservation to fail, so that host should not use it.

       	To support multiple guest, KVM will reserve Performance Monitor only once and keep a reference count. On subsequent reserve it will increment reference count.

       	On Successful reservation on performance monitor: Emulate the Performance monitor registers and interrupts to guest and return SUCCESS.
       	If Performance monitor reservation Fails: Write to Performance registers are ignored and reads are boundedly undefined.

       4)    On SUCCESS: QEMU will add "power-isa-e.pm" property in all cpus node of guest device tree
       On Failure : Nothing.

	 5)    On Guest Exit: Decrement the reference count and release reservation when reference count is ZERO (no more guest using PerfMon).


Kernel/Guest:
       Ideally the kernel should try to reserve performance monitor only if "power-isa-e.pm" property is present in device tree. Arch/powerpc/kernel/pmc.c - reserve_pm_hardware() should fail if this property does not exists. But addition of this property will require the change in all existing device trees.
       
       To solve this problem we can change u-boot to always add this property in cpus node, so the Performance Monitor is always available to host kernel (if not reserved by guest). While QEMU will patch guest device tree as explained above to allow guest to use it.

Thanks
-Bharat


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Proposal] QEMU-KVM Interface for granting Performance Monitor to guests
  2011-04-12  7:29 [Proposal] QEMU-KVM Interface for granting Performance Monitor to guests Bhushan Bharat-R65777
@ 2011-04-12 14:39 ` Avi Kivity
  2011-04-12 16:05   ` Bhushan Bharat-R65777
  0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2011-04-12 14:39 UTC (permalink / raw)
  To: Bhushan Bharat-R65777; +Cc: kvm@vger.kernel.org, bharatb.yadav@gmail.com

On 04/12/2011 10:29 AM, Bhushan Bharat-R65777 wrote:
> Hi All,
>
> The proposal is to about defining the qemu-kvm interface for reserving the performance monitor for guest(guests) in Embedded Power Architecture. The plan is to reserve the Performance Monitor for guest/s on guest boot-up and will be released only on guest reset/exit. If a Performance Monitor reserved by host then it can't be reserved for guest and vice-versa. So when Performance monitor is reserved by host then performance monitor can't be used by guests and if reserved by guest then it should not be used by host.

In general we greatly prefer sharing vs. reservation (there are 
exceptions, for example PCI device assignment).

Is there a compelling reason to assign the performance monitor to a 
single guest?

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [Proposal] QEMU-KVM Interface for granting Performance Monitor to guests
  2011-04-12 14:39 ` Avi Kivity
@ 2011-04-12 16:05   ` Bhushan Bharat-R65777
  2011-04-12 16:45     ` Scott Wood
  0 siblings, 1 reply; 5+ messages in thread
From: Bhushan Bharat-R65777 @ 2011-04-12 16:05 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm@vger.kernel.org, bharatb.yadav@gmail.com



> -----Original Message-----
> From: Avi Kivity [mailto:avi@redhat.com]
> Sent: Tuesday, April 12, 2011 8:09 PM
> To: Bhushan Bharat-R65777
> Cc: kvm@vger.kernel.org; bharatb.yadav@gmail.com
> Subject: Re: [Proposal] QEMU-KVM Interface for granting Performance
> Monitor to guests
> 
> On 04/12/2011 10:29 AM, Bhushan Bharat-R65777 wrote:
> > Hi All,
> >
> > The proposal is to about defining the qemu-kvm interface for reserving
> the performance monitor for guest(guests) in Embedded Power Architecture.
> The plan is to reserve the Performance Monitor for guest/s on guest boot-
> up and will be released only on guest reset/exit. If a Performance
> Monitor reserved by host then it can't be reserved for guest and vice-
> versa. So when Performance monitor is reserved by host then performance
> monitor can't be used by guests and if reserved by guest then it should
> not be used by host.
> 
> In general we greatly prefer sharing vs. reservation (there are
> exceptions, for example PCI device assignment).
> 
> Is there a compelling reason to assign the performance monitor to a
> single guest?

No, Guest can share with other guests but not with host.

Thanks
-Bharat



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Proposal] QEMU-KVM Interface for granting Performance Monitor to guests
  2011-04-12 16:05   ` Bhushan Bharat-R65777
@ 2011-04-12 16:45     ` Scott Wood
  2011-04-12 16:47       ` Avi Kivity
  0 siblings, 1 reply; 5+ messages in thread
From: Scott Wood @ 2011-04-12 16:45 UTC (permalink / raw)
  To: Bhushan Bharat-R65777
  Cc: Avi Kivity, kvm@vger.kernel.org, bharatb.yadav@gmail.com

On Tue, 12 Apr 2011 16:05:29 +0000
Bhushan Bharat-R65777 <R65777@freescale.com> wrote:

> 
> 
> > -----Original Message-----
> > From: Avi Kivity [mailto:avi@redhat.com]
> > Sent: Tuesday, April 12, 2011 8:09 PM
> > To: Bhushan Bharat-R65777
> > Cc: kvm@vger.kernel.org; bharatb.yadav@gmail.com
> > Subject: Re: [Proposal] QEMU-KVM Interface for granting Performance
> > Monitor to guests
> > 
> > On 04/12/2011 10:29 AM, Bhushan Bharat-R65777 wrote:
> > > Hi All,
> > >
> > > The proposal is to about defining the qemu-kvm interface for reserving
> > the performance monitor for guest(guests) in Embedded Power Architecture.
> > The plan is to reserve the Performance Monitor for guest/s on guest boot-
> > up and will be released only on guest reset/exit. If a Performance
> > Monitor reserved by host then it can't be reserved for guest and vice-
> > versa. So when Performance monitor is reserved by host then performance
> > monitor can't be used by guests and if reserved by guest then it should
> > not be used by host.
> > 
> > In general we greatly prefer sharing vs. reservation (there are
> > exceptions, for example PCI device assignment).
> > 
> > Is there a compelling reason to assign the performance monitor to a
> > single guest?
> 
> No, Guest can share with other guests but not with host.

Note that the reservation system is already in use in the host kernel,
between perf event and oprofile (and I think between users of oprofile).

Maybe something could be done with KVM acting as a perf event client.

-Scott


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Proposal] QEMU-KVM Interface for granting Performance Monitor to guests
  2011-04-12 16:45     ` Scott Wood
@ 2011-04-12 16:47       ` Avi Kivity
  0 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2011-04-12 16:47 UTC (permalink / raw)
  To: Scott Wood
  Cc: Bhushan Bharat-R65777, kvm@vger.kernel.org,
	bharatb.yadav@gmail.com

On 04/12/2011 07:45 PM, Scott Wood wrote:
> On Tue, 12 Apr 2011 16:05:29 +0000
> Bhushan Bharat-R65777<R65777@freescale.com>  wrote:
>
> >
> >
> >  >  -----Original Message-----
> >  >  From: Avi Kivity [mailto:avi@redhat.com]
> >  >  Sent: Tuesday, April 12, 2011 8:09 PM
> >  >  To: Bhushan Bharat-R65777
> >  >  Cc: kvm@vger.kernel.org; bharatb.yadav@gmail.com
> >  >  Subject: Re: [Proposal] QEMU-KVM Interface for granting Performance
> >  >  Monitor to guests
> >  >
> >  >  On 04/12/2011 10:29 AM, Bhushan Bharat-R65777 wrote:
> >  >  >  Hi All,
> >  >  >
> >  >  >  The proposal is to about defining the qemu-kvm interface for reserving
> >  >  the performance monitor for guest(guests) in Embedded Power Architecture.
> >  >  The plan is to reserve the Performance Monitor for guest/s on guest boot-
> >  >  up and will be released only on guest reset/exit. If a Performance
> >  >  Monitor reserved by host then it can't be reserved for guest and vice-
> >  >  versa. So when Performance monitor is reserved by host then performance
> >  >  monitor can't be used by guests and if reserved by guest then it should
> >  >  not be used by host.
> >  >
> >  >  In general we greatly prefer sharing vs. reservation (there are
> >  >  exceptions, for example PCI device assignment).
> >  >
> >  >  Is there a compelling reason to assign the performance monitor to a
> >  >  single guest?
> >
> >  No, Guest can share with other guests but not with host.
>
> Note that the reservation system is already in use in the host kernel,
> between perf event and oprofile (and I think between users of oprofile).
>
> Maybe something could be done with KVM acting as a perf event client.
>

That is the plan for x86 - using perf events to provide a virtual PMU to 
the guest.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-04-12 16:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-12  7:29 [Proposal] QEMU-KVM Interface for granting Performance Monitor to guests Bhushan Bharat-R65777
2011-04-12 14:39 ` Avi Kivity
2011-04-12 16:05   ` Bhushan Bharat-R65777
2011-04-12 16:45     ` Scott Wood
2011-04-12 16:47       ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox