Re: [Qemu-devel] [RFC PATCH] Convert ram_list to RCU DQ V4

2013-09-04 Thread Paolo Bonzini
Il 04/09/2013 22:48, Mike Day ha scritto: > > On Wed, Sep 4, 2013 at 3:58 PM, Paolo Bonzini > wrote: >> >> > @@ -1323,23 +1325,21 @@ static RAMBlock > *qemu_get_ram_block(ram_addr_t addr) >> > { >> > RAMBlock *block; >> > >> > -/* The list is protected by the

Re: [Qemu-devel] [RFC PATCH] Convert ram_list to RCU DQ V4

2013-09-04 Thread Mike Day
On Wed, Sep 4, 2013 at 3:58 PM, Paolo Bonzini wrote: > > > @@ -1323,23 +1325,21 @@ static RAMBlock *qemu_get_ram_block(ram_addr_t addr) > > { > > RAMBlock *block; > > > > -/* The list is protected by the iothread lock here. */ > > +/* This assumes the iothread lock is taken here too

Re: [Qemu-devel] [RFC PATCH] Convert ram_list to RCU DQ V4

2013-09-04 Thread Paolo Bonzini
Il 04/09/2013 21:41, Mike Day ha scritto: > * now passes virt-test -t qemu > * uses call_rcu instead of call_rcu1 > * completely removed the ram_list mutex and its locking functions > * cleaned up some comments > > Changes from V3: > > * added rcu reclaim function to free ram blocks > * reduced t

[Qemu-devel] [RFC PATCH] Convert ram_list to RCU DQ V4

2013-09-04 Thread Mike Day
* now passes virt-test -t qemu * uses call_rcu instead of call_rcu1 * completely removed the ram_list mutex and its locking functions * cleaned up some comments Changes from V3: * added rcu reclaim function to free ram blocks * reduced the number of comments * made rcu locking policy consistent f

Re: [Qemu-devel] [RFC PATCH] Convert ram_list to RCU DQ V2

2013-09-03 Thread Paolo Bonzini
Il 03/09/2013 16:19, Mike Day ha scritto: > > Yeah. So how about we say for now that the rcu critical section status > upon entry to the ram_control_*_iterate functions is undefined. I'll > make some updates. Sure. Paolo

Re: [Qemu-devel] [RFC PATCH] Convert ram_list to RCU DQ V2

2013-09-03 Thread Mike Day
On Tue, Sep 3, 2013 at 10:09 AM, Paolo Bonzini wrote: > > Il 03/09/2013 15:56, Mike Day ha scritto: > >> > +/* this implements a long-running RCU critical section. > >> > + * When rcu reclaims in the code start to become numerous > >> > + * it will be necessary to reduce the granularit

Re: [Qemu-devel] [RFC PATCH] Convert ram_list to RCU DQ V2

2013-09-03 Thread Paolo Bonzini
Il 03/09/2013 15:56, Mike Day ha scritto: >> > +/* this implements a long-running RCU critical section. >> > + * When rcu reclaims in the code start to become numerous >> > + * it will be necessary to reduce the granularity of this critical >> > + * section. >> > + */ >> >> Plea

Re: [Qemu-devel] [RFC PATCH] Convert ram_list to RCU DQ V2

2013-09-03 Thread Mike Day
On Fri, Aug 30, 2013 at 12:38 PM, Paolo Bonzini wrote: > > > @@ -867,7 +879,12 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) > > if (version_id < 4 || version_id > 4) { > > return -EINVAL; > > } > > - > > +/* this implements a long-running RCU critical se

Re: [Qemu-devel] [RFC PATCH] Convert ram_list to RCU DQ V2

2013-08-30 Thread Paolo Bonzini
Il 30/08/2013 18:06, Mike Day ha scritto: > Changes from V1: > > * Omitted locks or rcu critical sections within Some functions that > read or write the ram_list but are called in a protected context > (the caller holds the iothread lock, the ram_list mutex, or an rcu > critical section). >

[Qemu-devel] [RFC PATCH] Convert ram_list to RCU DQ V2

2013-08-30 Thread Mike Day
Changes from V1: * Omitted locks or rcu critical sections within Some functions that read or write the ram_list but are called in a protected context (the caller holds the iothread lock, the ram_list mutex, or an rcu critical section). Allow "unlocked" reads of the ram_list by using an RCU-

Re: [Qemu-devel] [RFC PATCH] convert ram_list to RCU DQ

2013-08-30 Thread Mike Day
On Fri, Aug 30, 2013 at 4:19 AM, Paolo Bonzini wrote: > > > I'm not sure about that; returning an RCU-protected variable after > rcu_read_unlock() seems wrong to me because the pointer may not be valid > at that point. I suggest using a comment that asks to call > host_from_stream_offset within r

Re: [Qemu-devel] [RFC PATCH] convert ram_list to RCU DQ

2013-08-30 Thread Paolo Bonzini
Il 29/08/2013 21:18, Mike Day ha scritto: > >> Similarly, here the critical section includes the caller, and block is >> living across calls to host. Again, for now just put all of ram_load >> under a huge RCU critical section. Later we can use ram_list.version to >> refresh the list and make th

Re: [Qemu-devel] [RFC PATCH] convert ram_list to RCU DQ

2013-08-29 Thread Mike Day
On Wed, Aug 28, 2013 at 12:35 PM, Paolo Bonzini wrote: > > > @@ -828,13 +829,18 @@ static inline void *host_from_stream_offset(QEMUFile *f, > > qemu_get_buffer(f, (uint8_t *)id, len); > > id[len] = 0; > > > > -QTAILQ_FOREACH(block, &ram_list.blocks, next) { > > -if (!strncmp(

Re: [Qemu-devel] [RFC PATCH] convert ram_list to RCU DQ

2013-08-28 Thread Paolo Bonzini
Il 28/08/2013 18:02, Mike Day ha scritto: > @@ -1102,15 +1110,15 @@ void qemu_ram_set_idstr(ram_addr_t addr, const char > *name, DeviceState *dev) > pstrcat(new_block->idstr, sizeof(new_block->idstr), name); > > /* This assumes the iothread lock is taken here too. */ > -qemu_mutex

Re: [Qemu-devel] [RFC PATCH] convert ram_list to RCU DQ

2013-08-28 Thread Paolo Bonzini
Il 28/08/2013 18:02, Mike Day ha scritto: > @@ -457,8 +459,9 @@ static int ram_save_block(QEMUFile *f, bool last_stage) > MemoryRegion *mr; > ram_addr_t current_addr; > > +rcu_read_lock(); > if (!block) > -block = QTAILQ_FIRST(&ram_list.blocks); > +block = QLIST

[Qemu-devel] [RFC PATCH] convert ram_list to RCU DQ

2013-08-28 Thread Mike Day
Allow "unlocked" reads of the ram_list by using an RCU-enabled DQ. Most readers of the list no longer require holding the list mutex. The ram_list now uses a QLIST instead of a QTAILQ. The difference is minimal. This patch has been built and make-checked for the x86_64, ppc64, s390x, and arm targ