From mboxrd@z Thu Jan 1 00:00:00 1970 From: liu ping fan Subject: Re: [PATCH 04/15] memory: MemoryRegion topology must be stable when updating Date: Fri, 10 Aug 2012 14:44:09 +0800 Message-ID: References: <1344407156-25562-1-git-send-email-qemulist@gmail.com> <1344407156-25562-5-git-send-email-qemulist@gmail.com> <50222DB6.8020505@redhat.com> <502373D1.9050109@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Anthony Liguori , Jan Kiszka , Marcelo Tosatti , Stefan Hajnoczi , Paolo Bonzini , Blue Swirl , =?ISO-8859-1?Q?Andreas_F=E4rber?= To: Avi Kivity Return-path: Received: from mail-wg0-f44.google.com ([74.125.82.44]:57270 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754481Ab2HJGoa (ORCPT ); Fri, 10 Aug 2012 02:44:30 -0400 Received: by mail-wg0-f44.google.com with SMTP id dr13so1180098wgb.1 for ; Thu, 09 Aug 2012 23:44:30 -0700 (PDT) In-Reply-To: <502373D1.9050109@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Aug 9, 2012 at 4:24 PM, Avi Kivity wrote: > On 08/09/2012 10:28 AM, liu ping fan wrote: >>> >>> Seems to me that nothing in memory.c can susceptible to races. It must >>> already be called under the big qemu lock, and with the exception of >>> mutators (memory_region_set_*), changes aren't directly visible. >>> >> Yes, what I want to do is "prepare unplug out of protection of global >> lock". When io-dispatch and mmio-dispatch are all out of big lock, we >> will run into the following scene: >> In vcpu context A, qdev_unplug_complete()-> delete subregion; >> In context B, write pci bar --> pci mapping update -> add subregion > > Why do you want unlocked unplug? Unplug is rare and complicated; there > are no performance considerations on one hand, and difficulty of testing > for lock correctness on the other. I think it is better if it remains > protected by the global lock. > Oh, yes! I deviate quite far from the origin aim, and introduce some unnecessary complicate. >> >>> I think it's sufficient to take the mem_map_lock at the beginning of >>> core_begin() and drop it at the end of core_commit(). That means all >>> updates of volatile state, phys_map, are protected. >>> >> The mem_map_lock is to protect both address_space_io and >> address_space_memory. When without the protection of big lock, >> competing will raise among the updaters >> (memory_region_{add,del}_subregion and the readers >> generate_memory_topology()->render_memory_region(). > > These should all run under the big qemu lock, for the same reasons. > They are rare and not performance sensitive. Only phys_map reads are > performance sensitive. > OK, I see. Leave the big lock as it is, except for mmio, we will not worry about it. >> >> If just in core_begin/commit, we will duplicate it for >> xx_begin/commit, right? > > No. Other listeners will be protected by the global lock. > Yes, if leave the big lock as it is. >> And at the same time, mr->subregions is >> exposed under SMP without big lock. >> > > Who accesses it? > Again, I assume the updaters out of the protection of the big lock > IMO locking should look like: > > phys_map: mem_map_lock > dispatch callbacks: device specific lock (or big qemu lock for > unconverted devices) > everything else: big qemu lock > I See. Thank you for the review. And I will eliminate the unnecessary complicate and effort for the next version Regards, pingfan > > > -- > error compiling committee.c: too many arguments to function From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzixU-0005IA-55 for qemu-devel@nongnu.org; Fri, 10 Aug 2012 02:44:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzixS-00065Q-Q4 for qemu-devel@nongnu.org; Fri, 10 Aug 2012 02:44:32 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:37555) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzixS-00062t-JA for qemu-devel@nongnu.org; Fri, 10 Aug 2012 02:44:30 -0400 Received: by mail-wi0-f181.google.com with SMTP id hm2so787590wib.10 for ; Thu, 09 Aug 2012 23:44:30 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <502373D1.9050109@redhat.com> References: <1344407156-25562-1-git-send-email-qemulist@gmail.com> <1344407156-25562-5-git-send-email-qemulist@gmail.com> <50222DB6.8020505@redhat.com> <502373D1.9050109@redhat.com> From: liu ping fan Date: Fri, 10 Aug 2012 14:44:09 +0800 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Qemu-devel] [PATCH 04/15] memory: MemoryRegion topology must be stable when updating List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: kvm@vger.kernel.org, Jan Kiszka , Marcelo Tosatti , qemu-devel@nongnu.org, Blue Swirl , Anthony Liguori , Stefan Hajnoczi , Paolo Bonzini , =?ISO-8859-1?Q?Andreas_F=E4rber?= On Thu, Aug 9, 2012 at 4:24 PM, Avi Kivity wrote: > On 08/09/2012 10:28 AM, liu ping fan wrote: >>> >>> Seems to me that nothing in memory.c can susceptible to races. It must >>> already be called under the big qemu lock, and with the exception of >>> mutators (memory_region_set_*), changes aren't directly visible. >>> >> Yes, what I want to do is "prepare unplug out of protection of global >> lock". When io-dispatch and mmio-dispatch are all out of big lock, we >> will run into the following scene: >> In vcpu context A, qdev_unplug_complete()-> delete subregion; >> In context B, write pci bar --> pci mapping update -> add subregion > > Why do you want unlocked unplug? Unplug is rare and complicated; there > are no performance considerations on one hand, and difficulty of testing > for lock correctness on the other. I think it is better if it remains > protected by the global lock. > Oh, yes! I deviate quite far from the origin aim, and introduce some unnecessary complicate. >> >>> I think it's sufficient to take the mem_map_lock at the beginning of >>> core_begin() and drop it at the end of core_commit(). That means all >>> updates of volatile state, phys_map, are protected. >>> >> The mem_map_lock is to protect both address_space_io and >> address_space_memory. When without the protection of big lock, >> competing will raise among the updaters >> (memory_region_{add,del}_subregion and the readers >> generate_memory_topology()->render_memory_region(). > > These should all run under the big qemu lock, for the same reasons. > They are rare and not performance sensitive. Only phys_map reads are > performance sensitive. > OK, I see. Leave the big lock as it is, except for mmio, we will not worry about it. >> >> If just in core_begin/commit, we will duplicate it for >> xx_begin/commit, right? > > No. Other listeners will be protected by the global lock. > Yes, if leave the big lock as it is. >> And at the same time, mr->subregions is >> exposed under SMP without big lock. >> > > Who accesses it? > Again, I assume the updaters out of the protection of the big lock > IMO locking should look like: > > phys_map: mem_map_lock > dispatch callbacks: device specific lock (or big qemu lock for > unconverted devices) > everything else: big qemu lock > I See. Thank you for the review. And I will eliminate the unnecessary complicate and effort for the next version Regards, pingfan > > > -- > error compiling committee.c: too many arguments to function