From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aY3yp-0001Dy-Pc for qemu-devel@nongnu.org; Mon, 22 Feb 2016 22:49:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aY3yl-0003qy-Mu for qemu-devel@nongnu.org; Mon, 22 Feb 2016 22:49:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42621) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aY3yl-0003qm-I0 for qemu-devel@nongnu.org; Mon, 22 Feb 2016 22:49:39 -0500 Date: Tue, 23 Feb 2016 11:49:35 +0800 From: Fam Zheng Message-ID: <20160223034935.GE26360@ad.usersys.redhat.com> References: <1456130097-4208-1-git-send-email-arei.gonglei@huawei.com> <56CAE16C.3060800@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56CAE16C.3060800@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 0/3] memory: an optimization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Gonglei , qemu-devel@nongnu.org, peter.huangpeng@huawei.com On Mon, 02/22 11:22, Paolo Bonzini wrote: > > > On 22/02/2016 09:34, Gonglei wrote: > > Perf top tells me qemu_get_ram_ptr consume some cpu cycles. > > > > Before this optimization: > > 1.26% qemu-kvm [.] qemu_get_ram_ptr > > 0.89% qemu-kvm [.] qemu_get_ram_block > > > > Applied the patch set: > > 0.87% qemu-kvm [.] qemu_get_ram_ptr > > > > And Paolo suggested that we can get rid of qemu_get_ram_ptr > > by storing the RAMBlock pointer into the memory region, > > instead of the ram_addr_t value. And after appling this change, > > I got much better performance indeed. > > > > BTW, PATCH 3 is an occasional find. > > > > v2: > > - using 'struct RAMBlock *' instead of 'void *' in patch 1 [Fam] > > - drop superfluous comments in patch 1 [Fam] > > > > Gonglei (3): > > exec: store RAMBlock pointer into memory region > > memory: optimize qemu_get_ram_ptr and qemu_ram_ptr_length > > memory: Remove the superfluous code > > > > exec.c | 48 ++++++++++++++++++++++++++++++------------------ > > include/exec/memory.h | 8 ++++---- > > memory.c | 3 ++- > > 3 files changed, 36 insertions(+), 23 deletions(-) > > > > Thanks Lei and Fam, patches queued. Thanks! Actually I'd like to clean this up a bit more: moving assigning to mr->ram_block from exec.c to memory.c, and drop mr->ram_addr. I've already done these on top of master last Friday before v1 of this was posted (oops! :), but I can rebase on top of these patches. And upon that, I think we can replicate the ram_list.mru_block trick as AddressSpaceDispatch.mru_section, to further reduce the calls to qemu_get_ram_ptr. Paolo, is there a git branch I can base off? Fam