From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF3OH-0008I9-OU for qemu-devel@nongnu.org; Mon, 11 Mar 2013 10:07:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UF3OA-0004mC-7B for qemu-devel@nongnu.org; Mon, 11 Mar 2013 10:07:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20574) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF3OA-0004lo-0Y for qemu-devel@nongnu.org; Mon, 11 Mar 2013 10:07:42 -0400 Message-ID: <513DE526.80108@redhat.com> Date: Mon, 11 Mar 2013 15:07:34 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1362976414-21396-1-git-send-email-mrhines@us.ibm.com> <1362976414-21396-10-git-send-email-mrhines@us.ibm.com> In-Reply-To: <1362976414-21396-10-git-send-email-mrhines@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH RDMA support v3: 09/10] Move RAMBlock to cpu-common.h List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael.R.Hines.mrhines@linux.vnet.ibm.com Cc: aliguori@us.ibm.com, mst@redhat.com, qemu-devel@nongnu.org, owasserm@redhat.com, abali@us.ibm.com, mrhines@us.ibm.com, gokul@us.ibm.com Il 11/03/2013 05:33, Michael.R.Hines.mrhines@linux.vnet.ibm.com ha scritto: > From: "Michael R. Hines" > > RDMA needs access to this structure by including cpu-common.h > (Including cpu-all.h causes things to throw up on me). > > Signed-off-by: Michael R. Hines > --- > include/exec/cpu-all.h | 27 --------------------------- > include/exec/cpu-common.h | 29 +++++++++++++++++++++++++++++ > 2 files changed, 29 insertions(+), 27 deletions(-) > > diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h > index 249e046..02a2808 100644 > --- a/include/exec/cpu-all.h > +++ b/include/exec/cpu-all.h > @@ -480,33 +480,6 @@ extern ram_addr_t ram_size; > /* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */ > #define RAM_PREALLOC_MASK (1 << 0) > > -typedef struct RAMBlock { > - struct MemoryRegion *mr; > - uint8_t *host; > - ram_addr_t offset; > - ram_addr_t length; > - uint32_t flags; > - char idstr[256]; > - /* Reads can take either the iothread or the ramlist lock. > - * Writes must take both locks. > - */ > - QTAILQ_ENTRY(RAMBlock) next; > -#if defined(__linux__) && !defined(TARGET_S390X) > - int fd; > -#endif > -} RAMBlock; > - > -typedef struct RAMList { > - QemuMutex mutex; > - /* Protected by the iothread lock. */ > - uint8_t *phys_dirty; > - RAMBlock *mru_block; > - /* Protected by the ramlist lock. */ > - QTAILQ_HEAD(, RAMBlock) blocks; > - uint32_t version; > -} RAMList; > -extern RAMList ram_list; > - > extern const char *mem_path; > extern int mem_prealloc; > > diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h > index 2e5f11f..763cef3 100644 > --- a/include/exec/cpu-common.h > +++ b/include/exec/cpu-common.h > @@ -11,6 +11,7 @@ > > #include "qemu/bswap.h" > #include "qemu/queue.h" > +#include "qemu/thread.h" > > /** > * CPUListState: > @@ -121,4 +122,32 @@ extern struct MemoryRegion io_mem_notdirty; > > #endif > > +typedef struct RAMBlock { > + struct MemoryRegion *mr; > + uint8_t *host; > + ram_addr_t offset; > + ram_addr_t length; > + uint32_t flags; > + char idstr[256]; > + /* Reads can take either the iothread or the ramlist lock. > + * Writes must take both locks. > + */ > + QTAILQ_ENTRY(RAMBlock) next; > +#if defined(__linux__) && !defined(TARGET_S390X) > + int fd; > +#endif > +} RAMBlock; > + > +typedef struct RAMList { > + QemuMutex mutex; > + /* Protected by the iothread lock. */ > + uint8_t *phys_dirty; > + RAMBlock *mru_block; > + /* Protected by the ramlist lock. */ > + QTAILQ_HEAD(, RAMBlock) blocks; > + uint32_t version; > +} RAMList; > + > +extern RAMList ram_list; > + > #endif /* !CPU_COMMON_H */ > Only used in qemu_rdma_init_ram_blocks. Can you add instead an API like qemu_ram_foreach_block( void (*fn)(void *host_addr, ram_addr_t offset, ram_addr_t length, void *opaque), void *opaque) ? BTW, please avoid arbitrary limits like RDMA_MAX_RAM_BLOCKS. Can you use a list (see qemu-queue.h; it is the same as the BSD queue.h) instead of current_index? Paolo