rcuja: partial implementation of cds_ja_del
[userspace-rcu.git] / rcuja / rcuja-internal.h
CommitLineData
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 26#include <pthread.h>
a2a7ff59
MD
27#include <stdio.h>
28#include <inttypes.h>
511b4dcc
MD
29#include <urcu/rculfhash.h>
30
31/* Never declared. Opaque type used to store flagged node pointers. */
b4540e8a 32struct cds_ja_inode_flag;
511b4dcc
MD
33
34/*
35 * Shadow node contains mutex and call_rcu head associated with a node.
36 */
d96bfb0d 37struct cds_ja_shadow_node {
d22c185b 38 struct cds_lfht_node ht_node; /* hash table node */
b4540e8a 39 struct cds_ja_inode *node; /* reverse mapping and hash table key */
e1db2db5
MD
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 */
d22c185b 47 struct rcu_head head; /* for deferred node and shadow node reclaim */
b0f74e47 48 int is_root; /* is it a root node ? */
f07b240f 49 int fallback_removal_count; /* removals left keeping fallback */
511b4dcc
MD
50};
51
d96bfb0d 52struct cds_ja {
b4540e8a
MD
53 struct cds_ja_inode_flag *root;
54 unsigned int tree_depth;
55 uint64_t key_max;
511b4dcc 56 /*
e1db2db5
MD
57 * We use a hash table to associate node keys to their
58 * respective shadow node. This helps reducing lookup hot path
59 * cache footprint, especially for very small nodes.
511b4dcc
MD
60 */
61 struct cds_lfht *ht;
f07b240f 62 unsigned long nr_fallback; /* Number of fallback nodes used */
511b4dcc 63};
61009379 64
25fde237 65__attribute__((visibility("protected")))
d96bfb0d 66struct cds_ja_shadow_node *rcuja_shadow_lookup_lock(struct cds_lfht *ht,
b4540e8a 67 struct cds_ja_inode *node);
be9a7474 68
25fde237 69__attribute__((visibility("protected")))
d96bfb0d 70void rcuja_shadow_unlock(struct cds_ja_shadow_node *shadow_node);
be9a7474 71
25fde237 72__attribute__((visibility("protected")))
f07b240f 73struct cds_ja_shadow_node *rcuja_shadow_set(struct cds_lfht *ht,
b4540e8a 74 struct cds_ja_inode *new_node,
d96bfb0d 75 struct cds_ja_shadow_node *inherit_from);
e1db2db5
MD
76
77/* rcuja_shadow_clear flags */
78enum {
79 RCUJA_SHADOW_CLEAR_FREE_NODE = (1U << 0),
80 RCUJA_SHADOW_CLEAR_FREE_LOCK = (1U << 1),
81};
82
be9a7474 83__attribute__((visibility("protected")))
e1db2db5 84int rcuja_shadow_clear(struct cds_lfht *ht,
b4540e8a 85 struct cds_ja_inode *node,
a2a7ff59 86 struct cds_ja_shadow_node *shadow_node,
e1db2db5 87 unsigned int flags);
be9a7474
MD
88
89__attribute__((visibility("protected")))
90void rcuja_shadow_prune(struct cds_lfht *ht,
91 unsigned int flags);
92
25fde237 93__attribute__((visibility("protected")))
5eb692c0 94struct cds_lfht *rcuja_create_ht(const struct rcu_flavor_struct *flavor);
be9a7474 95
25fde237 96__attribute__((visibility("protected")))
be9a7474 97int rcuja_delete_ht(struct cds_lfht *ht);
25fde237 98
a2a7ff59
MD
99#define DEBUG
100
101#ifdef DEBUG
102#define dbg_printf(fmt, args...) printf("[debug rcuja] " fmt, ## args)
103#else
104#define dbg_printf(fmt, args...) \
105do { \
106 /* do nothing but check printf format */ \
107 if (0) \
108 printf("[debug rcuja] " fmt, ## args); \
109} while (0)
110#endif
111
61009379 112#endif /* _URCU_RCUJA_INTERNAL_H */
This page took 0.0271 seconds and 4 git commands to generate.