From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: Hypercall for sleeping for some amount of time? Date: Fri, 23 Jan 2015 10:53:00 +0100 Message-ID: <54C219FC.7050203@redhat.com> References: <1592884.UZW4Xi8OkR@k> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: Gleb Natapov To: Stefan Fritsch , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:59516 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753101AbbAWJxJ (ORCPT ); Fri, 23 Jan 2015 04:53:09 -0500 In-Reply-To: <1592884.UZW4Xi8OkR@k> Sender: kvm-owner@vger.kernel.org List-ID: 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