1 #ifndef _TEST_URCU_JA_H
2 #define _TEST_URCU_JA_H
7 * Userspace RCU library - test program
9 * Copyright 2009-2012 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
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.
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.
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.
26 #include "../config.h"
31 #include <sys/types.h>
40 #include <urcu/tls-compat.h>
46 #define DEFAULT_RAND_POOL 1000000
48 /* Make this big enough to include the POWER5+ L3 cacheline size of 256B */
49 #define CACHE_LINE_SIZE 4096
51 /* hardcoded number of CPUs */
55 #define poison_free(ptr) \
57 memset(ptr, 0x42, sizeof(*(ptr))); \
61 #define poison_free(ptr) free(ptr)
66 #if defined(_syscall0)
67 _syscall0(pid_t
, gettid
)
68 #elif defined(__NR_gettid)
69 static inline pid_t
gettid(void)
71 return syscall(__NR_gettid
);
74 #warning "use pid as tid"
75 static inline pid_t
gettid(void)
81 #ifndef DYNAMIC_LINK_TEST
84 #define debug_yield_read()
86 #include <urcu-qsbr.h>
87 #include <urcu/rcuja.h>
88 #include <urcu-call-rcu.h>
91 unsigned long update_ops
;
93 unsigned long add_exist
;
97 extern DECLARE_URCU_TLS(unsigned int, rand_lookup
);
98 extern DECLARE_URCU_TLS(unsigned long, nr_add
);
99 extern DECLARE_URCU_TLS(unsigned long, nr_addexist
);
100 extern DECLARE_URCU_TLS(unsigned long, nr_del
);
101 extern DECLARE_URCU_TLS(unsigned long, nr_delnoent
);
102 extern DECLARE_URCU_TLS(unsigned long, lookup_fail
);
103 extern DECLARE_URCU_TLS(unsigned long, lookup_ok
);
105 extern struct cds_ja
*test_ja
;
107 struct ja_test_node
{
108 struct cds_ja_node node
;
109 uint64_t key
; /* for testing */
112 static inline struct ja_test_node
*
113 to_test_node(struct cds_ja_node
*node
)
115 return caa_container_of(node
, struct ja_test_node
, node
);
119 void ja_test_node_init(struct ja_test_node
*node
, uint64_t key
)
121 cds_ja_node_init(&node
->node
);
125 extern volatile int test_go
, test_stop
;
127 extern unsigned long wdelay
;
129 extern unsigned long duration
;
131 /* read-side C.S. duration, in loops */
132 extern unsigned long rduration
;
134 extern unsigned long init_populate
;
137 extern unsigned long init_pool_offset
, lookup_pool_offset
, write_pool_offset
;
138 extern unsigned long init_pool_size
,
141 extern int validate_lookup
;
143 extern int count_pipe
[2];
145 static inline void loop_sleep(unsigned long l
)
151 extern int verbose_mode
;
153 #define printf_verbose(fmt, args...) \
156 printf(fmt, ## args); \
159 extern unsigned int cpu_affinities
[NR_CPUS
];
160 extern unsigned int next_aff
;
161 extern int use_affinity
;
163 extern pthread_mutex_t affinity_mutex
;
165 #ifndef HAVE_CPU_SET_T
166 typedef unsigned long cpu_set_t
;
167 # define CPU_ZERO(cpuset) do { *(cpuset) = 0; } while(0)
168 # define CPU_SET(cpu, cpuset) do { *(cpuset) |= (1UL << (cpu)); } while(0)
171 void set_affinity(void);
174 * returns 0 if test should end.
176 static inline int test_duration_write(void)
181 static inline int test_duration_read(void)
186 extern DECLARE_URCU_TLS(unsigned long long, nr_writes
);
187 extern DECLARE_URCU_TLS(unsigned long long, nr_reads
);
189 extern unsigned int nr_readers
;
190 extern unsigned int nr_writers
;
192 void rcu_copy_mutex_lock(void);
193 void rcu_copy_mutex_unlock(void);
195 #endif /* _TEST_URCU_JA_H */