perftest: fix premature exit when select() is interrupted by SIGALRM #369
+33
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The perftest framework makes extensive use of alarm() to control test duration (--duration) and to schedule periodic tasks.
Functions such as
run_iter_bw(),run_iter_lat_send(), andrun_iter_bi()install a handler viasignal(SIGALRM, catch_alarm)when the -D option is used, and then set an alarm.In
run_iter_bw_server()andrun_iter_bi(), a watchdog is also installed in iterations mode viasignal(SIGALRM, check_alive)followed byalarm(60)to detect stalled tests.In the problematic case,
run_iter_bi()with the -e option invokesctx_notify_send_recv_events(), which performs aselect()on two file descriptors:ctx->recv_channel->fd— CQ receive completion channelctx->send_channel->fd— CQ send completion channelWhen a completion event is generated, the kernel marks the corresponding file descriptor readable and
select()returns.However, due to low processing speed on the some NICs, no completion event is generated within 60 seconds(test case is not finished under high pressure test). The watchdog
alarm()fires, delivering SIGALRM, which interrupts the blockingselect()call. The function then exits with an error instead of retrying.This behavior exposes a robustness issue in perftest: SIGALRM in this context is meant only as a check-alive signal, not as a fatal condition. A
select()call interrupted by SIGALRM should be restarted rather than causing an unexpected termination.This patch updates perftest to properly handle EINTR by retrying
select()when it is interrupted by SIGALRM, ensuring correct behavior even under slow device processing conditions.