Maintain list of struct call_rcu_data to keep valgrind happy.
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Wed, 9 Mar 2011 02:50:26 +0000 (21:50 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 9 Mar 2011 02:50:26 +0000 (21:50 -0500)
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
urcu-call-rcu.c
urcu-call-rcu.h

index 5c003aa944e9606ca8e2d27d4572bcefd186f0a8..aa1324e00568ef40b081ea2a7441603dd6270649 100644 (file)
@@ -36,6 +36,7 @@
 #include "urcu/wfqueue.h"
 #include "urcu-call-rcu.h"
 #include "urcu-pointer.h"
 #include "urcu/wfqueue.h"
 #include "urcu-call-rcu.h"
 #include "urcu-pointer.h"
+#include "urcu/list.h"
 
 /* Data structure that identifies a call_rcu thread. */
 
 
 /* Data structure that identifies a call_rcu thread. */
 
@@ -46,8 +47,16 @@ struct call_rcu_data {
        pthread_cond_t cond;
        unsigned long qlen;
        pthread_t tid;
        pthread_cond_t cond;
        unsigned long qlen;
        pthread_t tid;
+       struct cds_list_head list;
 } __attribute__((aligned(CAA_CACHE_LINE_SIZE)));
 
 } __attribute__((aligned(CAA_CACHE_LINE_SIZE)));
 
+/*
+ * List of all call_rcu_data structures to keep valgrind happy.
+ * Protected by call_rcu_mutex.
+ */
+
+CDS_LIST_HEAD(call_rcu_data_list);
+
 /* Link a thread using call_rcu() to its call_rcu thread. */
 
 static __thread struct call_rcu_data *thread_call_rcu_data;
 /* Link a thread using call_rcu() to its call_rcu thread. */
 
 static __thread struct call_rcu_data *thread_call_rcu_data;
@@ -197,10 +206,12 @@ static void *call_rcu_thread(void *arg)
 
 /*
  * Create both a call_rcu thread and the corresponding call_rcu_data
 
 /*
  * Create both a call_rcu thread and the corresponding call_rcu_data
- * structure, linking the structure in as specified.
+ * structure, linking the structure in as specified.  Caller must hold
+ * call_rcu_mutex.
  */
 
  */
 
-void call_rcu_data_init(struct call_rcu_data **crdpp, unsigned long flags)
+static void call_rcu_data_init(struct call_rcu_data **crdpp,
+                              unsigned long flags)
 {
        struct call_rcu_data *crdp;
 
 {
        struct call_rcu_data *crdp;
 
@@ -221,6 +232,7 @@ void call_rcu_data_init(struct call_rcu_data **crdpp, unsigned long flags)
                exit(-1);
        }
        crdp->flags = flags | URCU_CALL_RCU_RUNNING;
                exit(-1);
        }
        crdp->flags = flags | URCU_CALL_RCU_RUNNING;
+       cds_list_add(&crdp->list, &call_rcu_data_list);
        cmm_smp_mb();  /* Structure initialized before pointer is planted. */
        *crdpp = crdp;
        if (pthread_create(&crdp->tid, NULL, call_rcu_thread, crdp) != 0) {
        cmm_smp_mb();  /* Structure initialized before pointer is planted. */
        *crdpp = crdp;
        if (pthread_create(&crdp->tid, NULL, call_rcu_thread, crdp) != 0) {
@@ -265,7 +277,7 @@ pthread_t get_call_rcu_thread(struct call_rcu_data *crdp)
  * Create a call_rcu_data structure (with thread) and return a pointer.
  */
 
  * Create a call_rcu_data structure (with thread) and return a pointer.
  */
 
-struct call_rcu_data *create_call_rcu_data(unsigned long flags)
+static struct call_rcu_data *__create_call_rcu_data(unsigned long flags)
 {
        struct call_rcu_data *crdp;
 
 {
        struct call_rcu_data *crdp;
 
@@ -273,6 +285,16 @@ struct call_rcu_data *create_call_rcu_data(unsigned long flags)
        return crdp;
 }
 
        return crdp;
 }
 
+struct call_rcu_data *create_call_rcu_data(unsigned long flags)
+{
+       struct call_rcu_data *crdp;
+
+       call_rcu_lock(&call_rcu_mutex);
+       crdp = __create_call_rcu_data(flags);
+       call_rcu_unlock(&call_rcu_mutex);
+       return crdp;
+}
+
 /*
  * Set the specified CPU to use the specified call_rcu_data structure.
  */
 /*
  * Set the specified CPU to use the specified call_rcu_data structure.
  */
@@ -399,7 +421,7 @@ int create_all_cpu_call_rcu_data(unsigned long flags)
                        call_rcu_unlock(&call_rcu_mutex);
                        continue;
                }
                        call_rcu_unlock(&call_rcu_mutex);
                        continue;
                }
-               crdp = create_call_rcu_data(flags);
+               crdp = __create_call_rcu_data(flags);
                if (crdp == NULL) {
                        call_rcu_unlock(&call_rcu_mutex);
                        errno = ENOMEM;
                if (crdp == NULL) {
                        call_rcu_unlock(&call_rcu_mutex);
                        errno = ENOMEM;
index 2c133889fef9b413fefa5fc0e26b003a88adbca0..f965911ebfc8b61e08e1af2b63b6c109c9e26a8b 100644 (file)
@@ -60,7 +60,6 @@ struct rcu_head {
 /*
  * Exported functions
  */
 /*
  * Exported functions
  */
-void call_rcu_data_init(struct call_rcu_data **crdpp, unsigned long flags);
 struct call_rcu_data *get_cpu_call_rcu_data(int cpu);
 pthread_t get_call_rcu_thread(struct call_rcu_data *crdp);
 struct call_rcu_data *create_call_rcu_data(unsigned long flags);
 struct call_rcu_data *get_cpu_call_rcu_data(int cpu);
 pthread_t get_call_rcu_thread(struct call_rcu_data *crdp);
 struct call_rcu_data *create_call_rcu_data(unsigned long flags);
This page took 0.02817 seconds and 4 git commands to generate.