RCU Judy Array (rcuja) implementation
[userspace-rcu.git] / tests / regression / test_urcu_ja.h
CommitLineData
db61f215
MD
1#ifndef _TEST_URCU_JA_H
2#define _TEST_URCU_JA_H
3
4/*
5 * test_urcu_ja.h
6 *
7 * Userspace RCU library - test program
8 *
9 * Copyright 2009-2012 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program 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
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 */
25
26#include <stdio.h>
27#include <pthread.h>
28#include <stdlib.h>
29#include <string.h>
30#include <sys/types.h>
31#include <sys/wait.h>
32#include <unistd.h>
33#include <stdio.h>
34#include <assert.h>
35#include <sched.h>
36#include <errno.h>
37#include <signal.h>
38
39#include <urcu/tls-compat.h>
40#include "thread-id.h"
41
42#define DEFAULT_RAND_POOL 1000000
43
44/* Make this big enough to include the POWER5+ L3 cacheline size of 256B */
45#define CACHE_LINE_SIZE 4096
46
47/* hardcoded number of CPUs */
48#define NR_CPUS 16384
49
50#ifdef POISON_FREE
51#define poison_free(ptr) \
52 do { \
53 memset(ptr, 0x42, sizeof(*(ptr))); \
54 free(ptr); \
55 } while (0)
56#else
57#define poison_free(ptr) free(ptr)
58#endif
59
60#ifndef DYNAMIC_LINK_TEST
61#define _LGPL_SOURCE
62#else
63#define debug_yield_read()
64#endif
65#include <urcu-qsbr.h>
66#include <urcu/rcuja.h>
67#include <urcu-call-rcu.h>
68
69struct wr_count {
70 unsigned long update_ops;
71 unsigned long add;
72 unsigned long add_exist;
73 unsigned long remove;
74};
75
76extern DECLARE_URCU_TLS(unsigned int, rand_lookup);
77extern DECLARE_URCU_TLS(unsigned long, nr_add);
78extern DECLARE_URCU_TLS(unsigned long, nr_addexist);
79extern DECLARE_URCU_TLS(unsigned long, nr_del);
80extern DECLARE_URCU_TLS(unsigned long, nr_delnoent);
81extern DECLARE_URCU_TLS(unsigned long, lookup_fail);
82extern DECLARE_URCU_TLS(unsigned long, lookup_ok);
83
84extern struct cds_ja *test_ja;
85
86struct ja_test_node {
87 struct cds_ja_node node;
88 uint64_t key; /* for testing */
89 struct rcu_head head; /* delayed reclaim */
90};
91
92static inline struct ja_test_node *
93to_test_node(struct cds_ja_node *node)
94{
95 return caa_container_of(node, struct ja_test_node, node);
96}
97
98static inline
99void ja_test_node_init(struct ja_test_node *node, uint64_t key)
100{
101 cds_ja_node_init(&node->node);
102 node->key = key;
103}
104
105extern volatile int test_go, test_stop;
106
107extern unsigned long wdelay;
108
109extern unsigned long duration;
110
111/* read-side C.S. duration, in loops */
112extern unsigned long rduration;
113
114extern unsigned long init_populate;
115extern int add_only;
116
117extern unsigned long init_pool_offset, lookup_pool_offset, write_pool_offset;
118extern unsigned long init_pool_size,
119 lookup_pool_size,
120 write_pool_size;
121extern int validate_lookup;
122
123extern int count_pipe[2];
124
125static inline void loop_sleep(unsigned long l)
126{
127 while(l-- != 0)
128 caa_cpu_relax();
129}
130
131extern int verbose_mode;
132
133#define printf_verbose(fmt, args...) \
134 do { \
135 if (verbose_mode) \
136 printf(fmt, ## args); \
137 } while (0)
138
139extern unsigned int cpu_affinities[NR_CPUS];
140extern unsigned int next_aff;
141extern int use_affinity;
142
143extern pthread_mutex_t affinity_mutex;
144
145#ifndef HAVE_CPU_SET_T
146typedef unsigned long cpu_set_t;
147# define CPU_ZERO(cpuset) do { *(cpuset) = 0; } while(0)
148# define CPU_SET(cpu, cpuset) do { *(cpuset) |= (1UL << (cpu)); } while(0)
149#endif
150
151void set_affinity(void);
152
153/*
154 * returns 0 if test should end.
155 */
156static inline int test_duration_write(void)
157{
158 return !test_stop;
159}
160
161static inline int test_duration_read(void)
162{
163 return !test_stop;
164}
165
166extern DECLARE_URCU_TLS(unsigned long long, nr_writes);
167extern DECLARE_URCU_TLS(unsigned long long, nr_reads);
168
169extern unsigned int nr_readers;
170extern unsigned int nr_writers;
171
172void rcu_copy_mutex_lock(void);
173void rcu_copy_mutex_unlock(void);
174
175#endif /* _TEST_URCU_JA_H */
This page took 0.028051 seconds and 4 git commands to generate.