Re: [Qemu-devel] [PATCH 03/18] qemu-thread: introduce QemuLockCnt

2015-09-28 Thread Paolo Bonzini
On 28/09/2015 12:15, Stefan Hajnoczi wrote: > On Thu, Aug 06, 2015 at 03:36:01PM +0200, Paolo Bonzini wrote: >> > +int qemu_lockcnt_count(QemuLockCnt *lockcnt); > Why use int here when the counter field is unsigned? Nice catch, will fix. Paolo

Re: [Qemu-devel] [PATCH 03/18] qemu-thread: introduce QemuLockCnt

2015-09-28 Thread Stefan Hajnoczi
On Thu, Aug 06, 2015 at 03:36:01PM +0200, Paolo Bonzini wrote: > +int qemu_lockcnt_count(QemuLockCnt *lockcnt); Why use int here when the counter field is unsigned?

Re: [Qemu-devel] [PATCH 03/18] qemu-thread: introduce QemuLockCnt

2015-09-09 Thread Fam Zheng
On Thu, 08/06 15:36, Paolo Bonzini wrote: > +QemuLockCnt usage > +- > + > +The typical pattern for QemuLockCnt functions is as follows. > + > +qemu_lockcnt_inc(_lockcnt); > +if (xyz) { > +... access xyz ... > +} > + > +if

Re: [Qemu-devel] [PATCH 03/18] qemu-thread: introduce QemuLockCnt

2015-09-09 Thread Paolo Bonzini
On 09/09/2015 10:49, Fam Zheng wrote: >> > +qemu_lockcnt_inc(_handlers_lockcnt); >> > +QLIST_FOREACH_RCU(ioh, _handlers, pioh) { >> > +if (ioh->revents & G_IO_OUT) { >> > +ioh->fd_write(ioh->opaque); >> > +} >> > +} > I'm confused, the comment of

[Qemu-devel] [PATCH 03/18] qemu-thread: introduce QemuLockCnt

2015-08-06 Thread Paolo Bonzini
A QemuLockCnt comprises a counter and a mutex, with primitives to increment and decrement the counter, and to take and release the mutex. It can be used to do lock-free visits to a data structure whenever mutexes would be too heavy-weight and the critical section is too long for RCU. This could