From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2B4CBA09FF for ; Tue, 5 Jan 2021 06:15:40 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB26D1607B6; Tue, 5 Jan 2021 06:15:39 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 7493E1607A1; Tue, 5 Jan 2021 06:15:38 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B1BA3101E; Mon, 4 Jan 2021 21:15:37 -0800 (PST) Received: from net-x86-dell-8268.shanghai.arm.com (net-x86-dell-8268.shanghai.arm.com [10.169.210.127]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1FADF3F719; Mon, 4 Jan 2021 21:15:33 -0800 (PST) From: Feifei Wang To: Harry van Haaren , Nikhil Rao , Pavan Nikhilesh Cc: dev@dpdk.org, jerinj@marvell.com, nd@arm.com, Feifei Wang , pbhagavatula@marvell.com, stable@dpdk.org, Ruifeng Wang , Honnappa Nagarahalli Date: Tue, 5 Jan 2021 13:14:01 +0800 Message-Id: <20210105051401.435393-1-feifei.wang2@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201221053454.47307-1-feifei.wang2@arm.com> References: <20201221053454.47307-1-feifei.wang2@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v3] examples/eventdev: refactor ethdev port stop X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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: 085edac2ca38 ("examples/eventdev_pipeline: support Tx adapter") Cc: pbhagavatula@marvell.com Cc: stable@dpdk.org Suggested-by: Ruifeng Wang Signed-off-by: Feifei Wang Reviewed-by: Ruifeng Wang Reviewed-by: Honnappa Nagarahalli Acked-by: Harry van Haaren --- v2: 1. Delete unused variable to fix build error 2. Reduce commit message length to fix coding style issues v3: 1. Title improvement (Van Haaren) examples/eventdev_pipeline/main.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/examples/eventdev_pipeline/main.c b/examples/eventdev_pipeline/main.c index 823f8b51c..fdbaf667b 100644 --- a/examples/eventdev_pipeline/main.c +++ b/examples/eventdev_pipeline/main.c @@ -280,7 +280,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); @@ -291,17 +290,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); - if (rte_eth_dev_stop(portid) < 0) - printf("Failed to stop port %u", portid); - } - - rte_eal_mp_wait_lcore(); - } if (signum == SIGTSTP) rte_event_dev_dump(0, stdout); @@ -465,6 +453,10 @@ main(int argc, char **argv) } RTE_ETH_FOREACH_DEV(portid) { + rte_event_eth_rx_adapter_stop(portid); + rte_event_eth_tx_adapter_stop(portid); + if (rte_eth_dev_stop(portid) < 0) + printf("Failed to stop port %u", portid); rte_eth_dev_close(portid); } -- 2.25.1