Commit | Line | Data |
---|---|---|
61009379 MD |
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 | ||
511b4dcc MD |
26 | #include <pthread.h> |
27 | #include <urcu/rculfhash.h> | |
28 | ||
29 | /* Never declared. Opaque type used to store flagged node pointers. */ | |
b4540e8a | 30 | struct cds_ja_inode_flag; |
511b4dcc MD |
31 | |
32 | /* | |
33 | * Shadow node contains mutex and call_rcu head associated with a node. | |
34 | */ | |
d96bfb0d | 35 | struct cds_ja_shadow_node { |
d22c185b | 36 | struct cds_lfht_node ht_node; /* hash table node */ |
b4540e8a | 37 | struct cds_ja_inode *node; /* reverse mapping and hash table key */ |
e1db2db5 MD |
38 | /* |
39 | * mutual exclusion on all nodes belonging to the same tree | |
40 | * position (e.g. both nodes before and after recompaction | |
41 | * use the same lock). | |
42 | */ | |
43 | pthread_mutex_t *lock; | |
44 | unsigned int nr_child; /* number of children in node */ | |
d22c185b | 45 | struct rcu_head head; /* for deferred node and shadow node reclaim */ |
511b4dcc MD |
46 | }; |
47 | ||
d96bfb0d | 48 | struct cds_ja { |
b4540e8a MD |
49 | struct cds_ja_inode_flag *root; |
50 | unsigned int tree_depth; | |
51 | uint64_t key_max; | |
511b4dcc | 52 | /* |
e1db2db5 MD |
53 | * We use a hash table to associate node keys to their |
54 | * respective shadow node. This helps reducing lookup hot path | |
55 | * cache footprint, especially for very small nodes. | |
511b4dcc MD |
56 | */ |
57 | struct cds_lfht *ht; | |
58 | }; | |
61009379 | 59 | |
25fde237 | 60 | __attribute__((visibility("protected"))) |
d96bfb0d | 61 | struct cds_ja_shadow_node *rcuja_shadow_lookup_lock(struct cds_lfht *ht, |
b4540e8a | 62 | struct cds_ja_inode *node); |
be9a7474 | 63 | |
25fde237 | 64 | __attribute__((visibility("protected"))) |
d96bfb0d | 65 | void rcuja_shadow_unlock(struct cds_ja_shadow_node *shadow_node); |
be9a7474 | 66 | |
25fde237 MD |
67 | __attribute__((visibility("protected"))) |
68 | int rcuja_shadow_set(struct cds_lfht *ht, | |
b4540e8a | 69 | struct cds_ja_inode *new_node, |
d96bfb0d | 70 | struct cds_ja_shadow_node *inherit_from); |
e1db2db5 MD |
71 | |
72 | /* rcuja_shadow_clear flags */ | |
73 | enum { | |
74 | RCUJA_SHADOW_CLEAR_FREE_NODE = (1U << 0), | |
75 | RCUJA_SHADOW_CLEAR_FREE_LOCK = (1U << 1), | |
76 | }; | |
77 | ||
be9a7474 | 78 | __attribute__((visibility("protected"))) |
e1db2db5 | 79 | int rcuja_shadow_clear(struct cds_lfht *ht, |
b4540e8a | 80 | struct cds_ja_inode *node, |
e1db2db5 | 81 | unsigned int flags); |
be9a7474 MD |
82 | |
83 | __attribute__((visibility("protected"))) | |
84 | void rcuja_shadow_prune(struct cds_lfht *ht, | |
85 | unsigned int flags); | |
86 | ||
25fde237 | 87 | __attribute__((visibility("protected"))) |
5eb692c0 | 88 | struct cds_lfht *rcuja_create_ht(const struct rcu_flavor_struct *flavor); |
be9a7474 | 89 | |
25fde237 | 90 | __attribute__((visibility("protected"))) |
be9a7474 | 91 | int rcuja_delete_ht(struct cds_lfht *ht); |
25fde237 | 92 | |
61009379 | 93 | #endif /* _URCU_RCUJA_INTERNAL_H */ |