From: Mike Day <ncmike@ncultra.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Paul Mckenney <paulmck@linux.vnet.ibm.com>,
Mathew Desnoyers <mathieu.desnoyers@efficios.com>,
qemu-devel@nongnu.org, Anthony Liguori <anthony@codemonkey.ws>
Subject: Re: [Qemu-devel] [RFC PATCH] Introduce RCU-enabled DQs (v2)
Date: Sun, 25 Aug 2013 09:06:06 -0400 [thread overview]
Message-ID: <87vc2tapj5.fsf@pixel.localdomain> (raw)
In-Reply-To: <5219A4E8.60802@redhat.com>
Paolo Bonzini <pbonzini@redhat.com> writes:
> Just a couple of questions, one of them on the new macro...
>
>> +/* prior to publication of the elm->prev->next value, some list
>> + * readers may still see the removed element when following
>> + * the antecedent's next pointer.
>> + */
>> +
>> +#define QLIST_REMOVE_RCU(elm, field) do { \
>> + if ((elm)->field.le_next != NULL) { \
>> + (elm)->field.le_next->field.le_prev = \
>> + (elm)->field.le_prev; \
>> + } \
>> + atomic_rcu_set((elm)->field.le_prev, (elm)->field.le_next); \
>> +} while (/*CONSTCOND*/0)
>
> Why is the barrier needed here, but not in Linux's list_del_rcu?
>
> I think it is not needed because all involved elements have already been
> published and just have their pointers shuffled.
I read this as more than shuffling pointers. The intent here is
that the previous element's next pointer is being updated to omit the
current element from the list.
atomic_set always deferences the pointer passed to it, and
(field)->le_pre is a double pointer. So looking at the macro:
#define atomic_set(ptr, i) ((*(__typeof__(*ptr) *volatile) (ptr)) = (i))
It translates to:
( ( * (__typeof(*elm->field.le_prev) *volatile) (elm)->field.le_prev) =
elm->field.le_next; )
Which is:
*((struct *elm) *volatile)(elm)->field.le_prev = elm->field.le_next;
Which is:
*(elm)->field.le_prev = elm->field.le_next;
Because field.le_prev is a double pointer that has previously been set
to &prev (the address of the previous list element) this is assiging the
*previous* element's next pointer, the way I read it.
The Linux list_del_rcu is dealing with a singly linked list and
therefore does not set a value in the previous node's element.
But I'm still unclear on whether or not the memory barrier is needed
because the deleted element won't be reclaimed right away.
Mike
--
Mike Day | + 1 919 371-8786 | ncmike@ncultra.org
"Endurance is a Virtue"
next prev parent reply other threads:[~2013-08-25 13:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-24 19:06 [Qemu-devel] [RFC PATCH] Introduce RCU-enabled DQs (v2) Mike Day
2013-08-25 6:32 ` Paolo Bonzini
2013-08-25 13:06 ` Mike Day [this message]
2013-08-26 11:39 ` Paolo Bonzini
2013-08-25 19:18 ` Mathieu Desnoyers
2013-08-26 21:48 ` Mike Day
2013-08-26 21:48 ` [Qemu-devel] " Mike Day
2013-08-26 22:23 ` Paolo Bonzini
2013-08-26 22:23 ` [Qemu-devel] " Paolo Bonzini
2013-08-25 19:18 ` Mathieu Desnoyers
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=87vc2tapj5.fsf@pixel.localdomain \
--to=ncmike@ncultra.org \
--cc=anthony@codemonkey.ws \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.