From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcuC2-00013p-V0 for qemu-devel@nongnu.org; Thu, 16 May 2013 05:09:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UcuBy-0003UB-0S for qemu-devel@nongnu.org; Thu, 16 May 2013 05:09:46 -0400 Received: from mail-we0-x233.google.com ([2a00:1450:400c:c03::233]:37163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcuBx-0003Tw-QD for qemu-devel@nongnu.org; Thu, 16 May 2013 05:09:41 -0400 Received: by mail-we0-f179.google.com with SMTP id t59so2438141wes.24 for ; Thu, 16 May 2013 02:09:41 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <5194A24D.6060901@redhat.com> Date: Thu, 16 May 2013 11:09:33 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1368415264-10800-1-git-send-email-qemulist@gmail.com> <1368415264-10800-3-git-send-email-qemulist@gmail.com> <5190B2FD.7090008@redhat.com> In-Reply-To: <5190B2FD.7090008@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH 2/2] mem: prepare address_space listener rcu style List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Stefan Hajnoczi , "Michael S. Tsirkin" , Jan Kiszka , qemu-devel@nongnu.org, Liu Ping Fan , Anthony Liguori Better: rcu_read_lock(); do { pgtbl = d->cur_pgtbl; smp_rmb(); root = d->cur_root; smp_rmb(); /* d->cur_pgtbl == d->next_pgtbl only during an update. */ } while (pgtbl == d->next_pgtbl); ... rcu_read_unlock(); And in the writer: old_pgtbl = d->cur_pgtbl; /* Point to the new page table, tell readers cur_root is invalid. */ smp_wmb(); d->cur_pgtbl = d->next_pgtbl; /* Write the root before updating the page table. */ smp_wmb(); d->cur_root = d->next_root; /* Write cur_root before telling readers it is valid. */ smp_wmb(); d->next_pgtbl = NULL; /* Drop reference once readers will be done with it. */ call_rcu(page_table_unref, old_pgtbl, rcu); Paolo