projects
/
urcu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
urcu tests: add writer duration parameter
[urcu.git]
/
tests
/
test_perthreadlock.c
diff --git
a/tests/test_perthreadlock.c
b/tests/test_perthreadlock.c
index ea47e468f340fec3b9436bd8559dc743c0bcd4a3..7fcf3e801e228bdc21d4275e3ea92839bf04269b 100644
(file)
--- a/
tests/test_perthreadlock.c
+++ b/
tests/test_perthreadlock.c
@@
-21,6
+21,7
@@
*/
#define _GNU_SOURCE
*/
#define _GNU_SOURCE
+#include "../config.h"
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
@@
-32,12
+33,10
@@
#include <assert.h>
#include <sys/syscall.h>
#include <sched.h>
#include <assert.h>
#include <sys/syscall.h>
#include <sched.h>
+#include <errno.h>
#include <urcu/arch.h>
#include <urcu/arch.h>
-/* Make this big enough to include the POWER5+ L3 cacheline size of 256B */
-#define CACHE_LINE_SIZE 4096
-
/* hardcoded number of CPUs */
#define NR_CPUS 16384
/* hardcoded number of CPUs */
#define NR_CPUS 16384
@@
-84,6
+83,9
@@
static unsigned long duration;
/* read-side C.S. duration, in loops */
static unsigned long rduration;
/* read-side C.S. duration, in loops */
static unsigned long rduration;
+/* write-side C.S. duration, in loops */
+static unsigned long wduration;
+
static inline void loop_sleep(unsigned long l)
{
while(l-- != 0)
static inline void loop_sleep(unsigned long l)
{
while(l-- != 0)
@@
-104,6
+106,12
@@
static int use_affinity = 0;
pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER;
+#ifndef HAVE_CPU_SET_T
+typedef unsigned long cpu_set_t;
+# define CPU_ZERO(cpuset) do { *(cpuset) = 0; } while(0)
+# define CPU_SET(cpu, cpuset) do { *(cpuset) |= (1UL << (cpu)); } while(0)
+#endif
+
static void set_affinity(void)
{
cpu_set_t mask;
static void set_affinity(void)
{
cpu_set_t mask;
@@
-113,6
+121,7
@@
static void set_affinity(void)
if (!use_affinity)
return;
if (!use_affinity)
return;
+#if HAVE_SCHED_SETAFFINITY
ret = pthread_mutex_lock(&affinity_mutex);
if (ret) {
perror("Error in pthread mutex lock");
ret = pthread_mutex_lock(&affinity_mutex);
if (ret) {
perror("Error in pthread mutex lock");
@@
-126,7
+135,12
@@
static void set_affinity(void)
}
CPU_ZERO(&mask);
CPU_SET(cpu, &mask);
}
CPU_ZERO(&mask);
CPU_SET(cpu, &mask);
+#if SCHED_SETAFFINITY_ARGS == 2
+ sched_setaffinity(0, &mask);
+#else
sched_setaffinity(0, sizeof(mask), &mask);
sched_setaffinity(0, sizeof(mask), &mask);
+#endif
+#endif /* HAVE_SCHED_SETAFFINITY */
}
/*
}
/*
@@
-228,6
+242,8
@@
void *thr_writer(void *data)
}
test_array.a = 0;
test_array.a = 8;
}
test_array.a = 0;
test_array.a = 8;
+ if (unlikely(wduration))
+ loop_sleep(wduration);
for (tidx = (long)nr_readers - 1; tidx >= 0; tidx--) {
pthread_mutex_unlock(&per_thread_lock[tidx].lock);
}
for (tidx = (long)nr_readers - 1; tidx >= 0; tidx--) {
pthread_mutex_unlock(&per_thread_lock[tidx].lock);
}
@@
-252,6
+268,7
@@
void show_usage(int argc, char **argv)
#endif
printf(" [-d delay] (writer period (us))");
printf(" [-c duration] (reader C.S. duration (in loops))");
#endif
printf(" [-d delay] (writer period (us))");
printf(" [-c duration] (reader C.S. duration (in loops))");
+ printf(" [-e duration] (writer C.S. duration (in loops))");
printf(" [-v] (verbose output)");
printf(" [-a cpu#] [-a cpu#]... (affinity)");
printf("\n");
printf(" [-v] (verbose output)");
printf(" [-a cpu#] [-a cpu#]... (affinity)");
printf("\n");
@@
-326,6
+343,13
@@
int main(int argc, char **argv)
}
wdelay = atol(argv[++i]);
break;
}
wdelay = atol(argv[++i]);
break;
+ case 'e':
+ if (argc < i + 2) {
+ show_usage(argc, argv);
+ return -1;
+ }
+ wduration = atol(argv[++i]);
+ break;
case 'v':
verbose_mode = 1;
break;
case 'v':
verbose_mode = 1;
break;
This page took
0.024573 seconds
and
4
git commands to generate.