#include <unistd.h>
#include <stdio.h>
#include <assert.h>
-#include <sys/syscall.h>
#include <sched.h>
#include <errno.h>
#include <urcu/arch.h>
+#ifdef __linux__
+#include <syscall.h>
+#endif
+
/* hardcoded number of CPUs */
#define NR_CPUS 16384
#define _LGPL_SOURCE
#endif
#include <urcu.h>
-#include <urcu/rculfqueue.h>
-#include <urcu-defer.h>
+#include <urcu/cds.h>
static volatile int test_go, test_stop;
static inline void loop_sleep(unsigned long l)
{
while(l-- != 0)
- cpu_relax();
+ caa_cpu_relax();
}
static int verbose_mode;
static unsigned int nr_enqueuers;
static unsigned int nr_dequeuers;
-static struct rcu_lfq_queue q;
+static struct cds_lfq_queue_rcu q;
void *thr_enqueuer(void *_count)
{
while (!test_go)
{
}
- smp_mb();
+ cmm_smp_mb();
for (;;) {
- struct rcu_lfq_node *node = malloc(sizeof(*node));
+ struct cds_lfq_node_rcu *node = malloc(sizeof(*node));
if (!node)
goto fail;
- rcu_lfq_node_init(node);
- rcu_lfq_enqueue(&q, node);
+ cds_lfq_node_init_rcu(node);
+ rcu_read_lock();
+ cds_lfq_enqueue_rcu(&q, node);
+ rcu_read_unlock();
nr_successful_enqueues++;
if (unlikely(wdelay))
}
-static void rcu_release_node(struct urcu_ref *ref)
+static void rcu_free_node(struct rcu_head *head)
{
- struct rcu_lfq_node *node = container_of(ref, struct rcu_lfq_node, ref);
- defer_rcu(free, node);
- //synchronize_rcu();
- //free(node);
+ struct cds_lfq_node_rcu *node =
+ caa_container_of(head, struct cds_lfq_node_rcu, rcu_head);
+ free(node);
+}
+
+static void ref_release_node(struct urcu_ref *ref)
+{
+ struct cds_lfq_node_rcu *node =
+ caa_container_of(ref, struct cds_lfq_node_rcu, ref);
+ call_rcu(&node->rcu_head, rcu_free_node);
}
void *thr_dequeuer(void *_count)
{
unsigned long long *count = _count;
+ int ret;
printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
"dequeuer", pthread_self(), (unsigned long)gettid());
set_affinity();
- rcu_defer_register_thread();
rcu_register_thread();
while (!test_go)
{
}
- smp_mb();
+ cmm_smp_mb();
for (;;) {
- struct rcu_lfq_node *node = rcu_lfq_dequeue(&q,
- rcu_release_node);
+ struct cds_lfq_node_rcu *node;
+
+ rcu_read_lock();
+ node = cds_lfq_dequeue_rcu(&q);
+ rcu_read_unlock();
if (node) {
- urcu_ref_put(&node->ref, rcu_release_node);
+ urcu_ref_put(&node->ref, ref_release_node);
nr_successful_dequeues++;
}
}
rcu_unregister_thread();
- rcu_defer_unregister_thread();
-
printf_verbose("dequeuer thread_end, thread id : %lx, tid %lu, "
"dequeues %llu, successful_dequeues %llu\n",
pthread_self(), (unsigned long)gettid(), nr_dequeues,
static void release_node(struct urcu_ref *ref)
{
- struct rcu_lfq_node *node = container_of(ref, struct rcu_lfq_node, ref);
+ struct cds_lfq_node_rcu *node = caa_container_of(ref, struct cds_lfq_node_rcu, ref);
free(node);
}
-void test_end(struct rcu_lfq_queue *q, unsigned long long *nr_dequeues)
+void test_end(struct cds_lfq_queue_rcu *q, unsigned long long *nr_dequeues)
{
- struct rcu_lfq_node *node;
+ struct cds_lfq_node_rcu *node;
do {
- node = rcu_lfq_dequeue(q, release_node);
+ rcu_read_lock();
+ node = cds_lfq_dequeue_rcu(q);
+ rcu_read_unlock();
if (node) {
urcu_ref_put(&node->ref, release_node);
(*nr_dequeues)++;
tid_dequeuer = malloc(sizeof(*tid_dequeuer) * nr_dequeuers);
count_enqueuer = malloc(2 * sizeof(*count_enqueuer) * nr_enqueuers);
count_dequeuer = malloc(2 * sizeof(*count_dequeuer) * nr_dequeuers);
- rcu_lfq_init(&q);
+ cds_lfq_init_rcu(&q, ref_release_node);
next_aff = 0;
exit(1);
}
- smp_mb();
+ cmm_smp_mb();
test_go = 1;