[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [Qemu-devel] [PATCH 03/18] qemu-thread: introduce QemuL
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-block] [Qemu-devel] [PATCH 03/18] qemu-thread: introduce QemuLockCnt |
Date: |
Wed, 9 Sep 2015 11:14:54 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 |
On 09/09/2015 10:49, Fam Zheng wrote:
>> > + qemu_lockcnt_inc(&io_handlers_lockcnt);
>> > + QLIST_FOREACH_RCU(ioh, &io_handlers, pioh) {
>> > + if (ioh->revents & G_IO_OUT) {
>> > + ioh->fd_write(ioh->opaque);
>> > + }
>> > + }
> I'm confused, the comment of QLIST_FOREACH_RCU says "list traversal
> must occur within an RCU critical section.", but there is not rcu_read_lock
> here. Why?
Right, the comment should be updated.
RCU can be seen as a "global reference count" that prevents freeing an
object between rcu_read_lock and rcu_read_unlock. Here the reference
count is provided by the LockCnt.
The difference between QLIST_FOREACH and QLIST_FOREACH_RCU is just that
the latter has an extra smp_read_barrier_depends. The barrier is needed
for all lockless visits. I think QLIST_FOREACH_RCU is more expressive
than QLIST_FOREACH_LOCKLESS or something like that.
Paolo