From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [RFC] KVM: x86: conditionally acquire/release slots_lock on entry/exit Date: Thu, 27 Aug 2009 19:27:48 +0300 Message-ID: <4A96B404.5010500@redhat.com> References: <20090827012000.762063112@localhost.localdomain> <20090827155450.GA6312@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, Gleb Natapov To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:8054 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752938AbZH0Q1X (ORCPT ); Thu, 27 Aug 2009 12:27:23 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7RGRPo7008925 for ; Thu, 27 Aug 2009 12:27:25 -0400 In-Reply-To: <20090827155450.GA6312@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On 08/27/2009 06:54 PM, Marcelo Tosatti wrote: > perf report shows heavy overhead from down/up of slots_lock. > > Attempted to remove slots_lock by having vcpus stop on a synchronization > point, but this introduced further complexity (a vcpu can be scheduled > out before reaching the synchronization point, and can sched back in at > points which are slots_lock protected, etc). > > This patch changes vcpu_enter_guest to conditionally release/acquire > slots_lock in case a vcpu state bit is set. > > vmexit performance improves by 5-10% on UP guest. > Sorry, it looks pretty complex. Have you considered using srcu? It seems to me down/up_read() can be replaced by srcu_read_lock/unlock(), and after proper conversion of memslots and io_bus to rcu_assign_pointer(), we can just add synchronize_srcu() immediately after changing stuff (of course mmu_lock still needs to be held when updating slots). -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.