|
From: | Paolo Bonzini |
Subject: | Re: [Qemu-devel] [PATCH v2 1/2] Introduce QLIST_INSERT_HEAD_RCU and dummy RCU wrappers. |
Date: | Fri, 14 Oct 2011 08:49:49 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:7.0) Gecko/20110927 Thunderbird/7.0 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |