From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=51391 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pxp7A-0008E9-Ow for qemu-devel@nongnu.org; Thu, 10 Mar 2011 18:17:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pxp79-0007UN-JE for qemu-devel@nongnu.org; Thu, 10 Mar 2011 18:17:52 -0500 Received: from e1.ny.us.ibm.com ([32.97.182.141]:33630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pxp79-0007Tu-Gf for qemu-devel@nongnu.org; Thu, 10 Mar 2011 18:17:51 -0500 Received: from d01dlp01.pok.ibm.com (d01dlp01.pok.ibm.com [9.56.224.56]) by e1.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p2AN7t2H032595 for ; Thu, 10 Mar 2011 18:07:55 -0500 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 92BEA38C8038 for ; Thu, 10 Mar 2011 18:17:45 -0500 (EST) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p2ANHlS5257046 for ; Thu, 10 Mar 2011 18:17:47 -0500 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p2ANHlGP032585 for ; Thu, 10 Mar 2011 20:17:47 -0300 Message-ID: <4D795C16.9090806@us.ibm.com> Date: Thu, 10 Mar 2011 17:17:42 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1299790066-768-1-git-send-email-vpalatin@chromium.org> In-Reply-To: <1299790066-768-1-git-send-email-vpalatin@chromium.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] Fix performance regression in qemu_get_ram_ptr List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vincent Palatin Cc: Chris Wright , Alex Williamson , Qemu devel On 03/10/2011 02:47 PM, Vincent Palatin wrote: > When the commit f471a17e9d869df3c6573f7ec02c4725676d6f3a converted the > ram_blocks structure to QLIST, it also removed the conditional check before > switching the current block at the beginning of the list. > > In the common use case where ram_blocks has a few blocks with only one > frequently accessed (the main RAM), this has a performance impact as it > performs the useless list operations on each call (which are on a really > hot path). > > On my machine emulation (ARM on amd64), this patch reduces the > percentage of CPU time spent in qemu_get_ram_ptr from 6.3% to 2.1% in the > profiling of a full boot. > > Signed-off-by: Vincent Palatin Applied. Thanks. Regards, Anthony Liguori > --- > exec.c | 7 +++++-- > 1 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/exec.c b/exec.c > index d611100..81f08b7 100644 > --- a/exec.c > +++ b/exec.c > @@ -2957,8 +2957,11 @@ void *qemu_get_ram_ptr(ram_addr_t addr) > > QLIST_FOREACH(block,&ram_list.blocks, next) { > if (addr - block->offset< block->length) { > - QLIST_REMOVE(block, next); > - QLIST_INSERT_HEAD(&ram_list.blocks, block, next); > + /* Move this entry to to start of the list. */ > + if (block != QLIST_FIRST(&ram_list.blocks)) { > + QLIST_REMOVE(block, next); > + QLIST_INSERT_HEAD(&ram_list.blocks, block, next); > + } > return block->host + (addr - block->offset); > } > }