@@ -38,7 +38,7 @@ static int opt_modulo, verbose;
3838static int opt_yield , opt_signal , opt_sleep ,
3939 opt_disable_rseq , opt_threads = 200 ,
4040 opt_disable_mod = 0 , opt_test = 's' ;
41-
41+ static bool opt_rseq_legacy ;
4242static long long opt_reps = 5000 ;
4343
4444static __thread __attribute__((tls_model ("initial-exec" )))
@@ -281,9 +281,12 @@ unsigned int yield_mod_cnt, nr_abort;
281281 } \
282282}
283283
284+ #define rseq_no_glibc true
285+
284286#else
285287
286288#define printf_verbose (fmt , ...)
289+ #define rseq_no_glibc false
287290
288291#endif /* BENCHMARK */
289292
@@ -481,7 +484,7 @@ void *test_percpu_spinlock_thread(void *arg)
481484 long long i , reps ;
482485
483486 if (!opt_disable_rseq && thread_data -> reg &&
484- rseq_register_current_thread ( ))
487+ __rseq_register_current_thread ( rseq_no_glibc , opt_rseq_legacy ))
485488 abort ();
486489 reps = thread_data -> reps ;
487490 for (i = 0 ; i < reps ; i ++ ) {
@@ -558,7 +561,7 @@ void *test_percpu_inc_thread(void *arg)
558561 long long i , reps ;
559562
560563 if (!opt_disable_rseq && thread_data -> reg &&
561- rseq_register_current_thread ( ))
564+ __rseq_register_current_thread ( rseq_no_glibc , opt_rseq_legacy ))
562565 abort ();
563566 reps = thread_data -> reps ;
564567 for (i = 0 ; i < reps ; i ++ ) {
@@ -712,7 +715,7 @@ void *test_percpu_list_thread(void *arg)
712715 long long i , reps ;
713716 struct percpu_list * list = (struct percpu_list * )arg ;
714717
715- if (!opt_disable_rseq && rseq_register_current_thread ( ))
718+ if (!opt_disable_rseq && __rseq_register_current_thread ( rseq_no_glibc , opt_rseq_legacy ))
716719 abort ();
717720
718721 reps = opt_reps ;
@@ -895,7 +898,7 @@ void *test_percpu_buffer_thread(void *arg)
895898 long long i , reps ;
896899 struct percpu_buffer * buffer = (struct percpu_buffer * )arg ;
897900
898- if (!opt_disable_rseq && rseq_register_current_thread ( ))
901+ if (!opt_disable_rseq && __rseq_register_current_thread ( rseq_no_glibc , opt_rseq_legacy ))
899902 abort ();
900903
901904 reps = opt_reps ;
@@ -1105,7 +1108,7 @@ void *test_percpu_memcpy_buffer_thread(void *arg)
11051108 long long i , reps ;
11061109 struct percpu_memcpy_buffer * buffer = (struct percpu_memcpy_buffer * )arg ;
11071110
1108- if (!opt_disable_rseq && rseq_register_current_thread ( ))
1111+ if (!opt_disable_rseq && __rseq_register_current_thread ( rseq_no_glibc , opt_rseq_legacy ))
11091112 abort ();
11101113
11111114 reps = opt_reps ;
@@ -1258,7 +1261,7 @@ void *test_membarrier_worker_thread(void *arg)
12581261 const int iters = opt_reps ;
12591262 int i ;
12601263
1261- if (rseq_register_current_thread ( )) {
1264+ if (__rseq_register_current_thread ( rseq_no_glibc , opt_rseq_legacy )) {
12621265 fprintf (stderr , "Error: rseq_register_current_thread(...) failed(%d): %s\n" ,
12631266 errno , strerror (errno ));
12641267 abort ();
@@ -1323,7 +1326,7 @@ void *test_membarrier_manager_thread(void *arg)
13231326 intptr_t expect_a = 0 , expect_b = 0 ;
13241327 int cpu_a = 0 , cpu_b = 0 ;
13251328
1326- if (rseq_register_current_thread ( )) {
1329+ if (__rseq_register_current_thread ( rseq_no_glibc , opt_rseq_legacy )) {
13271330 fprintf (stderr , "Error: rseq_register_current_thread(...) failed(%d): %s\n" ,
13281331 errno , strerror (errno ));
13291332 abort ();
@@ -1475,6 +1478,7 @@ static void show_usage(int argc, char **argv)
14751478 printf (" [-D M] Disable rseq for each M threads\n" );
14761479 printf (" [-T test] Choose test: (s)pinlock, (l)ist, (b)uffer, (m)emcpy, (i)ncrement, membarrie(r)\n" );
14771480 printf (" [-M] Push into buffer and memcpy buffer with memory barriers.\n" );
1481+ printf (" [-O] Test with optimized RSEQ\n" );
14781482 printf (" [-v] Verbose output.\n" );
14791483 printf (" [-h] Show this help.\n" );
14801484 printf ("\n" );
@@ -1602,6 +1606,9 @@ int main(int argc, char **argv)
16021606 case 'M' :
16031607 opt_mo = RSEQ_MO_RELEASE ;
16041608 break ;
1609+ case 'L' :
1610+ opt_rseq_legacy = true;
1611+ break ;
16051612 default :
16061613 show_usage (argc , argv );
16071614 goto error ;
@@ -1618,7 +1625,7 @@ int main(int argc, char **argv)
16181625 if (set_signal_handler ())
16191626 goto error ;
16201627
1621- if (!opt_disable_rseq && rseq_register_current_thread ( ))
1628+ if (!opt_disable_rseq && __rseq_register_current_thread ( rseq_no_glibc , opt_rseq_legacy ))
16221629 goto error ;
16231630 if (!opt_disable_rseq && !rseq_validate_cpu_id ()) {
16241631 fprintf (stderr , "Error: cpu id getter unavailable\n" );
0 commit comments