Skip to content

Commit

Permalink
examples/eventdev: move ethdev stop to the end
Browse files Browse the repository at this point in the history
[ upstream commit f3527e0 ]

Move eth stop code from "signal_handler" function to the end of "main"
function. There are two reasons for this:

First, this improves code maintenance and makes code look simple and
clear. Based on this change, after receiving the interrupt signal,
"fdata->done" is set as 1. Then the main thread will wait all worker
lcores to jump out of the loop. Finally, the main thread will stop and
then close eth dev port.

Second, for older version, the main thread first stops eth dev port and
then waits the end of worker lcore. This may cause errors because it may
stop the eth dev port which worker lcores are using. This moving change
can fix this by waiting all worker threads to exit and then stop the
eth dev port.

In the meanwhile, remove wmb in signal_handler.

This is because when the main lcore receive the stop signal, it stores 1
into fdata->done. And then the worker lcores load "fdata->done" and jump
out of the loop to stop running. Nothing should be stored after updating
fdata->done, so the wmb is unnecessary.

Fixes: 085edac ("examples/eventdev_pipeline: support Tx adapter")

Suggested-by: Ruifeng Wang <ruifeng.wang@arm.com>
Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
  • Loading branch information
Feifeiarm authored and cpaelzer committed Feb 3, 2021
1 parent 02a5ce6 commit 035f49d
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions examples/eventdev_pipeline/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ static void
signal_handler(int signum)
{
static uint8_t once;
uint16_t portid;

if (fdata->done)
rte_exit(1, "Exiting on signal %d\n", signum);
Expand All @@ -324,16 +323,6 @@ signal_handler(int signum)
rte_event_dev_dump(0, stdout);
once = 1;
fdata->done = 1;
rte_smp_wmb();

RTE_ETH_FOREACH_DEV(portid) {
rte_event_eth_rx_adapter_stop(portid);
rte_event_eth_tx_adapter_stop(portid);
rte_eth_dev_stop(portid);
}

rte_eal_mp_wait_lcore();

}
if (signum == SIGTSTP)
rte_event_dev_dump(0, stdout);
Expand Down Expand Up @@ -484,6 +473,9 @@ main(int argc, char **argv)
}

RTE_ETH_FOREACH_DEV(portid) {
rte_event_eth_rx_adapter_stop(portid);
rte_event_eth_tx_adapter_stop(portid);
rte_eth_dev_stop(portid);
rte_eth_dev_close(portid);
}

Expand Down

0 comments on commit 035f49d

Please sign in to comment.