* Lai Jiangshan ([email protected]) wrote: > This code which waits for a node's next pointer until it appears, will be used > many times, move it to a help function and name it > ___cds_wfq_node_sync_next().
Merged as: commit b9103f30e18bf81ffbebb6a23215f19f621cd76b Author: Lai Jiangshan <[email protected]> Date: Thu Aug 9 10:24:38 2012 -0400 urcu: move busy-wait code and name it ___cds_wfq_node_sync_next() This code which waits for a node's next pointer until it appears, will be used many times, move it to a help function and name it ___cds_wfq_node_sync_next(). Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Mathieu Desnoyers <[email protected]> Thanks! Mathieu > > Signed-off-by: Lai Jiangshan <[email protected]> > --- > urcu/static/wfqueue.h | 36 +++++++++++++++++++++++++----------- > 1 files changed, 25 insertions(+), 11 deletions(-) > > diff --git a/urcu/static/wfqueue.h b/urcu/static/wfqueue.h > index 19314f5..636e1af 100644 > --- a/urcu/static/wfqueue.h > +++ b/urcu/static/wfqueue.h > @@ -85,6 +85,29 @@ static inline void _cds_wfq_enqueue(struct cds_wfq_queue > *q, > } > > /* > + * Waiting for enqueuer to complete enqueue and return the next node > + */ > +static inline struct cds_wfq_node * > +___cds_wfq_node_sync_next(struct cds_wfq_node *node) > +{ > + struct cds_wfq_node *next; > + int attempt = 0; > + > + /* > + * Adaptative busy-looping waiting for enqueuer to complete enqueue. > + */ > + while ((next = CMM_LOAD_SHARED(node->next)) == NULL) { > + if (++attempt >= WFQ_ADAPT_ATTEMPTS) { > + poll(NULL, 0, WFQ_WAIT); /* Wait for 10ms */ > + attempt = 0; > + } else > + caa_cpu_relax(); > + } > + > + return next; > +} > + > +/* > * It is valid to reuse and free a dequeued node immediately. > * > * No need to go on a waitqueue here, as there is no possible state in which > the > @@ -96,7 +119,6 @@ static inline struct cds_wfq_node * > ___cds_wfq_dequeue_blocking(struct cds_wfq_queue *q) > { > struct cds_wfq_node *node, *next; > - int attempt = 0; > > /* > * Queue is empty if it only contains the dummy node. > @@ -105,16 +127,8 @@ ___cds_wfq_dequeue_blocking(struct cds_wfq_queue *q) > return NULL; > node = q->head; > > - /* > - * Adaptative busy-looping waiting for enqueuer to complete enqueue. > - */ > - while ((next = CMM_LOAD_SHARED(node->next)) == NULL) { > - if (++attempt >= WFQ_ADAPT_ATTEMPTS) { > - poll(NULL, 0, WFQ_WAIT); /* Wait for 10ms */ > - attempt = 0; > - } else > - caa_cpu_relax(); > - } > + next = ___cds_wfq_node_sync_next(node); > + > /* > * Move queue head forward. > */ > -- > 1.7.7 > -- Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
