All of lore.kernel.org
 help / color / mirror / Atom feed
* Hypercall for sleeping for some amount of time?
@ 2015-01-23  9:40 Stefan Fritsch
  2015-01-23  9:53 ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Fritsch @ 2015-01-23  9:40 UTC (permalink / raw)
  To: kvm; +Cc: Gleb Natapov, Paolo Bonzini

Hi,

there are situations where a guest needs to wait, but has interrupts 
disabled.  Usually this is done by polling in a tight loop, which is a 
waste of CPU cycles on a virtualized system. Therefore I propose to 
add a hypercall to KVM that allows the guest to yield the CPU for a 
specified amount of time.

One significant use case is the guest sitting in a kernel debugger and 
polling for user input. But I expect that there are other situations 
where such a hypercall could be useful, for example during hardware 
detection at startup.

What do you think about this idea?

What would be the preferred interface for such a hypercall? Using 
vmcall like KVM_HC_*, or MSR write, or even a simple IO port write? Is 
there a way to make this architecture independent?

For detection, at least a new bit in KVM_CPUID_FEATURES would be 
necessary.  Does one also need more information, like the minimum 
supported delay and the expected granularity of the delay? Also, 
should the call be simply "best effort" or should it guarantee that it 
sleeps for at least the requested time? I think keeping it simple at 
first would be best.

Cheers,
Stefan


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

* Re: Hypercall for sleeping for some amount of time?
  2015-01-23  9:40 Hypercall for sleeping for some amount of time? Stefan Fritsch
@ 2015-01-23  9:53 ` Paolo Bonzini
  2015-01-23 11:18   ` Stefan Fritsch
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2015-01-23  9:53 UTC (permalink / raw)
  To: Stefan Fritsch, kvm; +Cc: Gleb Natapov



On 23/01/2015 10:40, Stefan Fritsch wrote:
> Hi,
> 
> there are situations where a guest needs to wait, but has interrupts 
> disabled.  Usually this is done by polling in a tight loop, which is a 
> waste of CPU cycles on a virtualized system. Therefore I propose to 
> add a hypercall to KVM that allows the guest to yield the CPU for a 
> specified amount of time.
> 
> One significant use case is the guest sitting in a kernel debugger and 
> polling for user input. But I expect that there are other situations 
> where such a hypercall could be useful, for example during hardware 
> detection at startup.
> 
> What do you think about this idea?
> 
> What would be the preferred interface for such a hypercall? Using 
> vmcall like KVM_HC_*, or MSR write, or even a simple IO port write? Is 
> there a way to make this architecture independent?
> 
> For detection, at least a new bit in KVM_CPUID_FEATURES would be 
> necessary.  Does one also need more information, like the minimum 
> supported delay and the expected granularity of the delay? Also, 
> should the call be simply "best effort" or should it guarantee that it 
> sleeps for at least the requested time? I think keeping it simple at 
> first would be best.

I think a platform device similar to drivers/platform/x86/pvpanic.c
would be best.  That would be a simple IO port write (milliseconds?),
with the port described in ACPI.

Paolo

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

* Re: Hypercall for sleeping for some amount of time?
  2015-01-23  9:53 ` Paolo Bonzini
@ 2015-01-23 11:18   ` Stefan Fritsch
  2015-01-23 11:58     ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Fritsch @ 2015-01-23 11:18 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Gleb Natapov

On Friday 23 January 2015 10:53:00, Paolo Bonzini wrote:
> On 23/01/2015 10:40, Stefan Fritsch wrote:
> > Hi,
> > 
> > there are situations where a guest needs to wait, but has
> > interrupts disabled.  Usually this is done by polling in a tight
> > loop, which is a waste of CPU cycles on a virtualized system.
> > Therefore I propose to add a hypercall to KVM that allows the
> > guest to yield the CPU for a specified amount of time.
> > 
> > One significant use case is the guest sitting in a kernel debugger
> > and polling for user input. But I expect that there are other
> > situations where such a hypercall could be useful, for example
> > during hardware detection at startup.
> > 
> > What do you think about this idea?
> > 
> > What would be the preferred interface for such a hypercall? Using
> > vmcall like KVM_HC_*, or MSR write, or even a simple IO port
> > write? Is there a way to make this architecture independent?
> > 
> > For detection, at least a new bit in KVM_CPUID_FEATURES would be
> > necessary.  Does one also need more information, like the minimum
> > supported delay and the expected granularity of the delay? Also,
> > should the call be simply "best effort" or should it guarantee
> > that it sleeps for at least the requested time? I think keeping
> > it simple at first would be best.
> 
> I think a platform device similar to drivers/platform/x86/pvpanic.c
> would be best.  That would be a simple IO port write
> (milliseconds?), with the port described in ACPI.

Wasn't there some issue that Windows guests would then ask for a 
driver? AIUI, pvpanic has been disabled by default for this reason. 
Also, it would be nice if simplistic bootloaders without ACPI support 
would also be able to use the feature.

Cheers,
Stefan

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

* Re: Hypercall for sleeping for some amount of time?
  2015-01-23 11:18   ` Stefan Fritsch
@ 2015-01-23 11:58     ` Paolo Bonzini
  2015-01-23 20:36       ` Stefan Fritsch
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2015-01-23 11:58 UTC (permalink / raw)
  To: Stefan Fritsch; +Cc: kvm, Gleb Natapov



On 23/01/2015 12:18, Stefan Fritsch wrote:
> Wasn't there some issue that Windows guests would then ask for a 
> driver? AIUI, pvpanic has been disabled by default for this reason. 
> Also, it would be nice if simplistic bootloaders without ACPI support 
> would also be able to use the feature.

That was only XP and perhaps 2003.  I think this is a very specialized
usecase.  In most cases you can use hlt.

Paolo

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

* Re: Hypercall for sleeping for some amount of time?
  2015-01-23 11:58     ` Paolo Bonzini
@ 2015-01-23 20:36       ` Stefan Fritsch
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Fritsch @ 2015-01-23 20:36 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm

On Friday 23 January 2015 12:58:20, Paolo Bonzini wrote:
> On 23/01/2015 12:18, Stefan Fritsch wrote:
> > Wasn't there some issue that Windows guests would then ask for a
> > driver? AIUI, pvpanic has been disabled by default for this
> > reason.
> > Also, it would be nice if simplistic bootloaders without ACPI
> > support would also be able to use the feature.
> 
> That was only XP and perhaps 2003.  I think this is a very
> specialized usecase.  In most cases you can use hlt.

OK, I will give it a try.

Stefan


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

end of thread, other threads:[~2015-01-23 20:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-23  9:40 Hypercall for sleeping for some amount of time? Stefan Fritsch
2015-01-23  9:53 ` Paolo Bonzini
2015-01-23 11:18   ` Stefan Fritsch
2015-01-23 11:58     ` Paolo Bonzini
2015-01-23 20:36       ` Stefan Fritsch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.