Lines Matching refs:pair
186 pair->param = (pair->param ? pair->param : def); \
187 if (pair->param < low) \
189 if (pair->param > hi) \
202 static void tst_fzsync_pair_init(struct tst_fzsync_pair *pair) in tst_fzsync_pair_init() argument
219 static void tst_fzsync_pair_cleanup(struct tst_fzsync_pair *pair) in tst_fzsync_pair_cleanup() argument
221 if (pair->thread_b) { in tst_fzsync_pair_cleanup()
223 if (!pair->exit) { in tst_fzsync_pair_cleanup()
224 tst_atomic_store(1, &pair->exit); in tst_fzsync_pair_cleanup()
236 SAFE_PTHREAD_JOIN(pair->thread_b, NULL); in tst_fzsync_pair_cleanup()
237 pair->thread_b = 0; in tst_fzsync_pair_cleanup()
292 static void tst_fzsync_pair_reset(struct tst_fzsync_pair *pair, in tst_fzsync_pair_reset() argument
295 tst_fzsync_pair_cleanup(pair); in tst_fzsync_pair_reset()
297 tst_init_stat(&pair->diff_ss); in tst_fzsync_pair_reset()
298 tst_init_stat(&pair->diff_sa); in tst_fzsync_pair_reset()
299 tst_init_stat(&pair->diff_sb); in tst_fzsync_pair_reset()
300 tst_init_stat(&pair->diff_ab); in tst_fzsync_pair_reset()
301 tst_init_stat(&pair->spins_avg); in tst_fzsync_pair_reset()
302 pair->delay = 0; in tst_fzsync_pair_reset()
303 pair->sampling = pair->min_samples; in tst_fzsync_pair_reset()
305 pair->exec_loop = 0; in tst_fzsync_pair_reset()
307 pair->a_cntr = 0; in tst_fzsync_pair_reset()
308 pair->b_cntr = 0; in tst_fzsync_pair_reset()
309 pair->exit = 0; in tst_fzsync_pair_reset()
312 SAFE_PTHREAD_CREATE(&pair->thread_b, 0, tst_fzsync_thread_wrapper, &wrap_run_b); in tst_fzsync_pair_reset()
315 pair->exec_time_start = (float)tst_timeout_remaining(); in tst_fzsync_pair_reset()
336 static void tst_fzsync_pair_info(struct tst_fzsync_pair *pair) in tst_fzsync_pair_info() argument
339 pair->exec_loop, pair->delay_bias); in tst_fzsync_pair_info()
340 tst_fzsync_stat_info(pair->diff_ss, "ns", "start_a - start_b"); in tst_fzsync_pair_info()
341 tst_fzsync_stat_info(pair->diff_sa, "ns", "end_a - start_a"); in tst_fzsync_pair_info()
342 tst_fzsync_stat_info(pair->diff_sb, "ns", "end_b - start_b"); in tst_fzsync_pair_info()
343 tst_fzsync_stat_info(pair->diff_ab, "ns", "end_a - end_b"); in tst_fzsync_pair_info()
344 tst_fzsync_stat_info(pair->spins_avg, " ", "spins"); in tst_fzsync_pair_info()
489 static void tst_fzsync_pair_update(struct tst_fzsync_pair *pair) in tst_fzsync_pair_update() argument
491 float alpha = pair->avg_alpha; in tst_fzsync_pair_update()
493 float max_dev = pair->max_dev_ratio; in tst_fzsync_pair_update()
496 pair->delay = pair->delay_bias; in tst_fzsync_pair_update()
498 over_max_dev = pair->diff_ss.dev_ratio > max_dev in tst_fzsync_pair_update()
499 || pair->diff_sa.dev_ratio > max_dev in tst_fzsync_pair_update()
500 || pair->diff_sb.dev_ratio > max_dev in tst_fzsync_pair_update()
501 || pair->diff_ab.dev_ratio > max_dev in tst_fzsync_pair_update()
502 || pair->spins_avg.dev_ratio > max_dev; in tst_fzsync_pair_update()
504 if (pair->sampling > 0 || over_max_dev) { in tst_fzsync_pair_update()
505 tst_upd_diff_stat(&pair->diff_ss, alpha, in tst_fzsync_pair_update()
506 pair->a_start, pair->b_start); in tst_fzsync_pair_update()
507 tst_upd_diff_stat(&pair->diff_sa, alpha, in tst_fzsync_pair_update()
508 pair->a_end, pair->a_start); in tst_fzsync_pair_update()
509 tst_upd_diff_stat(&pair->diff_sb, alpha, in tst_fzsync_pair_update()
510 pair->b_end, pair->b_start); in tst_fzsync_pair_update()
511 tst_upd_diff_stat(&pair->diff_ab, alpha, in tst_fzsync_pair_update()
512 pair->a_end, pair->b_end); in tst_fzsync_pair_update()
513 tst_upd_stat(&pair->spins_avg, alpha, pair->spins); in tst_fzsync_pair_update()
514 if (pair->sampling > 0 && --pair->sampling == 0) { in tst_fzsync_pair_update()
516 tst_fzsync_pair_info(pair); in tst_fzsync_pair_update()
518 } else if (fabsf(pair->diff_ab.avg) >= 1) { in tst_fzsync_pair_update()
519 per_spin_time = fabsf(pair->diff_ab.avg) / MAX(pair->spins_avg.avg, 1.0f); in tst_fzsync_pair_update()
520 time_delay = drand48() * (pair->diff_sa.avg + pair->diff_sb.avg) in tst_fzsync_pair_update()
521 - pair->diff_sb.avg; in tst_fzsync_pair_update()
522 pair->delay += (int)(time_delay / per_spin_time); in tst_fzsync_pair_update()
524 if (!pair->sampling) { in tst_fzsync_pair_update()
527 pair->max_dev_ratio); in tst_fzsync_pair_update()
529 (int)(pair->diff_sb.avg / per_spin_time) + pair->delay_bias, in tst_fzsync_pair_update()
530 (int)(pair->diff_sa.avg / per_spin_time) - pair->delay_bias); in tst_fzsync_pair_update()
531 tst_fzsync_pair_info(pair); in tst_fzsync_pair_update()
532 pair->sampling = -1; in tst_fzsync_pair_update()
534 } else if (!pair->sampling) { in tst_fzsync_pair_update()
536 tst_fzsync_pair_info(pair); in tst_fzsync_pair_update()
537 pair->sampling = -1; in tst_fzsync_pair_update()
540 pair->spins = 0; in tst_fzsync_pair_update()
602 static inline void tst_fzsync_wait_a(struct tst_fzsync_pair *pair) in tst_fzsync_wait_a() argument
604 tst_fzsync_pair_wait(&pair->a_cntr, &pair->b_cntr, NULL); in tst_fzsync_wait_a()
613 static inline void tst_fzsync_wait_b(struct tst_fzsync_pair *pair) in tst_fzsync_wait_b() argument
615 tst_fzsync_pair_wait(&pair->b_cntr, &pair->a_cntr, NULL); in tst_fzsync_wait_b()
629 static inline int tst_fzsync_run_a(struct tst_fzsync_pair *pair) in tst_fzsync_run_a() argument
632 float rem_p = 1 - tst_timeout_remaining() / pair->exec_time_start; in tst_fzsync_run_a()
634 if ((pair->exec_time_p * SAMPLING_SLICE < rem_p) in tst_fzsync_run_a()
635 && (pair->sampling > 0)) { in tst_fzsync_run_a()
638 pair->exec_loop, pair->min_samples); in tst_fzsync_run_a()
639 pair->sampling = 0; in tst_fzsync_run_a()
640 tst_fzsync_pair_info(pair); in tst_fzsync_run_a()
643 if (pair->exec_time_p < rem_p) { in tst_fzsync_run_a()
649 if (++pair->exec_loop > pair->exec_loops) { in tst_fzsync_run_a()
655 tst_atomic_store(exit, &pair->exit); in tst_fzsync_run_a()
656 tst_fzsync_wait_a(pair); in tst_fzsync_run_a()
659 tst_fzsync_pair_cleanup(pair); in tst_fzsync_run_a()
672 static inline int tst_fzsync_run_b(struct tst_fzsync_pair *pair) in tst_fzsync_run_b() argument
674 tst_fzsync_wait_b(pair); in tst_fzsync_run_b()
675 return !tst_atomic_load(&pair->exit); in tst_fzsync_run_b()
696 static inline void tst_fzsync_start_race_a(struct tst_fzsync_pair *pair) in tst_fzsync_start_race_a() argument
700 tst_fzsync_pair_update(pair); in tst_fzsync_start_race_a()
702 tst_fzsync_wait_a(pair); in tst_fzsync_start_race_a()
704 delay = pair->delay; in tst_fzsync_start_race_a()
708 tst_fzsync_time(&pair->a_start); in tst_fzsync_start_race_a()
717 static inline void tst_fzsync_end_race_a(struct tst_fzsync_pair *pair) in tst_fzsync_end_race_a() argument
719 tst_fzsync_time(&pair->a_end); in tst_fzsync_end_race_a()
720 tst_fzsync_pair_wait(&pair->a_cntr, &pair->b_cntr, &pair->spins); in tst_fzsync_end_race_a()
729 static inline void tst_fzsync_start_race_b(struct tst_fzsync_pair *pair) in tst_fzsync_start_race_b() argument
733 tst_fzsync_wait_b(pair); in tst_fzsync_start_race_b()
735 delay = pair->delay; in tst_fzsync_start_race_b()
739 tst_fzsync_time(&pair->b_start); in tst_fzsync_start_race_b()
748 static inline void tst_fzsync_end_race_b(struct tst_fzsync_pair *pair) in tst_fzsync_end_race_b() argument
750 tst_fzsync_time(&pair->b_end); in tst_fzsync_end_race_b()
751 tst_fzsync_pair_wait(&pair->b_cntr, &pair->a_cntr, &pair->spins); in tst_fzsync_end_race_b()
778 static inline void tst_fzsync_pair_add_bias(struct tst_fzsync_pair *pair, int change) in tst_fzsync_pair_add_bias() argument
780 if (pair->sampling > 0) in tst_fzsync_pair_add_bias()
781 pair->delay_bias += change; in tst_fzsync_pair_add_bias()