[lttng-dev] [PATCH 01/16] Fix: wfcqueue nonblocking dequeue
Lai Jiangshan
laijs at cn.fujitsu.com
Wed Nov 21 03:07:54 EST 2012
On 11/21/2012 03:40 AM, Mathieu Desnoyers wrote:
> Failures were not handled in the nonblocking dequeue implementation.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
> urcu/static/wfcqueue.h | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/urcu/static/wfcqueue.h b/urcu/static/wfcqueue.h
> index 8733771..a284b58 100644
> --- a/urcu/static/wfcqueue.h
> +++ b/urcu/static/wfcqueue.h
> @@ -312,6 +312,8 @@ ___cds_wfcq_dequeue(struct cds_wfcq_head *head,
> return NULL;
>
> node = ___cds_wfcq_node_sync_next(&head->node, blocking);
> + if (!blocking && node == CDS_WFCQ_WOULDBLOCK)
> + return CDS_WFCQ_WOULDBLOCK;
>
> if ((next = CMM_LOAD_SHARED(node->next)) == NULL) {
> /*
> @@ -332,6 +334,15 @@ ___cds_wfcq_dequeue(struct cds_wfcq_head *head,
> if (uatomic_cmpxchg(&tail->p, node, &head->node) == node)
> return node;
Is it this simpler?
we had just loaded node->next via "if ((next = CMM_LOAD_SHARED(node->next)) == NULL)"
+ if (!blocking)
+ return CDS_WFCQ_WOULDBLOCK
> next = ___cds_wfcq_node_sync_next(node, blocking);
and remove the following.
> + /*
> + * In nonblocking mode, if we would need to block to
> + * get node's next, set the head next node pointer
> + * (currently NULL) back to its original value.
> + */
> + if (!blocking && next == CDS_WFCQ_WOULDBLOCK) {
> + head->node.next = node;
> + return CDS_WFCQ_WOULDBLOCK;
> + }
> }
>
> /*
More information about the lttng-dev
mailing list