67d121bcda21722f35ec6e2cdc50993aefc5e9a9
[userspace-rcu.git] / rcuja / rcuja-internal.h
1 #ifndef _URCU_RCUJA_INTERNAL_H
2 #define _URCU_RCUJA_INTERNAL_H
3
4 /*
5 * rcuja/rcuja-internal.h
6 *
7 * Userspace RCU library - RCU Judy Array Internal Header
8 *
9 * Copyright 2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26 #include <pthread.h>
27 #include <stdio.h>
28 #include <inttypes.h>
29 #include <urcu/rculfhash.h>
30
31 /* Never declared. Opaque type used to store flagged node pointers. */
32 struct cds_ja_inode_flag;
33
34 /*
35 * Shadow node contains mutex and call_rcu head associated with a node.
36 */
37 struct cds_ja_shadow_node {
38 struct cds_lfht_node ht_node; /* hash table node */
39 struct cds_ja_inode *node; /* reverse mapping and hash table key */
40 /*
41 * mutual exclusion on all nodes belonging to the same tree
42 * position (e.g. both nodes before and after recompaction
43 * use the same lock).
44 */
45 pthread_mutex_t *lock;
46 unsigned int nr_child; /* number of children in node */
47 struct rcu_head head; /* for deferred node and shadow node reclaim */
48 int is_root; /* is it a root node ? */
49 };
50
51 struct cds_ja {
52 struct cds_ja_inode_flag *root;
53 unsigned int tree_depth;
54 uint64_t key_max;
55 /*
56 * We use a hash table to associate node keys to their
57 * respective shadow node. This helps reducing lookup hot path
58 * cache footprint, especially for very small nodes.
59 */
60 struct cds_lfht *ht;
61 };
62
63 __attribute__((visibility("protected")))
64 struct cds_ja_shadow_node *rcuja_shadow_lookup_lock(struct cds_lfht *ht,
65 struct cds_ja_inode *node);
66
67 __attribute__((visibility("protected")))
68 void rcuja_shadow_unlock(struct cds_ja_shadow_node *shadow_node);
69
70 __attribute__((visibility("protected")))
71 int rcuja_shadow_set(struct cds_lfht *ht,
72 struct cds_ja_inode *new_node,
73 struct cds_ja_shadow_node *inherit_from);
74
75 /* rcuja_shadow_clear flags */
76 enum {
77 RCUJA_SHADOW_CLEAR_FREE_NODE = (1U << 0),
78 RCUJA_SHADOW_CLEAR_FREE_LOCK = (1U << 1),
79 };
80
81 __attribute__((visibility("protected")))
82 int rcuja_shadow_clear(struct cds_lfht *ht,
83 struct cds_ja_inode *node,
84 struct cds_ja_shadow_node *shadow_node,
85 unsigned int flags);
86
87 __attribute__((visibility("protected")))
88 void rcuja_shadow_prune(struct cds_lfht *ht,
89 unsigned int flags);
90
91 __attribute__((visibility("protected")))
92 struct cds_lfht *rcuja_create_ht(const struct rcu_flavor_struct *flavor);
93
94 __attribute__((visibility("protected")))
95 int rcuja_delete_ht(struct cds_lfht *ht);
96
97 #define DEBUG
98
99 #ifdef DEBUG
100 #define dbg_printf(fmt, args...) printf("[debug rcuja] " fmt, ## args)
101 #else
102 #define dbg_printf(fmt, args...) \
103 do { \
104 /* do nothing but check printf format */ \
105 if (0) \
106 printf("[debug rcuja] " fmt, ## args); \
107 } while (0)
108 #endif
109
110 #endif /* _URCU_RCUJA_INTERNAL_H */
This page took 0.030273 seconds and 3 git commands to generate.