From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10083.outbound.protection.outlook.com [40.107.1.83]) by dpdk.org (Postfix) with ESMTP id BF57AF72 for ; Mon, 23 Jul 2018 08:12:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t9ypScrF992tIcAgjtcdxGLsB29RJ2JHuxlsGUoO4+0=; b=uDxafiGD3AD5N6Ty/ANNZBGJ+lns7GPlrMamXgy4KKlnHHLr7TV5YRGhWOME9T/0+ST19t7ICfidX3CPbomtCnAPf0qq+RQN2mPFvs07chXVze0OlimFu/InmJSlCfJSfVQTHpHK/QWemEiv1MbVEW54bHcowJEhbRe3vRcLM38= Received: from VI1PR0501MB2608.eurprd05.prod.outlook.com (10.168.137.20) by VI1PR0501MB2749.eurprd05.prod.outlook.com (10.172.11.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.16; Mon, 23 Jul 2018 06:12:31 +0000 Received: from VI1PR0501MB2608.eurprd05.prod.outlook.com ([fe80::7519:f438:f107:1373]) by VI1PR0501MB2608.eurprd05.prod.outlook.com ([fe80::7519:f438:f107:1373%8]) with mapi id 15.20.0973.018; Mon, 23 Jul 2018 06:12:31 +0000 From: Matan Azrad To: Aaron Conole , "dev@dpdk.org" CC: Ferruh Yigit , Marcelo Leitner , Shahaf Shuler , Ori Kam , Thomas Monjalon Thread-Topic: [dpdk-dev] [PATCH] ethdev: move sanity checks to non-debug paths Thread-Index: AQHUIa4hMAUNWOG7I0y82WSCV2bqN6ScUq+w Date: Mon, 23 Jul 2018 06:12:31 +0000 Message-ID: References: <20180722112116.8419-1-aconole@redhat.com> In-Reply-To: <20180722112116.8419-1-aconole@redhat.com> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0501MB2749; 6:ixS8HzbYS2aPHPFpaNT/v15qPSxlfZ/r9M/1Bd6lDykqTw+/1LNF54YQRTd+CdyUgUDnPDLHqbkpWh6/Wd2eO5+G86OzPI01+SEcvArhXpvbbmjs9Ah4vurL28UF2c3ZX/4B1A3crk6Et1Mt3Ym+HiG9Nh67hAGjh6wF9Tsl5lL0kwlIv6U6c7PYWOsi5cm6vOBynuk9e9RP14ghQYofEuGd1cFou4vdc18RGmyvz7BpfCJGPGNwqnAcooL0RxqHDzCNGGY/4T8w+Ln7RZoyPbDE0WvZQdmmcXIjKrAdQoT9lDx+fuUswnpqmBmg45XBfI5VvC1z7yuIGzydD7WFgmOXKYrhpROdPvFRzmZQSuH+1oYCruYSZpnYBZliydKnFTNDHaKxav0K/+ghtC9CJcjDPHoDQvzXTzk0B3Tk8pxegACqN6hApBMaD6nE+tjrr0xnZ6UVR9azZHJii2xBoA==; 5:cr5Ynb1PxjKT5VenzbpO+gxW7V1jTX+ULIjebgMK8xPBrXmcU12rIfADmCA3/dWqRfgnIzR000StA5P7bRsiVF7KM7IHktu5S8dlp1x9/qCT43HVma/y1A8RXAqoapwSHGubn1Q5IJSv8wga2ekgs0XbbP3ZC1wrXPC4KdyadFA=; 7:/9//fM4TJ2Y+o1/Uz4HsZ+8OqMfaO7gDF2gSmGXm3pYqVhFcwtvqI+vg50uUL8uanD/D8P6XnEgqxRVsZXgdcttTFnogRh0psjvHuSMvxzuHogdy24O3ZH/BA0iYXOap4TGrauM7iTCmZbTKwzpH68aJE2cdSm/JH3kosx+Xoa9gYIknzOB911fS4aRz2i5XvWMt4Vo82l3Ou1vwvsKvPxHIHYH2GlI39pYsJlP2KQHhb9tOCgsHmBgJtzqPQXdt x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: a739d19e-4b67-4b61-6720-08d5f0634657 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4618075)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2749; x-ms-traffictypediagnostic: VI1PR0501MB2749: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231311)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2749; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2749; x-forefront-prvs: 0742443479 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(39860400002)(346002)(376002)(366004)(396003)(136003)(199004)(189003)(51444003)(66066001)(4326008)(476003)(486006)(11346002)(97736004)(14444005)(256004)(229853002)(25786009)(53936002)(2906002)(6246003)(86362001)(5660300001)(2900100001)(99286004)(74316002)(76176011)(5250100002)(7696005)(81166006)(6506007)(26005)(8676002)(33656002)(8936002)(68736007)(81156014)(2501003)(186003)(102836004)(446003)(105586002)(7736002)(6436002)(3846002)(316002)(9686003)(55016002)(305945005)(54906003)(6116002)(478600001)(106356001)(14454004)(110136005)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2749; H:VI1PR0501MB2608.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: lsV8+shwu/9fnmxdpQ6/9gqdtt+++7XSz3PHG2pI3KpFQyC1Ymz4iAhLgYHFZt0+8OfjmUqEXHQct39aKl5bwhnnhrh20IPu+mx48od5aKKS+LTcfFmpJjwbq3pmbTHu16w3G/6kqamNy5eSCxCd1CuVI6es1hVwIumybdYTtvgr0qdBz3M5v+5Oms+foG2gByO5TYxG6GbRXZ4tPv7IsdLfXUyqLQRJ9AHriB2BRRpe4td1031TCNSWyhXRecx4fz2el4BqER31ytYMk7zFKjFffibDfeCrbKmhO/t9rbv8fe+3gIyqYsxTV7FN9WQmBA1NP5N7AFpNCi5WA7pk8JhC7Kp8F3gRCSeyzRQ2+DM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: a739d19e-4b67-4b61-6720-08d5f0634657 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jul 2018 06:12:31.4143 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2749 Subject: Re: [dpdk-dev] [PATCH] ethdev: move sanity checks to non-debug paths 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: Mon, 23 Jul 2018 06:12:35 -0000 Hi Aaron From: Aaron Conole > These checks would have prevented a reported crash in the field. If a us= er > builds without ETHDEV_DEBUG, it should make their application more stable= , > not less. >=20 > Many of these functions immediately dereference arrays based on the passe= d > in values, so the sanity checks are quite important. >=20 These functions are datapath functions. Do you really want to add more 3 checks + calculations per each burst call? Did you check the performance impact? I think that performance numbers must be added for the discussion of this p= atch. > The logs are left as DEBUG only. >=20 > Cc: Marcelo Leitner > Signed-off-by: Aaron Conole > --- > lib/librte_ethdev/rte_ethdev.h | 29 +++++++++++++---------------- > 1 file changed, 13 insertions(+), 16 deletions(-) >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethde= v.h > index f5f593b31..bfd6a3406 100644 > --- a/lib/librte_ethdev/rte_ethdev.h > +++ b/lib/librte_ethdev/rte_ethdev.h > @@ -3805,15 +3805,16 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t > queue_id, > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > uint16_t nb_rx; >=20 > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0); > RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_pkt_burst, 0); >=20 > if (queue_id >=3D dev->data->nb_rx_queues) { > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG > RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=3D%u\n", > queue_id); > +#endif > return 0; > } > -#endif > + > nb_rx =3D (*dev->rx_pkt_burst)(dev->data->rx_queues[queue_id], > rx_pkts, nb_pkts); >=20 > @@ -3928,14 +3929,12 @@ rte_eth_rx_descriptor_status(uint16_t port_id, > uint16_t queue_id, > struct rte_eth_dev *dev; > void *rxq; >=20 > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); -#endif > dev =3D &rte_eth_devices[port_id]; > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG > + > if (queue_id >=3D dev->data->nb_rx_queues) > return -ENODEV; > -#endif > + > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_status, - > ENOTSUP); > rxq =3D dev->data->rx_queues[queue_id]; >=20 > @@ -3985,14 +3984,12 @@ static inline int > rte_eth_tx_descriptor_status(uint16_t port_id, > struct rte_eth_dev *dev; > void *txq; >=20 > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); -#endif > dev =3D &rte_eth_devices[port_id]; > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG > + > if (queue_id >=3D dev->data->nb_tx_queues) > return -ENODEV; > -#endif > + > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_descriptor_status, - > ENOTSUP); > txq =3D dev->data->tx_queues[queue_id]; >=20 > @@ -4071,15 +4068,15 @@ rte_eth_tx_burst(uint16_t port_id, uint16_t > queue_id, { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; >=20 > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, 0); > RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_pkt_burst, 0); >=20 > if (queue_id >=3D dev->data->nb_tx_queues) { > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG > RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=3D%u\n", > queue_id); > +#endif > return 0; > } > -#endif >=20 > #ifdef RTE_ETHDEV_RXTX_CALLBACKS > struct rte_eth_rxtx_callback *cb =3D dev->pre_tx_burst_cbs[queue_id]; > @@ -4160,23 +4157,23 @@ rte_eth_tx_prepare(uint16_t port_id, uint16_t > queue_id, { > struct rte_eth_dev *dev; >=20 > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG > if (!rte_eth_dev_is_valid_port(port_id)) { > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG > RTE_ETHDEV_LOG(ERR, "Invalid TX port_id=3D%u\n", port_id); > +#endif > rte_errno =3D -EINVAL; > return 0; > } > -#endif >=20 > dev =3D &rte_eth_devices[port_id]; >=20 > -#ifdef RTE_LIBRTE_ETHDEV_DEBUG > if (queue_id >=3D dev->data->nb_tx_queues) { > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG > RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=3D%u\n", > queue_id); > +#endif > rte_errno =3D -EINVAL; > return 0; > } > -#endif >=20 > if (!dev->tx_pkt_prepare) > return nb_pkts; > -- > 2.14.3