From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:49830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RcelG-0004xy-55 for qemu-devel@nongnu.org; Mon, 19 Dec 2011 10:04:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rcel9-0003Si-Nf for qemu-devel@nongnu.org; Mon, 19 Dec 2011 10:04:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4765) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rcel9-0003SZ-Gn for qemu-devel@nongnu.org; Mon, 19 Dec 2011 10:04:11 -0500 Message-ID: <4EEF5263.8070004@redhat.com> Date: Mon, 19 Dec 2011 17:04:03 +0200 From: Avi Kivity MIME-Version: 1.0 References: <1324304024-11220-1-git-send-email-avi@redhat.com> <1324304024-11220-2-git-send-email-avi@redhat.com> <4EEF4F1E.9080104@codemonkey.ws> In-Reply-To: <4EEF4F1E.9080104@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 01/23] memory: introduce memory_region_find() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: xen-devel@lists.xensource.com, "Michael S. Tsirkin" , qemu-devel@nongnu.org, kvm@vger.kernel.org, Stefano Stabellini On 12/19/2011 04:50 PM, Anthony Liguori wrote: >> +static int cmp_flatrange_addr(const void *_addr, const void *_fr) >> +{ >> + const AddrRange *addr = _addr; >> + const FlatRange *fr = _fr; > > > Please don't prefix with an underscore. Why not? It's legal according to the standards, if that's your concern (only _[_A-Z]+ are reserved). >> @@ -502,6 +520,20 @@ void memory_region_del_subregion(MemoryRegion *mr, >> MemoryRegion *subregion); >> >> /** >> + * memory_region_find: locate a MemoryRegion in an address space >> + * >> + * Locates the first #MemoryRegion within an address space given by >> + * @address_space that overlaps the range given by @addr and @size. >> + * >> + * @address_space: a top-level (i.e. parentless) region that contains >> + * the region to be found >> + * @addr: start of the area within @address_space to be searched >> + * @size: size of the area to be searched >> + */ >> +MemoryRegionSection memory_region_find(MemoryRegion *address_space, >> + target_phys_addr_t addr, >> uint64_t size); > > > Returning structs by value is a bit unexpected. It's just prejudice, here's the call sequence: 127a63: 48 89 c6 mov %rax,%rsi 127a66: 48 8d 45 b0 lea -0x50(%rbp),%rax 127a6a: b9 01 00 00 00 mov $0x1,%ecx 127a6f: 48 89 da mov %rbx,%rdx 127a72: 48 89 c7 mov %rax,%rdi 127a75: e8 89 46 15 00 callq 27c103 The return value is passed via %rax, so no performance penalty. On the other hand, it's clear that it is a return value, unlike a pointer parameter. -- error compiling committee.c: too many arguments to function