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>
41 #include "thread-id.h"
43 #define DEFAULT_RAND_POOL 1000000
45 /* Make this big enough to include the POWER5+ L3 cacheline size of 256B */
46 #define CACHE_LINE_SIZE 4096
48 /* hardcoded number of CPUs */
52 #define poison_free(ptr) \
54 memset(ptr, 0x42, sizeof(*(ptr))); \
58 #define poison_free(ptr) free(ptr)
61 #ifndef DYNAMIC_LINK_TEST
64 #define debug_yield_read()
66 #include <urcu-qsbr.h>
67 #include <urcu/rcuja.h>
68 #include <urcu-call-rcu.h>
71 unsigned long update_ops
;
73 unsigned long add_exist
;
77 extern DECLARE_URCU_TLS(unsigned int, rand_lookup
);
78 extern DECLARE_URCU_TLS(unsigned long, nr_add
);
79 extern DECLARE_URCU_TLS(unsigned long, nr_addexist
);
80 extern DECLARE_URCU_TLS(unsigned long, nr_del
);
81 extern DECLARE_URCU_TLS(unsigned long, nr_delnoent
);
82 extern DECLARE_URCU_TLS(unsigned long, lookup_fail
);
83 extern DECLARE_URCU_TLS(unsigned long, lookup_ok
);
85 extern struct cds_ja
*test_ja
;
88 struct cds_ja_node node
;
89 uint64_t key
; /* for testing */
90 struct rcu_head head
; /* delayed reclaim */
93 static inline struct ja_test_node
*
94 to_test_node(struct cds_ja_node
*node
)
96 return caa_container_of(node
, struct ja_test_node
, node
);
100 void ja_test_node_init(struct ja_test_node
*node
, uint64_t key
)
102 cds_ja_node_init(&node
->node
);
106 extern volatile int test_go
, test_stop
;
108 extern unsigned long wdelay
;
110 extern unsigned long duration
;
112 /* read-side C.S. duration, in loops */
113 extern unsigned long rduration
;
115 extern unsigned long init_populate
;
118 extern unsigned long init_pool_offset
, lookup_pool_offset
, write_pool_offset
;
119 extern unsigned long init_pool_size
,
122 extern int validate_lookup
;
124 extern int count_pipe
[2];
126 static inline void loop_sleep(unsigned long l
)
132 extern int verbose_mode
;
134 #define printf_verbose(fmt, args...) \
137 printf(fmt, ## args); \
140 extern unsigned int cpu_affinities
[NR_CPUS
];
141 extern unsigned int next_aff
;
142 extern int use_affinity
;
144 extern pthread_mutex_t affinity_mutex
;
146 #ifndef HAVE_CPU_SET_T
147 typedef unsigned long cpu_set_t
;
148 # define CPU_ZERO(cpuset) do { *(cpuset) = 0; } while(0)
149 # define CPU_SET(cpu, cpuset) do { *(cpuset) |= (1UL << (cpu)); } while(0)
152 void set_affinity(void);
155 * returns 0 if test should end.
157 static inline int test_duration_write(void)
162 static inline int test_duration_read(void)
167 extern DECLARE_URCU_TLS(unsigned long long, nr_writes
);
168 extern DECLARE_URCU_TLS(unsigned long long, nr_reads
);
170 extern unsigned int nr_readers
;
171 extern unsigned int nr_writers
;
173 void rcu_copy_mutex_lock(void);
174 void rcu_copy_mutex_unlock(void);
176 #endif /* _TEST_URCU_JA_H */