Skip to contentSkip to conversation

test: test for the proper pointer

PATCH New Lai Jiangshan 2 participants 7 messages Oct 13, 2012 4 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/4 test: remove rcu_defer_register_thread() from test_urcu_lfs

test_urcu_lfs has already switch to call_rcu(), rcu_defer_register_thread() is unneeded.

---
 tests/test_urcu_lfs.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
tests/test_urcu_lfs.c +0 -8
index 681b654..f5d7d4b 100644
@@ -67,7 +67,6 @@ static inline pid_t gettid(void)
 #endif
 #include <urcu.h>
 #include <urcu/cds.h>
-#include <urcu-defer.h>
 
 static volatile int test_go, test_stop;
 
@@ -221,18 +220,12 @@ void free_node_cb(struct rcu_head *head)
 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();
 
-	ret = rcu_defer_register_thread();
-	if (ret) {
-		printf("Error in rcu_defer_register_thread\n");
-		exit(-1);
-	}
 	rcu_register_thread();
 
 	while (!test_go)
@@ -261,7 +254,6 @@ void *thr_dequeuer(void *_count)
 	}
 
 	rcu_unregister_thread();
-	rcu_defer_unregister_thread();
 
 	printf_verbose("dequeuer thread_end, thread id : %lx, tid %lu, "
 		       "dequeues %llu, successful_dequeues %llu\n",
Signature · 1 line
1.7.7.6
#2 lore raw

PATCH 3/4 test: test for the proper pointer

In reply to a message not in the archive

We should use "if (qnode)" instead of "if (node)" in case of the struct cds_lfq_node_rcu is not the first field of struct node.

---
 tests/test_urcu_lfq.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
tests/test_urcu_lfq.c +4 -3
index 66ddd41..0fcbf55 100644
@@ -243,14 +243,15 @@ void *thr_dequeuer(void *_count)
 
 	for (;;) {
 		struct cds_lfq_node_rcu *qnode;
-		struct test *node;
 
 		rcu_read_lock();
 		qnode = cds_lfq_dequeue_rcu(&q);
-		node = caa_container_of(qnode, struct test, list);
 		rcu_read_unlock();
 
-		if (node) {
+		if (qnode) {
+			struct test *node;
+
+			node = caa_container_of(qnode, struct test, list);
 			call_rcu(&node->rcu, free_node_cb);
 			URCU_TLS(nr_successful_dequeues)++;
 		}
Signature · 1 line
1.7.7.6
#3 lore raw

PATCH 4/4 test: remove rcu_defer_register_thread() from test_urcu_lfq

In reply to a message not in the archive

test_urcu_lfq has already switch to call_rcu(), rcu_defer_register_thread() is unneeded.

---
 tests/test_urcu_lfq.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
tests/test_urcu_lfq.c +0 -8
index 0fcbf55..1204d92 100644
@@ -67,7 +67,6 @@ static inline pid_t gettid(void)
 #endif
 #include <urcu.h>
 #include <urcu/cds.h>
-#include <urcu-defer.h>
 
 static volatile int test_go, test_stop;
 
@@ -222,18 +221,12 @@ void free_node_cb(struct rcu_head *head)
 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();
 
-	ret = rcu_defer_register_thread();
-	if (ret) {
-		printf("Error in rcu_defer_register_thread\n");
-		exit(-1);
-	}
 	rcu_register_thread();
 
 	while (!test_go)
@@ -264,7 +257,6 @@ void *thr_dequeuer(void *_count)
 	}
 
 	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(),
Signature · 1 line
1.7.7.6
#4 lore raw
In reply to a message not in the archive
Quoted 4 lines · * Lai Jiangshan ([email protected]) wrote:

We should use "if (snode)" instead of "if (node)" in case of the struct cds_lfs_node_rcu is not the first field of struct node.

merged, thanks!

Mathieu

Quoted 29 lines
---
 tests/test_urcu_lfs.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
tests/test_urcu_lfs.c +4 -3
index 88bf65d..681b654 100644
@@ -242,13 +242,14 @@ void *thr_dequeuer(void *_count)
 
 	for (;;) {
 		struct cds_lfs_node_rcu *snode;
-		struct test *node;
 
 		rcu_read_lock();
 		snode = cds_lfs_pop_rcu(&s);
-		node = caa_container_of(snode, struct test, list);
 		rcu_read_unlock();
-		if (node) {
+		if (snode) {
+			struct test *node;
+
+			node = caa_container_of(snode, struct test, list);
 			call_rcu(&node->rcu, free_node_cb);
 			URCU_TLS(nr_successful_dequeues)++;
 		}
Signature · 1 line
1.7.7.6
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Re: [PATCH 2/4] test: remove rcu_defer_register_thread() from test_urcu_lfs

Quoted 2 lines · * Lai Jiangshan ([email protected]) wrote:

test_urcu_lfs has already switch to call_rcu(), rcu_defer_register_thread() is unneeded.

Merged, thanks!

Mathieu

Quoted 48 lines
---
 tests/test_urcu_lfs.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
tests/test_urcu_lfs.c +0 -8
index 681b654..f5d7d4b 100644
@@ -67,7 +67,6 @@ static inline pid_t gettid(void)
 #endif
 #include <urcu.h>
 #include <urcu/cds.h>
-#include <urcu-defer.h>
 
 static volatile int test_go, test_stop;
 
@@ -221,18 +220,12 @@ void free_node_cb(struct rcu_head *head)
 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();
 
-	ret = rcu_defer_register_thread();
-	if (ret) {
-		printf("Error in rcu_defer_register_thread\n");
-		exit(-1);
-	}
 	rcu_register_thread();
 
 	while (!test_go)
@@ -261,7 +254,6 @@ void *thr_dequeuer(void *_count)
 	}
 
 	rcu_unregister_thread();
-	rcu_defer_unregister_thread();
 
 	printf_verbose("dequeuer thread_end, thread id : %lx, tid %lu, "
 		       "dequeues %llu, successful_dequeues %llu\n",
Signature · 1 line
1.7.7.6
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 2 lines · * Lai Jiangshan ([email protected]) wrote:

We should use "if (qnode)" instead of "if (node)" in case of the struct cds_lfq_node_rcu is not the first field of struct node.

merged, thanks!

Mathieu

Quoted 32 lines
---
 tests/test_urcu_lfq.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
tests/test_urcu_lfq.c +4 -3
index 66ddd41..0fcbf55 100644
@@ -243,14 +243,15 @@ void *thr_dequeuer(void *_count)
 
 	for (;;) {
 		struct cds_lfq_node_rcu *qnode;
-		struct test *node;
 
 		rcu_read_lock();
 		qnode = cds_lfq_dequeue_rcu(&q);
-		node = caa_container_of(qnode, struct test, list);
 		rcu_read_unlock();
 
-		if (node) {
+		if (qnode) {
+			struct test *node;
+
+			node = caa_container_of(qnode, struct test, list);
 			call_rcu(&node->rcu, free_node_cb);
 			URCU_TLS(nr_successful_dequeues)++;
 		}
Signature · 1 line
1.7.7.6
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

Re: [PATCH 4/4] test: remove rcu_defer_register_thread() from test_urcu_lfq

Quoted 2 lines · * Lai Jiangshan ([email protected]) wrote:

test_urcu_lfq has already switch to call_rcu(), rcu_defer_register_thread() is unneeded.

merged, thanks!

Mathieu

Quoted 48 lines
---
 tests/test_urcu_lfq.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
tests/test_urcu_lfq.c +0 -8
index 0fcbf55..1204d92 100644
@@ -67,7 +67,6 @@ static inline pid_t gettid(void)
 #endif
 #include <urcu.h>
 #include <urcu/cds.h>
-#include <urcu-defer.h>
 
 static volatile int test_go, test_stop;
 
@@ -222,18 +221,12 @@ void free_node_cb(struct rcu_head *head)
 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();
 
-	ret = rcu_defer_register_thread();
-	if (ret) {
-		printf("Error in rcu_defer_register_thread\n");
-		exit(-1);
-	}
 	rcu_register_thread();
 
 	while (!test_go)
@@ -264,7 +257,6 @@ void *thr_dequeuer(void *_count)
 	}
 
 	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(),
Signature · 1 line
1.7.7.6
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com