qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
Cc: jan.kiszka@web.de, qemu-devel@nongnu.org,
	aneesh.kumar@linux.vnet.ibm.com
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	[thread overview]
Message-ID: <4E97DB8D.4070403@redhat.com> (raw)
In-Reply-To: <1318538102-6982-1-git-send-email-harsh@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

      parent reply	other threads:[~2011-10-14  6:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-13 20:35 [Qemu-devel] [PATCH v2 1/2] Introduce QLIST_INSERT_HEAD_RCU and dummy RCU wrappers Harsh Prateek Bora
2011-10-13 20:35 ` [Qemu-devel] [PATCH v2 2/2] Replace rwlocks with RCU variants of interfaces Harsh Prateek Bora
2011-10-13 22:09   ` Harsh Bora
2011-10-14  4:56   ` Aneesh Kumar K.V
2011-10-14  6:49 ` Paolo Bonzini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E97DB8D.4070403@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=harsh@linux.vnet.ibm.com \
    --cc=jan.kiszka@web.de \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).