From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdFFN-0007g5-Nj for qemu-devel@nongnu.org; Fri, 17 May 2013 03:38:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UdFCI-0002iB-Jb for qemu-devel@nongnu.org; Fri, 17 May 2013 03:35:31 -0400 Received: from mail-ye0-f172.google.com ([209.85.213.172]:63820) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UdFCI-0002i6-Ee for qemu-devel@nongnu.org; Fri, 17 May 2013 03:35:26 -0400 Received: by mail-ye0-f172.google.com with SMTP id m15so294524yen.3 for ; Fri, 17 May 2013 00:35:25 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <5195DDB3.3070903@redhat.com> Date: Fri, 17 May 2013 09:35:15 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1368632937-32272-1-git-send-email-pbonzini@redhat.com> <1368632937-32272-4-git-send-email-pbonzini@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 03/12] rcu: add rcu library List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: liu ping fan Cc: Jan Kiszka , qemu-devel@nongnu.org, David Gibson Il 17/05/2013 06:36, liu ping fan ha scritto: >> > + /* Mark the writer thread offline to make sure we don't wait for >> > + * our own quiescent state. This allows using synchronize_rcu() >> > + * in threads registered as readers. >> > + * >> > + * rcu_thread_offline() and rcu_thread_online() include a >> > + * memory barrier. >> > + */ >> > + if (was_online) { >> > + rcu_thread_offline(); > Encourage the user to call synchronize_rcu() in reader? Not in a read-side critical section, but in a *thread registered as reader*. And in QEMU, all threads actually are registered as readers. > I think the caller should ensure it is outside read-section. That would be possible by adding a small overhead to rcu_read_lock/unlock. > Also online can be > nested which make the situation even worse. It's not online that can be nested, only offline. So: - if the thread is already marked as offline, there will be no effect. - if the thread is not marked as offline, it will be. Paolo