From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] kvm: don't take vcpu mutex for obviously invalid vcpu ioctls Date: Mon, 22 Sep 2014 17:08:12 -0300 Message-ID: <20140922200812.GA9217@amt.cnet> References: <1411167805-2458-1-git-send-email-dmatlack@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Gleb Natapov , Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org To: David Matlack Return-path: Content-Disposition: inline In-Reply-To: <1411167805-2458-1-git-send-email-dmatlack@google.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Fri, Sep 19, 2014 at 04:03:25PM -0700, David Matlack wrote: > vcpu ioctls can hang the calling thread if issued while a vcpu is > running. There is a mutex per-vcpu, so thats expected, OK... > If we know ioctl is going to be rejected as invalid anyway, > we can fail before trying to take the vcpu mutex. Consider a valid ioctl that takes the vcpu mutex. If you need immediate access for that valid ioctl, it is necessary to interrupt thread which KVM_RUN ioctl executes. So knowledge of whether KVM_RUN is being executed is expected in userspace (either that or ask the KVM_RUN thread to run the ioctl for you, as qemu does). Can't see why having different behaviour for valid/invalid ioctls is a good thing. > This patch does not change functionality, it just makes invalid ioctls > fail faster. Should not be executing vcpu ioctls without interrupt KVM_RUN in the first place.