The handler called rte_exit(), rte_event_dev_dump() and (before the previous patch) printf(), none of which are async-signal-safe. rte_exit() in particular runs rte_eal_cleanup() and exit(), tearing down the EAL from signal context while the worker lcores are still running in it.
Set the done flag and let main() do the work: - The second-signal path becomes _exit(), which is async-signal-safe. This keeps the "hit ^C twice to give up on a clean shutdown" escape hatch without running exit handlers from the handler. - The --dump-dev dump on exit moves to main() after rte_eal_mp_wait_lcore(), where it also gets the real dev_id instead of the hardcoded 0. - SIGTSTP sets cdata.dump_dev_signal, which schedule_devices() already checks and drains on the scheduler lcore. That mechanism was present but nothing ever set the flag. Note this makes the SIGTSTP dump depend on a scheduler lcore being configured; there is no dump in configurations without one. dump_dev_signal is now written from signal context, so make it volatile sig_atomic_t. Unlike the rest of this series this one is not reported by -fanalyzer: the handler is registered in main() after rte_eal_init(), and the analyzer does not connect the registration to the handler body there. Found by inspection while auditing the neighbours. Signed-off-by: Stephen Hemminger <[email protected]> --- examples/eventdev_pipeline/main.c | 16 +++++++--------- examples/eventdev_pipeline/pipeline_common.h | 3 ++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/eventdev_pipeline/main.c b/examples/eventdev_pipeline/main.c index 65e0cd437c..80197b7c21 100644 --- a/examples/eventdev_pipeline/main.c +++ b/examples/eventdev_pipeline/main.c @@ -314,18 +314,13 @@ do_capability_setup(uint8_t eventdev_id) static void signal_handler(int signum) { - static uint8_t once; - - if (fdata->done) - rte_exit(1, "Exiting on signal %d\n", signum); - if ((signum == SIGINT || signum == SIGTERM) && !once) { - if (cdata.dump_dev) - rte_event_dev_dump(0, stdout); - once = 1; + if (signum == SIGINT || signum == SIGTERM) { + if (fdata->done) + _exit(1); fdata->done = 1; } if (signum == SIGTSTP) - rte_event_dev_dump(0, stdout); + cdata.dump_dev_signal = 1; } static inline uint64_t @@ -452,6 +447,9 @@ main(int argc, char **argv) rte_eal_mp_wait_lcore(); + if (cdata.dump_dev) + rte_event_dev_dump(dev_id, stdout); + if (!cdata.quiet && (port_stat(dev_id, worker_data[0].port_id) != (uint64_t)-ENOTSUP)) { printf("\nPort Workload distribution:\n"); diff --git a/examples/eventdev_pipeline/pipeline_common.h b/examples/eventdev_pipeline/pipeline_common.h index 7b8eb50240..131617cd5b 100644 --- a/examples/eventdev_pipeline/pipeline_common.h +++ b/examples/eventdev_pipeline/pipeline_common.h @@ -3,6 +3,7 @@ * Copyright 2017 Cavium, Inc. */ +#include <signal.h> #include <stdbool.h> #include <rte_eal.h> @@ -68,7 +69,7 @@ struct config_data { int enable_queue_priorities; int quiet; int dump_dev; - int dump_dev_signal; + volatile sig_atomic_t dump_dev_signal; int all_type_queues; unsigned int num_stages; unsigned int worker_cq_depth; -- 2.53.0

