@samitouri / QOSamiQemu / commits / 39678e16e8

tests/tcg/multiarch: Improve mutator randomness

Currently mutators perform the same actions, because the RNG seed is derived from the current time in seconds. Mix in thread ID. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20260706165445.57418-3-iii@linux.ibm.com>

Ilya Leoshkevich committed Jul 6, 2026 at 18:51 UTC 39678e16e805d92ebaa465172bd92f5c245a1756
1 file changed +2 -1
tests/tcg/multiarch/vma-pthread.c
+2 -1
@@ -11,6 +11,7 @@
11 * pages, which are guaranteed to have the respective protection bit set.
12 * Two mutator threads change the non-fixed protection bits randomly.
13 */
14 +#define _GNU_SOURCE
15 #include <assert.h>
16 #include <fcntl.h>
17 #include <pthread.h>
@@ -121,7 +122,7 @@ static void *thread_mutate(void *arg)
122 unsigned int seed;
123 int prot, ret;
124
124 - seed = (unsigned int)time(NULL);
125 + seed = (unsigned int)time(NULL) + (unsigned int)gettid();
126 for (i = 0; i < 10000; i++) {
127 start_idx = rand_r(&seed) & PAGE_IDX_MASK;
128 end_idx = rand_r(&seed) & PAGE_IDX_MASK;