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