From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH 2/2] KVM: Convert read-only users of vm_list to RCU Date: Thu, 10 Feb 2011 15:55:57 +0100 Message-ID: <4D53FC7D.9090609@siemens.com> References: <4D512EF7.8040409@siemens.com> <4D512F3B.1080107@siemens.com> <4D53BB02.20206@redhat.com> <4D53CCAB.8040204@siemens.com> <4D53DB54.90605@redhat.com> <4D53DDD3.5020704@siemens.com> <4D53E063.1040004@redhat.com> <4D53E0A9.2030501@redhat.com> <4D53E4C0.5000605@siemens.com> <4D53E5FB.5090109@redhat.com> <4D53EC7B.3030903@siemens.com> <4D53F5A4.8050403@redhat.com> <4D53F770.6040908@siemens.com> <4D53FA97.4090007@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm , Zachary Amsden To: Avi Kivity Return-path: Received: from thoth.sbs.de ([192.35.17.2]:22163 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750917Ab1BJO4M (ORCPT ); Thu, 10 Feb 2011 09:56:12 -0500 In-Reply-To: <4D53FA97.4090007@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 2011-02-10 15:47, Avi Kivity wrote: > On 02/10/2011 04:34 PM, Jan Kiszka wrote: >> On 2011-02-10 15:26, Avi Kivity wrote: >>> On 02/10/2011 03:47 PM, Jan Kiszka wrote: >>>>>> >>>>>> Accept for mmu_shrink, which is write but not delete, thus works without >>>>>> that slow synchronize_rcu. >>>>> >>>>> I don't really see how you can implement list_move_rcu(), it has to be >>>>> atomic or other users will see a partial vm_list. >>>> >>>> Right, even if we synchronized that step cleanly, rcu-protected users >>>> could miss the moving vm during concurrent list walks. >>>> >>>> What about using a separate mutex for protecting vm_list instead? >>>> Unless I missed some detail, mmu_shrink should allow blocking. >>> >>> What else does kvm_lock protect? >> >> Someone tried to write a locking.txt and stated that it's also >> protecting enabling/disabling hardware virtualization. But that guy may >> have overlooked something. > > Right. I guess splitting that lock makes sense. > >>> >>> I think we could simply reduce the amount of time we hold kvm_lock. >>> Pick a vm, ref it, list_move_tail(), unlock, then do the actual >>> shrinking. Of course taking a ref must be done carefully, we might >>> already be in kvm_destroy_vm() at that time. >>> >> >> Plain mutex held across the whole mmu_shrink loop is still simpler and >> should be sufficient - unless we also have to deal with scalability >> issues if that handler is able to run concurrently. But based on how we >> were using kvm_lock so far... > > I don't think a mutex would work for kvmclock_cpufreq_notifier(). At > the very least, we'd need a preempt_disable() there. At the worst, the > notifier won't like sleeping. Damn, there was that other user. Yes, this means we need to break the lock in mmu_shrink. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux