The test uses a signal-handler to periodically print a line of report. Snip libc info: <quote> 24.4.6 Signal Handling and Nonreentrant Functions Handler functions usually don't do very much. The best practice is to write a handler that does nothing but set an external variable that the program checks regularly, and leave all serious work to the program. </quote> The current codebase violates the above and is deadlock prone. The mutexes taken by the printf functions called from the signal handler might be held by activity conducted by the main thread.
This commit fixes this by setting a flag in the signal handler and handle the printout in the mainloop of the test. Signed-off-by: Hans Westgaard Ry <hans.westgaard...@oracle.com> Reviewed-by: HÃ¥kon Bugge <haakon.bu...@oracle.com> Reviewed-by: Knut Omang <knut.om...@oracle.com> --- src/perftest_resources.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/perftest_resources.c b/src/perftest_resources.c index cb915e0..4d8e6c0 100755 --- a/src/perftest_resources.c +++ b/src/perftest_resources.c @@ -25,6 +25,12 @@ static enum ibv_wr_opcode opcode_atomic_array[] = {IBV_WR_ATOMIC_CMP_AND_SWP,IBV struct perftest_parameters* duration_param; struct check_alive_data check_alive_data; +/* + * Flag to trig call to print_report_bw + * The flag is set in signal_handler and tested/reset in run_iter_bw_infinitely + */ +static volatile int trig_print_report_bw = 0; + /****************************************************************************** * Beginning @@ -3214,7 +3220,15 @@ int run_iter_bw_infinitely(struct pingpong_context *ctx,struct perftest_paramete /* main loop for posting */ while (1) { - + if (trig_print_report_bw) { + duration_param->tcompleted[0] = get_cycles(); + print_report_bw(duration_param,NULL); + duration_param->iters = 0; + alarm(duration_param->duration); + duration_param->tposted[0] = get_cycles(); + trig_print_report_bw = 0; + } + /* main loop to run over all the qps and post each time n messages */ for (index =0 ; index < num_of_qps ; index++) { @@ -4213,11 +4227,7 @@ void check_alive(int sig) ******************************************************************************/ void catch_alarm_infintely(int sig) { - duration_param->tcompleted[0] = get_cycles(); - print_report_bw(duration_param,NULL); - duration_param->iters = 0; - alarm(duration_param->duration); - duration_param->tposted[0] = get_cycles(); + trig_print_report_bw = 1; } /****************************************************************************** -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html