From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:33574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REbaf-0003w5-D4 for qemu-devel@nongnu.org; Fri, 14 Oct 2011 02:49:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1REbad-0004Mc-Ki for qemu-devel@nongnu.org; Fri, 14 Oct 2011 02:49:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14552) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REbad-0004MP-Cg for qemu-devel@nongnu.org; Fri, 14 Oct 2011 02:49:55 -0400 Message-ID: <4E97DB8D.4070403@redhat.com> Date: Fri, 14 Oct 2011 08:49:49 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1318538102-6982-1-git-send-email-harsh@linux.vnet.ibm.com> In-Reply-To: <1318538102-6982-1-git-send-email-harsh@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 1/2] Introduce QLIST_INSERT_HEAD_RCU and dummy RCU wrappers. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Harsh Prateek Bora Cc: jan.kiszka@web.de, qemu-devel@nongnu.org, aneesh.kumar@linux.vnet.ibm.com On 10/13/2011 10:35 PM, Harsh Prateek Bora wrote: > > +#define QLIST_INSERT_HEAD_RCU(head, elm, field) do { \ > + (elm)->field.le_prev =&(head)->lh_first; \ > + smp_wmb(); \ > + if (((elm)->field.le_next = (head)->lh_first) != NULL) \ > + (head)->lh_first->field.le_prev =&(elm)->field.le_next;\ > + smp_wmb(); \ > + (head)->lh_first = (elm); \ > + smp_wmb(); \ > +} while (/* CONSTCOND*/0) Actually, looking more at it it should be more like (elm)->field.le_prev =&(head)->lh_first; (elm)->field.le_next = (head)->lh_first; smb_wmb(); /* fill elm before linking it */ if ((head)->lh_first != NULL) (head)->lh_first->field.le_prev =&(elm)->field.le_next; (head)->lh_first = (elm); smp_wmb(); ... which even saves a memory barrier. Paolo