From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 19F69A00BE; Tue, 28 Apr 2020 13:19:14 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 769891D58A; Tue, 28 Apr 2020 13:19:13 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 0BCA31D573 for ; Tue, 28 Apr 2020 13:19:11 +0200 (CEST) IronPort-SDR: 6UGuDtm1tkYftPZI+sGRpEGX3x0ZpiHVE89IrlQBlUezgQTv8vSSOwKxrpx51VOBUdqzn1ZWw3 5oBg31VOHPVQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2020 04:19:11 -0700 IronPort-SDR: QIHWkdohctlNUm9lLH0UAX793p5grpDcppxGMjsMp0hHHO+oN3pjTkJP3KgjiseLXKY0EeLV4w 1eMDl2SE3VHA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,327,1583222400"; d="scan'208";a="275803773" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga002.jf.intel.com with ESMTP; 28 Apr 2020 04:19:10 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 28 Apr 2020 04:19:10 -0700 Received: from cdsmsx103.ccr.corp.intel.com (172.17.3.37) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 28 Apr 2020 04:19:09 -0700 Received: from cdsmsx102.ccr.corp.intel.com ([169.254.2.104]) by CDSMSX103.ccr.corp.intel.com ([169.254.5.221]) with mapi id 14.03.0439.000; Tue, 28 Apr 2020 19:19:07 +0800 From: "Xie, WeiX" To: "Burakov, Anatoly" , "dev@dpdk.org" CC: "Hunt, David" , "Pattan, Reshma" Thread-Topic: [dpdk-dev] [PATCH v2 2/2] l3fwd-power: implement proper shutdown handling Thread-Index: AQHWF8quamAcWKk5pUCl/mraqpO03aiOacow Date: Tue, 28 Apr 2020 11:19:06 +0000 Message-ID: <6FD6A7610D20924F885A4ECF34E8AC91045E7816@CDSMSX102.ccr.corp.intel.com> References: <854770a880777e7ad200481294a7aa5ac9a45f2d.1586361368.git.anatoly.burakov@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.17.6.105] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 2/2] l3fwd-power: implement proper shutdown handling X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Tested-by: Xie,WeiX < weix.xie@intel.com> Regards, Xie Wei -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Anatoly Burakov Sent: Tuesday, April 21, 2020 1:57 AM To: dev@dpdk.org Cc: Hunt, David ; Pattan, Reshma Subject: [dpdk-dev] [PATCH v2 2/2] l3fwd-power: implement proper shutdown h= andling Currently, shutdown for l3fwd-power application is all over the place and m= ay or may not happen either in the signal handler or in the main() function= . Fix this so that the signal handler will only set the exit variable, ther= eby allowing all of the loops to end properly and proceed to deinitialize e= verything. Signed-off-by: Anatoly Burakov Acked-by: David Hunt Reviewed-by: Reshma Pattan --- Notes: v2: - rebase on top of latest master examples/l3fwd-power/main.c | 74 ++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c inde= x be50ec049..293b3da4a 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -422,41 +422,10 @@ static int is_done(void) static void signal_exit_no= w(int sigtype) { - unsigned lcore_id; - unsigned int portid; - int ret; - - if (sigtype =3D=3D SIGINT) { - if (app_mode =3D=3D APP_MODE_EMPTY_POLL || - app_mode =3D=3D APP_MODE_TELEMETRY) - quit_signal =3D true; =20 + if (sigtype =3D=3D SIGINT) + quit_signal =3D true; =20 - for (lcore_id =3D 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { - if (rte_lcore_is_enabled(lcore_id) =3D=3D 0) - continue; - - /* init power management library */ - ret =3D rte_power_exit(lcore_id); - if (ret) - rte_exit(EXIT_FAILURE, "Power management " - "library de-initialization failed on " - "core%u\n", lcore_id); - } - - if (app_mode !=3D APP_MODE_EMPTY_POLL) { - RTE_ETH_FOREACH_DEV(portid) { - if ((enabled_port_mask & (1 << portid)) =3D=3D 0) - continue; - - rte_eth_dev_stop(portid); - rte_eth_dev_close(portid); - } - } - } - - if (app_mode !=3D APP_MODE_EMPTY_POLL) - rte_exit(EXIT_SUCCESS, "User forced exit\n"); } =20 /* Freqency scale down timer callback */ @@ -1196,7 +1165,7 @@ main_loop(= __rte_unused void *dummy) else RTE_LOG(INFO, L3FWD_POWER, "RX interrupt won't enable.\n"); =20 - while (1) { + while (!is_done()) { stats[lcore_id].nb_iteration_looped++; =20 cur_tsc =3D rte_rdtsc(); @@ -1343,6 +1312,8 @@ main_loop(__rte_unused void *dummy) stats[lcore_id].sleep_time +=3D lcore_idle_hint; } } + + return 0; } =20 static int @@ -2080,6 +2051,26 @@ init_power_library(void) } return ret; } + +static int +deinit_power_library(void) +{ + unsigned int lcore_id; + int ret =3D 0; + + RTE_LCORE_FOREACH(lcore_id) { + /* deinit power management library */ + ret =3D rte_power_exit(lcore_id); + if (ret) { + RTE_LOG(ERR, POWER, + "Library deinitialization failed on core %u\n", + lcore_id); + return ret; + } + } + return ret; +} + static void update_telemetry(__rte_unused struct rte_timer *tim, __rte_unused void *arg) @@ -2530,8 +2521,23 @@ main(int argc, char **argv) return -1; } =20 + RTE_ETH_FOREACH_DEV(portid) + { + if ((enabled_port_mask & (1 << portid)) =3D=3D 0) + continue; + + rte_eth_dev_stop(portid); + rte_eth_dev_close(portid); + } + if (app_mode =3D=3D APP_MODE_EMPTY_POLL) rte_power_empty_poll_stat_free(); =20 + if (app_mode !=3D APP_MODE_TELEMETRY && deinit_power_library()) + rte_exit(EXIT_FAILURE, "deinit_power_library failed\n"); + + if (rte_eal_cleanup() < 0) + RTE_LOG(ERR, L3FWD_POWER, "EAL cleanup failed\n"); + return 0; } -- 2.17.1