From: Mathieu Desnoyers Date: Sun, 19 Aug 2012 13:28:53 +0000 (-0400) Subject: rcuja: create shadow node for root X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b0f74e4734295f71a2c311817c0082223f2564d8;p=userspace-rcu.git rcuja: create shadow node for root Signed-off-by: Mathieu Desnoyers --- diff --git a/rcuja/rcuja-internal.h b/rcuja/rcuja-internal.h index 28908e0..0277808 100644 --- a/rcuja/rcuja-internal.h +++ b/rcuja/rcuja-internal.h @@ -43,6 +43,7 @@ struct cds_ja_shadow_node { pthread_mutex_t *lock; unsigned int nr_child; /* number of children in node */ struct rcu_head head; /* for deferred node and shadow node reclaim */ + int is_root; /* is it a root node ? */ }; struct cds_ja { diff --git a/rcuja/rcuja.c b/rcuja/rcuja.c index 1c1d6e4..945b299 100644 --- a/rcuja/rcuja.c +++ b/rcuja/rcuja.c @@ -876,7 +876,8 @@ int cds_ja_add(struct cds_ja *ja, uint64_t key, retry: iter_key = key; parent2_node_flag = NULL; - parent_node_flag = NULL; + parent_node_flag = + (struct cds_ja_inode_flag *) &ja->root; /* Use root ptr address as key for mutex */ node_flag_ptr = &ja->root; node_flag = rcu_dereference(*node_flag_ptr); @@ -921,6 +922,7 @@ struct cds_ja *_cds_ja_new(unsigned int key_bits, const struct rcu_flavor_struct *flavor) { struct cds_ja *ja; + int ret; ja = calloc(sizeof(*ja), 1); if (!ja) @@ -950,8 +952,21 @@ struct cds_ja *_cds_ja_new(unsigned int key_bits, ja->ht = rcuja_create_ht(flavor); if (!ja->ht) goto ht_error; + + /* + * Note: we should not free this node until judy array destroy. + */ + ret = rcuja_shadow_set(ja->ht, + ja_node_ptr((struct cds_ja_inode_flag *) &ja->root), + NULL); + if (ret) + goto ht_node_error; + return ja; +ht_node_error: + ret = rcuja_delete_ht(ja->ht); + assert(!ret); ht_error: check_error: free(ja);