aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNadav Amit <namit@vmware.com>2016-10-10 03:36:47 -0700
committerFengguang Wu <fengguang.wu@intel.com>2016-10-12 10:54:24 +0800
commit0ef7ce5ec7bfaf524638c3db05b81986cccb150d (patch)
tree39e6fb03f2ece59ca0d696686a6a4adce84d9d08
parentdddafc918d897c2acfabaddb1dabc67e4284e2d0 (diff)
downloadvm-scalability-0ef7ce5ec7bfaf524638c3db05b81986cccb150d.tar.gz
Base random seed on thread ID instead on PID
The random seed was previously based on process ID. This caused the random multi-threaded benchmarks to mostly practice very strange behavior, in which all threads access the same memory, in some benchmarks in a lockstep behavior. Changing the getpid to gettid to get the expected behavior, which is also in line with the multi-process benchmarks. Signed-off-by: Nadav Amit <namit@vmware.com> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
-rw-r--r--usemem.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/usemem.c b/usemem.c
index 2de0dbd..2efff64 100644
--- a/usemem.c
+++ b/usemem.c
@@ -25,6 +25,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/shm.h>
+#include <sys/syscall.h>
#include "usemem_mincore.h"
#include "usemem_hugepages.h"
@@ -574,8 +575,9 @@ long do_units(void)
if (opt_detach)
detach();
+ /* Base the random seed on the thread ID for multithreaded tests */
if (opt_randomise)
- os_random_seed(time(0) ^ getpid(), &rand_data);
+ os_random_seed(time(0) ^ syscall(SYS_gettid), &rand_data);
if (!unit)
unit = bytes;