From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZbT8-0001Q2-A6 for qemu-devel@nongnu.org; Wed, 09 Sep 2015 05:15:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZbT7-0001Z4-Ij for qemu-devel@nongnu.org; Wed, 09 Sep 2015 05:15:06 -0400 References: <1438868176-20364-1-git-send-email-pbonzini@redhat.com> <1438868176-20364-4-git-send-email-pbonzini@redhat.com> <20150909084947.GD21413@ad.nay.redhat.com> From: Paolo Bonzini Message-ID: <55EFF88E.4000301@redhat.com> Date: Wed, 9 Sep 2015 11:14:54 +0200 MIME-Version: 1.0 In-Reply-To: <20150909084947.GD21413@ad.nay.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 03/18] qemu-thread: introduce QemuLockCnt List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: kwolf@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, stefanha@redhat.com 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