From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=36720 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Od3Yu-00089c-9x for qemu-devel@nongnu.org; Sun, 25 Jul 2010 11:56:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Od3Yq-0007bD-RR for qemu-devel@nongnu.org; Sun, 25 Jul 2010 11:56:24 -0400 Received: from mail-bw0-f45.google.com ([209.85.214.45]:39754) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Od3Yq-0007aw-Mb for qemu-devel@nongnu.org; Sun, 25 Jul 2010 11:56:20 -0400 Received: by bwz19 with SMTP id 19so2154005bwz.4 for ; Sun, 25 Jul 2010 08:56:19 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4C4C5EA0.6080408@redhat.com> Date: Sun, 25 Jul 2010 17:56:16 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <438ED7C1-AD7C-4946-99D2-B0E9A91B8DF1@gmail.com> <6BBDD0C9-39D5-435C-8CD7-4E3DD8BAF57D@gmail.com> <4C472889.5000407@mail.berlios.de> <2FAAD29F-6C3E-4128-A6E1-46EE15AF80FA@gmail.com> <4C484105.5060607@siemens.com> <4C494A60.2040502@web.de> <1D54BA79-2AE5-40B3-813C-676529F1BA49@suse.de> In-Reply-To: Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: Release of COREMU, a scalable and portable full-system emulator List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Jan Kiszka , Chen Yufei , wang Tiger , Alexander Graf , qemu-devel@nongnu.org On 07/23/2010 01:02 PM, Stefan Hajnoczi wrote: >> In fact, we solve this problem through a really simple method. >> In our prototype, we removed this piece of code like this: >> void *qemu_get_ram_ptr(ram_addr_t addr) >> { >> ...... >> >> /* Move this entry to to start of the list. */ >> #ifndef CONFIG_COREMU >> /* Different core can access this function at the same time. >> * For coremu, disable this optimization to avoid data race. >> * XXX or use spin lock here if performance impact is big. */ >> if (prev) { >> prev->next = block->next; >> block->next = *prevp; >> *prevp = block; >> } >> #endif >> return block->host + (addr - block->offset); >> } >> >> CONFIG_COREMU is defined when TCG parallel mode is configured. >> And the list is more likely to be read only without hotplug device, so >> we don't use a lock to protect it. >> Reimplement this list with a lock free list is also reasonable, but >> seems unnecessary. :-) > > Ah, good :). For this one in particular, you could just use circular lists (without a "head" node, unlike the Linux kernel's list data type, as there's always a RAM entry) and start iteration at "prev". Paolo