-extern struct defer_queue __thread defer_queue;
-
-extern void rcu_defer_barrier_thread(void);
-
-/*
- * not signal-safe.
- */
-static inline void _rcu_defer_queue(void *p)
-{
- unsigned long head, tail;
-
- /*
- * Head is only modified by ourself. Tail can be modified by reclamation
- * thread.
- */
- head = defer_queue.head;
- tail = LOAD_SHARED(defer_queue.tail);
-
- /*
- * If queue is full, empty it ourself.
- */
- if (unlikely(head - tail >= DEFER_QUEUE_SIZE)) {
- assert(head - tail == DEFER_QUEUE_SIZE);
- rcu_defer_barrier_thread();
- assert(head - LOAD_SHARED(defer_queue.tail) == 0);
- }
-
- smp_wmb(); /* Publish new pointer before write q[] */
- _STORE_SHARED(defer_queue.q[head & DEFER_QUEUE_MASK], p);
- smp_wmb(); /* Write q[] before head. */
- STORE_SHARED(defer_queue.head, head + 1);
-}
-