From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50067.outbound.protection.outlook.com [40.107.5.67]) by dpdk.org (Postfix) with ESMTP id C1232DED for ; Tue, 30 Oct 2018 01:42:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6c3OxnnO36uxakNzh0cpsciiR000L4hUnsGtxUAxu8E=; b=hVmfDNJX9CjRql2ULlEeqgZyDIB4Dim+qdFP/hpgfM0SGf35JAzlN4aZmSjZudJIJk4UGeW+TNQiI5zzf33Lc4/hu4v0HSnB2r+Z6BfkX80KT70AObOnLkBgySUIl5b/iASbB+7GHAJ5F8Yh60MNdb1dorNkimf60YBRrvChgR4= Received: from DB7PR08MB3385.eurprd08.prod.outlook.com (20.176.238.90) by DB7PR08MB3066.eurprd08.prod.outlook.com (52.134.110.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.26; Tue, 30 Oct 2018 00:42:17 +0000 Received: from DB7PR08MB3385.eurprd08.prod.outlook.com ([fe80::b076:664:ea92:5b79]) by DB7PR08MB3385.eurprd08.prod.outlook.com ([fe80::b076:664:ea92:5b79%2]) with mapi id 15.20.1273.027; Tue, 30 Oct 2018 00:42:17 +0000 From: "Phil Yang (Arm Technology China)" To: "Phil Yang (Arm Technology China)" , "dev@dpdk.org" CC: nd Thread-Topic: [dpdk-dev] [PATCH v2] test/pmd_ring: release ring resources after test Thread-Index: AQHUZ5yev5+ALXPhWUKv82TqNzVB5KU3AuUA Date: Tue, 30 Oct 2018 00:42:17 +0000 Message-ID: References: <1539946839-12996-2-git-send-email-phil.yang@arm.com> <1539947526-13271-1-git-send-email-phil.yang@arm.com> In-Reply-To: <1539947526-13271-1-git-send-email-phil.yang@arm.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Phil.Yang@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR08MB3066; 6:aoMZT67C4wreGqZS9p3eDiYsdgJg0tzx+zgxOEATKvpwSCuHd9W7de+QBY7EA1cndlH+JAM17ptJDKMHfDAX/X/Qt6QHwL8XFFbXmyH7PkJ6H0v1sc/2CwoGldB/R2OcwlspQg1gGWyZVdB5Z7HrkiYT6kTRcfZCl4nProjFiw+otpbcs7sz4iWdHqisCE8nDkoaneXWm+COcL98Gh6/QqA61/ckoxuXoS02RSk7GHGfDmeIQz6QLQ3FkZ4qAU2XhdyN2qnCzDHWn5IkOlGzXkWYYe0zEkxUnqoE5MPVde8SzNHbLLONd9iUxJ1qNM5dClPCieT/0u4jaDJP1MtRyRZ+XCA9BfOblePzncLWE9y6asqCISpXMa7K6+2jH2lL7hBBbrw4vw/DxOQg8t+HqtaOID7d6tuL5JLYcZOc6lD9qi/S5QVqovvxX28+9mzB6PrxRT3fTSld7j0ZDUnBGg==; 5:+6f3i32cD6+exTDWrd3MA30AT0hGaNSz64Qvaf5C9oaW1TRrDgZ1csRuegoicA+di0iMvk491EKxFE5boTsCalqNvStbEmieEEGsTpeVVrZSoU1ALxDf7d6IiQPgD5DrTNpRY53w9WZiVHaCunx/1jVDC9KR6/cestaTmtDn0Go=; 7:lbIS06b2UxLgmfdpdWE6eypC7HbeDJ/ft9YDCN4a1Zf31GyA2XYNf0ZwUPrCXD8AXVVc/03HRL6dyZHLRanu9V9gk2MtTVbWlxSVtjN7krs+EaRGCP0XyXzf6YGiY1T9LcL7O/H6C7/cWU3xitnffA== x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-ms-office365-filtering-correlation-id: dbe3b265-2be8-4b6e-8bb8-08d63e008aeb x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB7PR08MB3066; x-ms-traffictypediagnostic: DB7PR08MB3066: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231382)(944501410)(52105095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:DB7PR08MB3066; BCL:0; PCL:0; RULEID:; SRVR:DB7PR08MB3066; x-forefront-prvs: 08417837C5 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(376002)(39860400002)(346002)(366004)(396003)(199004)(189003)(13464003)(74316002)(81156014)(25786009)(14454004)(26005)(186003)(33656002)(4326008)(53936002)(305945005)(72206003)(68736007)(6246003)(81166006)(5660300001)(446003)(476003)(11346002)(6436002)(5250100002)(486006)(7736002)(2906002)(2501003)(316002)(106356001)(9686003)(105586002)(256004)(110136005)(5024004)(14444005)(55016002)(229853002)(7696005)(71200400001)(86362001)(66066001)(8936002)(97736004)(2900100001)(71190400001)(55236004)(478600001)(76176011)(3846002)(6506007)(102836004)(99286004)(53546011)(6116002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR08MB3066; H:DB7PR08MB3385.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: L6pZtSSU+r22el0fiQ52z+TIRPSX9R6W9VdRe7U+Jc3VTSI4enccYbw1V6gTFb9CNSTpQuef0qowNVVq9vMlWFi1YnaD00FqnKYDiRi4ot4KULAcu7sswxOywu/VR8uAlChZReXNfHRGMfAA7fUrNP+/l8I6Ga79mz0a1rhOuHqv2k389/h5GTbOOaS3WNETd1q6P2E70wmX/jxqSdhbri4Rvg5fRpwjrw+v7dIFBBErEDkMKv4QsFm8QAi0mOeiRm3fs3wCVjFjw0m5pNKBw4O+H/eQDlJCBtLBiPnR/oclFeGfAjfFpiIwpCIN45eCJTACbdPqbY8NPYqAVGtr0U4rSWlkC5omSqIsNWZ+gXM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: dbe3b265-2be8-4b6e-8bb8-08d63e008aeb X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2018 00:42:17.0337 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3066 Subject: Re: [dpdk-dev] [PATCH v2] test/pmd_ring: release ring resources after test 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: , X-List-Received-Date: Tue, 30 Oct 2018 00:42:19 -0000 Hi, The commit 6e20a08 ("test/pmd_ring: restructure and cleanup") has already f= ixed this issue. Abandon this one. Thanks, Phil Yang > -----Original Message----- > From: dev On Behalf Of Phil Yang > Sent: Friday, October 19, 2018 7:12 PM > To: dev@dpdk.org > Cc: nd > Subject: [dpdk-dev] [PATCH v2] test/pmd_ring: release ring resources afte= r test >=20 > Need to release the port and the ring resources after test. Otherwise, it= will > cause failure to allocate memory when reentry the test. >=20 > Fixes: 4ea3801 ("app/test: fix ring unit test") >=20 > Signed-off-by: Phil Yang > Reviewed-by: Gavin Hu > --- > test/test/test_pmd_ring.c | 100 ++++++++++++++++++++++++++++------------= ---- > -- > 1 file changed, 62 insertions(+), 38 deletions(-) >=20 > diff --git a/test/test/test_pmd_ring.c b/test/test/test_pmd_ring.c index > 19d7d20..f332df9 100644 > --- a/test/test/test_pmd_ring.c > +++ b/test/test/test_pmd_ring.c > @@ -7,15 +7,16 @@ >=20 > #include > #include > - > -static struct rte_mempool *mp; > -static int tx_porta, rx_portb, rxtx_portc, rxtx_portd, rxtx_porte; > +#include >=20 > #define SOCKET0 0 > #define RING_SIZE 256 > #define NUM_RINGS 2 > #define NB_MBUF 512 > +#define NUM_PORTS 5 >=20 > +static struct rte_mempool *mp; > +static int ports[NUM_PORTS]; >=20 > static int > test_ethdev_configure_port(int port) > @@ -64,18 +65,19 @@ test_send_basic_packets(void) > struct rte_mbuf *pbufs[RING_SIZE]; > int i; >=20 > - printf("Testing send and receive RING_SIZE/2 packets (tx_porta -> > rx_portb)\n"); > + printf("Testing send and receive RING_SIZE/2 " > + "packets (ports[0] -> ports[1])\n"); >=20 > for (i =3D 0; i < RING_SIZE/2; i++) > pbufs[i] =3D &bufs[i]; >=20 > - if (rte_eth_tx_burst(tx_porta, 0, pbufs, RING_SIZE/2) < RING_SIZE/2) { > - printf("Failed to transmit packet burst port %d\n", tx_porta); > + if (rte_eth_tx_burst(ports[0], 0, pbufs, RING_SIZE/2) < RING_SIZE/2) { > + printf("Failed to transmit packet burst port %d\n", ports[0]); > return -1; > } >=20 > - if (rte_eth_rx_burst(rx_portb, 0, pbufs, RING_SIZE) !=3D RING_SIZE/2) { > - printf("Failed to receive packet burst on port %d\n", rx_portb); > + if (rte_eth_rx_burst(ports[1], 0, pbufs, RING_SIZE) !=3D RING_SIZE/2) { > + printf("Failed to receive packet burst on port %d\n", ports[1]); > return -1; > } >=20 > @@ -95,7 +97,8 @@ test_send_basic_packets_port(int port) > struct rte_mbuf *pbufs[RING_SIZE]; > int i; >=20 > - printf("Testing send and receive RING_SIZE/2 packets (cmdl_port0 -> > cmdl_port0)\n"); > + printf("Testing send and receive RING_SIZE/2 packets" > + "(cmdl_port0 -> cmdl_port0)\n"); >=20 > for (i =3D 0; i < RING_SIZE/2; i++) > pbufs[i] =3D &bufs[i]; > @@ -232,8 +235,10 @@ test_pmd_ring_pair_create_attach(int portd, int port= e) > return -1; > } >=20 > - if ((rte_eth_rx_queue_setup(portd, 0, RING_SIZE, SOCKET0, NULL, mp) < > 0) > - || (rte_eth_rx_queue_setup(porte, 0, RING_SIZE, SOCKET0, > NULL, mp) < 0)) { > + if ((rte_eth_rx_queue_setup(portd, 0, RING_SIZE, > + SOCKET0, NULL, mp) < 0) > + || (rte_eth_rx_queue_setup(porte, 0, RING_SIZE, > + SOCKET0, NULL, mp) < 0)) { > printf("RX queue setup failed\n"); > return -1; > } > @@ -388,9 +393,6 @@ test_pmd_ring_pair_create_attach(int portd, int porte= ) > return -1; > } >=20 > - rte_eth_dev_stop(portd); > - rte_eth_dev_stop(porte); > - > return 0; > } >=20 > @@ -400,6 +402,7 @@ test_pmd_ring(void) > struct rte_ring *rxtx[NUM_RINGS]; > int port, cmdl_port0 =3D -1; > uint8_t nb_ports; > + char port_name[RTE_ETH_NAME_MAX_LEN]; >=20 > nb_ports =3D rte_eth_dev_count_avail(); > printf("nb_ports=3D%d\n", (int)nb_ports); @@ -409,29 +412,36 @@ > test_pmd_ring(void) > * > * Test with the command line option --vdev=3Dnet_ring0 to test > rte_pmd_ring_devinit. > */ > - rxtx[0] =3D rte_ring_create("R0", RING_SIZE, SOCKET0, > RING_F_SP_ENQ|RING_F_SC_DEQ); > + rxtx[0] =3D rte_ring_create("R0", RING_SIZE, SOCKET0, > + RING_F_SP_ENQ|RING_F_SC_DEQ); > if (rxtx[0] =3D=3D NULL) { > printf("rte_ring_create R0 failed"); > return -1; > } >=20 > - rxtx[1] =3D rte_ring_create("R1", RING_SIZE, SOCKET0, > RING_F_SP_ENQ|RING_F_SC_DEQ); > + rxtx[1] =3D rte_ring_create("R1", RING_SIZE, SOCKET0, > + RING_F_SP_ENQ|RING_F_SC_DEQ); > if (rxtx[1] =3D=3D NULL) { > printf("rte_ring_create R1 failed"); > return -1; > } >=20 > - tx_porta =3D rte_eth_from_rings("net_ringa", rxtx, NUM_RINGS, rxtx, > NUM_RINGS, SOCKET0); > - rx_portb =3D rte_eth_from_rings("net_ringb", rxtx, NUM_RINGS, rxtx, > NUM_RINGS, SOCKET0); > - rxtx_portc =3D rte_eth_from_rings("net_ringc", rxtx, NUM_RINGS, rxtx, > NUM_RINGS, SOCKET0); > - rxtx_portd =3D rte_eth_from_rings("net_ringd", rxtx, NUM_RINGS, rxtx, > NUM_RINGS, SOCKET0); > - rxtx_porte =3D rte_eth_from_rings("net_ringe", rxtx, NUM_RINGS, rxtx, > NUM_RINGS, SOCKET0); > + ports[0] =3D rte_eth_from_rings("net_ringa", rxtx, > + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); > + ports[1] =3D rte_eth_from_rings("net_ringb", rxtx, > + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); > + ports[2] =3D rte_eth_from_rings("net_ringc", rxtx, > + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); > + ports[3] =3D rte_eth_from_rings("net_ringd", rxtx, > + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); > + ports[4] =3D rte_eth_from_rings("net_ringe", rxtx, > + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); >=20 > - printf("tx_porta=3D%d rx_portb=3D%d rxtx_portc=3D%d rxtx_portd=3D%d > rxtx_porte=3D%d\n", > - tx_porta, rx_portb, rxtx_portc, rxtx_portd, rxtx_porte); > + printf("ports[0]=3D%d ports[1]=3D%d ports[2]=3D%d ports[3]=3D%d > ports[4]=3D%d\n", > + ports[0], ports[1], ports[2], ports[3], ports[4]); >=20 > - if ((tx_porta =3D=3D -1) || (rx_portb =3D=3D -1) || (rxtx_portc =3D=3D = -1) > - || (rxtx_portd =3D=3D -1) || (rxtx_porte =3D=3D -1)) { > + if ((ports[0] =3D=3D -1) || (ports[1] =3D=3D -1) || (ports[2] =3D=3D -1= ) > + || (ports[3] =3D=3D -1) || (ports[4] =3D=3D -1)) { > printf("rte_eth_from rings failed\n"); > return -1; > } > @@ -441,37 +451,35 @@ test_pmd_ring(void) > if (mp =3D=3D NULL) > return -1; >=20 > - if ((tx_porta >=3D RTE_MAX_ETHPORTS) || (rx_portb >=3D > RTE_MAX_ETHPORTS) > - || (rxtx_portc >=3D RTE_MAX_ETHPORTS) > - || (rxtx_portd >=3D RTE_MAX_ETHPORTS) > - || (rxtx_porte >=3D RTE_MAX_ETHPORTS)) { > + if ((ports[0] >=3D RTE_MAX_ETHPORTS) > + || (ports[1] >=3D RTE_MAX_ETHPORTS) > + || (ports[2] >=3D RTE_MAX_ETHPORTS) > + || (ports[3] >=3D RTE_MAX_ETHPORTS) > + || (ports[4] >=3D RTE_MAX_ETHPORTS)) { > printf(" port exceed max eth ports\n"); > return -1; > } >=20 > - if (test_ethdev_configure_port(tx_porta) < 0) > + if (test_ethdev_configure_port(ports[0]) < 0) > return -1; >=20 > - if (test_ethdev_configure_port(rx_portb) < 0) > + if (test_ethdev_configure_port(ports[1]) < 0) > return -1; >=20 > - if (test_ethdev_configure_port(rxtx_portc) < 0) > + if (test_ethdev_configure_port(ports[2]) < 0) > return -1; >=20 > if (test_send_basic_packets() < 0) > return -1; >=20 > - if (test_get_stats(rxtx_portc) < 0) > + if (test_get_stats(ports[2]) < 0) > return -1; >=20 > - if (test_stats_reset(rxtx_portc) < 0) > + if (test_stats_reset(ports[2]) < 0) > return -1; >=20 > - rte_eth_dev_stop(tx_porta); > - rte_eth_dev_stop(rx_portb); > - rte_eth_dev_stop(rxtx_portc); >=20 > - if (test_pmd_ring_pair_create_attach(rxtx_portd, rxtx_porte) < 0) > + if (test_pmd_ring_pair_create_attach(ports[3], ports[4]) < 0) > return -1; >=20 > /* find a port created with the --vdev=3Dnet_ring0 command line option = */ > @@ -495,7 +503,23 @@ test_pmd_ring(void) > if (test_get_stats(cmdl_port0) < 0) > return -1; > rte_eth_dev_stop(cmdl_port0); > + rte_eth_dev_get_name_by_port(cmdl_port0, port_name); > + rte_vdev_uninit(port_name); > } > + > + /* release ports and rings resources */ > + if (mp !=3D NULL) > + rte_mempool_free(mp); > + > + for (int i =3D 0; i < NUM_PORTS; i++) { > + rte_eth_dev_stop(ports[i]); > + rte_eth_dev_get_name_by_port(ports[i], port_name); > + rte_vdev_uninit(port_name); > + } > + > + for (int i =3D 0; i < NUM_RINGS; i++) > + rte_ring_free(rxtx[i]); > + > return 0; > } >=20 > -- > 2.7.4