perf: Add signal handlers
Perf tool doesn't have handlers for SIGINT and SIGTERM signals, so when the tool is killed with e.g. ctrl-c all SPDK and transport resources are destroyed ungracefully. In the case of RDMA we may have IO requests inflight and if the request is processed by the driver when the corresponding MR is destroyed by the kernel, it may cause an error on the target side. Such errors are not harmful but it is better to have a graceful shutdown procedure. Fixes issue #1549 Signed-off-by: Alexey Marchuk <alexeymar@mellanox.com> Change-Id: I7818a4705d2b5cf4a5f3ca4745c62392312d22d2 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5869 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: <dongx.yi@intel.com> Reviewed-by: Michael Haeuptle <michaelhaeuptle@gmail.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
7fdf829cd7
commit
59d50e1f1c
@ -4,7 +4,7 @@
|
||||
* Copyright (c) Intel Corporation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2019-2020 Mellanox Technologies LTD. All rights reserved.
|
||||
* Copyright (c) 2019-2021 Mellanox Technologies LTD. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -2464,6 +2464,35 @@ nvme_poll_ctrlrs(void *arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
g_exit = true;
|
||||
}
|
||||
|
||||
static int
|
||||
setup_sig_handlers(void)
|
||||
{
|
||||
struct sigaction sigact = {};
|
||||
int rc;
|
||||
|
||||
sigemptyset(&sigact.sa_mask);
|
||||
sigact.sa_handler = sig_handler;
|
||||
rc = sigaction(SIGINT, &sigact, NULL);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "sigaction(SIGINT) failed, errno %d (%s)\n", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = sigaction(SIGTERM, &sigact, NULL);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "sigaction(SIGTERM) failed, errno %d (%s)\n", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int rc;
|
||||
@ -2501,6 +2530,12 @@ int main(int argc, char **argv)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
rc = setup_sig_handlers();
|
||||
if (rc != 0) {
|
||||
rc = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
g_tsc_rate = spdk_get_ticks_hz();
|
||||
|
||||
if (register_workers() != 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user