rcuja: API change: move rcu_head to user code
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 5 Jun 2013 15:00:28 +0000 (11:00 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 5 Jun 2013 15:00:28 +0000 (11:00 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
rcuja/rcuja-internal.h
rcuja/rcuja-shadow-nodes.c
rcuja/rcuja.c
tests/test_urcu_ja.c
tests/test_urcu_ja.h
urcu/rcuja.h

index cf4ef96fcc71a0f0f86ba6b69a6ac24a100d9131..9b1daca61cb7541009f8db64b9014215a5ff1fe4 100644 (file)
@@ -149,7 +149,7 @@ struct cds_ja_inode *ja_node_ptr(struct cds_ja_inode_flag *node);
 __attribute__((visibility("protected")))
 void rcuja_free_all_children(struct cds_ja_shadow_node *shadow_node,
                struct cds_ja_inode_flag *node_flag,
-               void (*free_node_cb)(struct rcu_head *head));
+               void (*rcu_free_node)(struct cds_ja_node *node));
 
 __attribute__((visibility("protected")))
 struct cds_ja_shadow_node *rcuja_shadow_lookup_lock(struct cds_lfht *ht,
@@ -179,7 +179,7 @@ int rcuja_shadow_clear(struct cds_lfht *ht,
 __attribute__((visibility("protected")))
 void rcuja_shadow_prune(struct cds_lfht *ht,
                unsigned int flags,
-               void (*free_node_cb)(struct rcu_head *head));
+               void (*rcu_free_node)(struct cds_ja_node *node));
 
 __attribute__((visibility("protected")))
 struct cds_lfht *rcuja_create_ht(const struct rcu_flavor_struct *flavor);
index 1c6124e3e749e5cc6c72e28a0c584c4f272b811f..917c6a2038e8c11a809fb4acfd5cf69be8d57b02 100644 (file)
@@ -377,7 +377,7 @@ rcu_unlock:
 __attribute__((visibility("protected")))
 void rcuja_shadow_prune(struct cds_lfht *ht,
                unsigned int flags,
-               void (*free_node_cb)(struct rcu_head *head))
+               void (*rcu_free_node)(struct cds_ja_node *node))
 {
        const struct rcu_flavor_struct *flavor;
        struct cds_ja_shadow_node *shadow_node;
@@ -397,7 +397,7 @@ void rcuja_shadow_prune(struct cds_lfht *ht,
                                if (shadow_node->level == shadow_node->ja->tree_depth - 1) {
                                        rcuja_free_all_children(shadow_node,
                                                        shadow_node->node_flag,
-                                                       free_node_cb);
+                                                       rcu_free_node);
                                }
                                if (flags & RCUJA_SHADOW_CLEAR_FREE_LOCK) {
                                        flavor->update_call_rcu(&shadow_node->head,
index 1103116d2591a58c36df36d9363cd667e0a3c4d9..4d1f2b435a1433c44cdc3a8ae0983178000e0160 100644 (file)
@@ -2529,14 +2529,12 @@ ja_error:
 __attribute__((visibility("protected")))
 void rcuja_free_all_children(struct cds_ja_shadow_node *shadow_node,
                struct cds_ja_inode_flag *node_flag,
-               void (*free_node_cb)(struct rcu_head *head))
+               void (*rcu_free_node)(struct cds_ja_node *node))
 {
-       const struct rcu_flavor_struct *flavor;
        unsigned int type_index;
        struct cds_ja_inode *node;
        const struct cds_ja_type *type;
 
-       flavor = cds_lfht_rcu_flavor(shadow_node->ja->ht);
        node = ja_node_ptr(node_flag);
        assert(node != NULL);
        type_index = ja_node_type(node_flag);
@@ -2561,7 +2559,7 @@ void rcuja_free_all_children(struct cds_ja_shadow_node *shadow_node,
                                continue;
                        head.next = (struct cds_hlist_node *) iter;
                        cds_hlist_for_each_entry_safe(entry, pos, tmp, &head, list) {
-                               flavor->update_call_rcu(&entry->head, free_node_cb);
+                               rcu_free_node(entry);
                        }
                }
                break;
@@ -2589,7 +2587,7 @@ void rcuja_free_all_children(struct cds_ja_shadow_node *shadow_node,
                                        continue;
                                head.next = (struct cds_hlist_node *) iter;
                                cds_hlist_for_each_entry_safe(entry, pos, tmp, &head, list) {
-                                       flavor->update_call_rcu(&entry->head, free_node_cb);
+                                       rcu_free_node(entry);
                                }
                        }
                }
@@ -2612,7 +2610,7 @@ void rcuja_free_all_children(struct cds_ja_shadow_node *shadow_node,
                                continue;
                        head.next = (struct cds_hlist_node *) iter;
                        cds_hlist_for_each_entry_safe(entry, pos, tmp, &head, list) {
-                               flavor->update_call_rcu(&entry->head, free_node_cb);
+                               rcu_free_node(entry);
                        }
                }
                break;
@@ -2671,7 +2669,7 @@ int ja_final_checks(struct cds_ja *ja)
  * being destroyed (ensured by the caller).
  */
 int cds_ja_destroy(struct cds_ja *ja,
-               void (*free_node_cb)(struct rcu_head *head))
+               void (*rcu_free_node)(struct cds_ja_node *node))
 {
        const struct rcu_flavor_struct *flavor;
        int ret;
@@ -2679,7 +2677,7 @@ int cds_ja_destroy(struct cds_ja *ja,
        flavor = cds_lfht_rcu_flavor(ja->ht);
        rcuja_shadow_prune(ja->ht,
                RCUJA_SHADOW_CLEAR_FREE_NODE | RCUJA_SHADOW_CLEAR_FREE_LOCK,
-               free_node_cb);
+               rcu_free_node);
        flavor->thread_offline();
        ret = rcuja_delete_ht(ja->ht);
        if (ret)
index 63683b6faa1a309adb919ef2c70cffdb887c3703..7230ec6d8398e2a44eefc5470b33775a782e4590 100644 (file)
@@ -156,10 +156,24 @@ static
 void free_node_cb(struct rcu_head *head)
 {
        struct ja_test_node *node =
-               caa_container_of(head, struct ja_test_node, node.head);
+               caa_container_of(head, struct ja_test_node, head);
        free_node(node);
 }
 
+static
+void rcu_free_test_node(struct ja_test_node *test_node)
+{
+       call_rcu(&test_node->head, free_node_cb);
+}
+
+static
+void rcu_free_node(struct cds_ja_node *node)
+{
+       struct ja_test_node *test_node = to_test_node(node);
+
+       rcu_free_test_node(test_node);
+}
+
 #if 0
 static
 void test_delete_all_nodes(struct cds_lfht *ht)
@@ -286,7 +300,7 @@ int test_8bit_key(void)
                        fprintf(stderr, "Error (%d) removing node %" PRIu64 "\n", ret, key);
                        assert(0);
                }
-               call_rcu(&node->node.head, free_node_cb);
+               rcu_free_test_node(node);
                head = cds_ja_lookup(test_ja, key);
                if (!cds_hlist_empty(&head)) {
                        fprintf(stderr, "Error lookup %" PRIu64 ": %p (after delete) failed. Node is not expected.\n", key, head.next);
@@ -357,7 +371,7 @@ int test_8bit_key(void)
 
        printf("OK\n");
 
-       ret = cds_ja_destroy(test_ja, free_node_cb);
+       ret = cds_ja_destroy(test_ja, rcu_free_node);
        if (ret) {
                fprintf(stderr, "Error destroying judy array\n");
                return -1;
@@ -445,7 +459,7 @@ int test_16bit_key(void)
                        fprintf(stderr, "Error (%d) removing node %" PRIu64 "\n", ret, key);
                        assert(0);
                }
-               call_rcu(&node->node.head, free_node_cb);
+               rcu_free_test_node(node);
                head = cds_ja_lookup(test_ja, key);
                if (!cds_hlist_empty(&head)) {
                        fprintf(stderr, "Error lookup %" PRIu64 ": %p (after delete) failed. Node is not expected.\n", key, head.next);
@@ -516,7 +530,7 @@ int test_16bit_key(void)
 
        printf("OK\n");
 
-       ret = cds_ja_destroy(test_ja, free_node_cb);
+       ret = cds_ja_destroy(test_ja, rcu_free_node);
        if (ret) {
                fprintf(stderr, "Error destroying judy array\n");
                return -1;
@@ -638,7 +652,7 @@ int test_sparse_key(unsigned int bits, int nr_dup)
                                fprintf(stderr, "Error (%d) removing node %" PRIu64 "\n", ret, key);
                                assert(0);
                        }
-                       call_rcu(&node->node.head, free_node_cb);
+                       rcu_free_test_node(node);
                        testhead = cds_ja_lookup(test_ja, key);
                        if (count < nr_dup && cds_hlist_empty(&testhead)) {
                                fprintf(stderr, "Error: no node found after deletion of some nodes of a key\n");
@@ -656,7 +670,7 @@ int test_sparse_key(unsigned int bits, int nr_dup)
        }
        printf("OK\n");
 
-       ret = cds_ja_destroy(test_ja, free_node_cb);
+       ret = cds_ja_destroy(test_ja, rcu_free_node);
        if (ret) {
                fprintf(stderr, "Error destroying judy array\n");
                return -1;
@@ -858,7 +872,7 @@ void *test_ja_rw_thr_writer(void *_count)
                        if (node) {
                                ret = cds_ja_del(test_ja, key, &node->node);
                                if (!ret) {
-                                       call_rcu(&node->node.head, free_node_cb);
+                                       rcu_free_test_node(node);
                                        URCU_TLS(nr_del)++;
                                } else {
                                        URCU_TLS(nr_delnoent)++;
@@ -1001,7 +1015,7 @@ int do_mt_test(void)
        }
        rcu_thread_online_qsbr();
 
-       ret = cds_ja_destroy(test_ja, free_node_cb);
+       ret = cds_ja_destroy(test_ja, rcu_free_node);
        if (ret) {
                fprintf(stderr, "Error destroying judy array\n");
                goto end;
index 3174613178d0d5e6091366236021108047e2bbf8..873b493bc0c0739347f05167b42104259a5a914a 100644 (file)
@@ -106,7 +106,8 @@ extern struct cds_ja *test_ja;
 
 struct ja_test_node {
        struct cds_ja_node node;
-       uint64_t key; /* for testing */
+       uint64_t key;           /* for testing */
+       struct rcu_head head;   /* delayed reclaim */
 };
 
 static inline struct ja_test_node *
index e66ce7e9288095458377ca35eba046ce18959780..a6407b66785fc757b568605b0f79792ab2c83286 100644 (file)
@@ -39,8 +39,6 @@ extern "C" {
 struct cds_ja_node {
        /* Linked list of nodes with same key */
        struct cds_hlist_node list;
-       /* delayed reclaim */
-       struct rcu_head head;
 };
 
 struct cds_ja;
@@ -80,7 +78,7 @@ struct cds_ja *cds_ja_new(unsigned int key_bits)
 }
 
 int cds_ja_destroy(struct cds_ja *ja,
-               void (*free_node_cb)(struct rcu_head *head));
+               void (*rcu_free_node_cb)(struct cds_ja_node *node));
 
 #ifdef __cplusplus
 }
This page took 0.03119 seconds and 4 git commands to generate.