From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80057.outbound.protection.outlook.com [40.107.8.57]) by dpdk.org (Postfix) with ESMTP id 39AE6160 for ; Mon, 23 Jul 2018 14:13:59 +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=BSu6o6CXsK9s84+E3jkP8U3JuqoctsSODIPTLxi6y+E=; b=gHrIsa9V5fTnjnkxM6zRYx6lKs0Bfuoyfh6kIwcyZvkXd7oEYdxknA7f0sqvVcfw36Sj72NdYxxDe/hHLJl+CS4nr9rmvK8nET1DLhSgp0LKXDNezRBrVpVTS1phDpy8b3YrOCQIWMPuoSCneclTRzbiUT8UIVGpsO5H28sO8Ao= Received: from VI1PR0501MB2608.eurprd05.prod.outlook.com (10.168.137.20) by VI1PR0501MB2109.eurprd05.prod.outlook.com (10.167.196.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Mon, 23 Jul 2018 12:13:56 +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 12:13:56 +0000 From: Matan Azrad To: Aaron Conole CC: "dev@dpdk.org" , 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+wgABhEviAAAK5oA== Date: Mon, 23 Jul 2018 12:13:56 +0000 Message-ID: References: <20180722112116.8419-1-aconole@redhat.com> In-Reply-To: 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; VI1PR0501MB2109; 6:rzRKLsZA3ncI5eLJ7abBOsKdRb3dSxDOmw4o307rEUvlf7ea4SvKWWJ6CUvj2xg/3UNdrJakiuW+CladSSy/7uSbGdrTBijvuE2WFj88+ddUFqUxePF+6aYxUGoufGgDBqpLPgqidEoxml4alpDYF/h9cva2zOJcP9D6XnGeokiB/Jq4vz8Bz/MaQ+TncOr+Alny08DoN/DjMxFGqFAmPpiUcWEZ/NH2LsvdDZt2CZgtCFXoYpIwVzBWtuPyHg4Beedi9KnXQtGPFcNf0fJgjadlgx58E7JwsJkUsBGYol8O1G2QuERqxuZMN0sr6wG7bFjEEkJuca0jjFBNuRT+ldb2zABnSIfkBC7vHbQnsPeDTxpIPe7d3FMYYLm450LDvyJCdaS8yewZgLQ2gkhdKCEiwPoPEkS1TF442TfElCtZmVYHNfo37vYcFVscUDN53JV1gbqebFNomFeAeXDfvQ==; 5:W3m4JgxeT4NDtPrJ8ZOJA3ZQSoD6BTmXlJdsoblxNtTtQx6TJjqZ5aRTbOAiIvthBydn2LpX37+ydsm2YvKPGNMshjkzQfxtjjs9LDYmCEz7FJVKV9jcshkDEuJ3RoD9XwQSxC/g5mzaBGw+hCTuCSgolOdf/nmY07W0HwAgGdI=; 7:KX0J5b7qBe2ba7gNWS3k2jd4o0GacZMKppNXyEBZyAlR3TOE947Hm5dohcpuOz4q8ve0jf3LOMDhYKUOIx5fJpdjR04ji5G9Cx1wkJXqfF+5JB62zOLqn2VPw1J4P0NYANRqNfuAayUpdSvflAPLtWs/C+K/bDAdmw+qKHGU4FrriPBNpOYsNIC9JEc0ulTzV99xbLKFCBOf4jf7FV4K7QQK1PyTTnxx8P/lpm57fd24alyCjdvLez4MTgCOhf01 x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 89f6c37a-87ca-4481-f304-08d5f095c3bb x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0501MB2109; x-ms-traffictypediagnostic: VI1PR0501MB2109: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(3231311)(944501410)(52105095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:VI1PR0501MB2109; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2109; x-forefront-prvs: 0742443479 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(346002)(136003)(396003)(366004)(51444003)(189003)(199004)(66066001)(256004)(229853002)(105586002)(14444005)(186003)(106356001)(99286004)(26005)(6506007)(3846002)(53546011)(97736004)(5250100002)(102836004)(54906003)(316002)(6116002)(2906002)(7736002)(7696005)(305945005)(76176011)(14454004)(74316002)(6916009)(33656002)(11346002)(53936002)(478600001)(446003)(8676002)(5660300001)(81156014)(486006)(81166006)(86362001)(55016002)(476003)(8936002)(25786009)(6246003)(68736007)(4326008)(2900100001)(6436002)(9686003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2109; H:VI1PR0501MB2608.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: RLu21DunZtEZR1SovGDkrO9IO53DLfHSFgh+604IEvAIHAmZGtBj7GNcICpADKMuO9mBbRD0AZJmuSFJOHGCmXU7Tu438f3X8yL7yEPsaIkVQQZNmuRjCy7Ls5Dz5j4koPed6T4WN2PIEQXhjPKPc66ws0TpvEMIEymqtizveRxCym6WBlLYHeoVFTrGTl8pa67mnevo7s0WcXP/0KKlwOSkX4DQSI9M7htfHKzmZBL4zo9fyuK7aPJpn1AugoAQHipPCWXMTMJydS8e+UTNEu3VIA0yNdwHtjK/eXruklAhWgMLnmFhqrhZuiFJojzXbmAVqfocTCE+tW2KlW906brRcC+tvI7cnzVUBr1oD4M= 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: 89f6c37a-87ca-4481-f304-08d5f095c3bb X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jul 2018 12:13:56.5742 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2109 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 12:13:59 -0000 Hi Aaron From: Aaron Conole > Sent: Monday, July 23, 2018 2:52 PM > To: Matan Azrad > Cc: dev@dpdk.org; Ferruh Yigit ; Marcelo Leitner > ; Shahaf Shuler ; Ori Kam > ; Thomas Monjalon > Subject: Re: [dpdk-dev] [PATCH] ethdev: move sanity checks to non-debug p= aths >=20 > Matan Azrad writes: >=20 > > Hi Aaron > > > > From: Aaron Conole > >> These checks would have prevented a reported crash in the field. If > >> a user builds without ETHDEV_DEBUG, it should make their application > >> more stable, not less. > >> > >> Many of these functions immediately dereference arrays based on the > >> passed in values, so the sanity checks are quite important. > >> > > > > These functions are datapath functions. > > Do you really want to add more 3 checks + calculations per each burst c= all? > > Did you check the performance impact? > > I think that performance numbers must be added for the discussion of th= is > patch. >=20 > I'll dig up performance numbers - but performance doesn't mean anything i= f > the application isn't running any longer due to crash. Yes, I understand your point, but think about that, if we are going to defe= nd each user mistake it will cost a lot. For example in Tx path, Adding checks for each mbuf pointer and mbuf data v= alidity will be very expensive. I think the best way is to check the common user mistakes in DEBUG mode to = help for application debugging and that's it. > >> The logs are left as DEBUG only. > >> > >> Cc: Marcelo Leitner > >> Signed-off-by: Aaron Conole > >> --- > >> lib/librte_ethdev/rte_ethdev.h | 29 +++++++++++++---------------- > >> 1 file changed, 13 insertions(+), 16 deletions(-) > >> > >> diff --git a/lib/librte_ethdev/rte_ethdev.h > >> b/lib/librte_ethdev/rte_ethdev.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; > >> > >> -#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); > >> > >> 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); > >> > >> @@ -3928,14 +3929,12 @@ rte_eth_rx_descriptor_status(uint16_t > >> port_id, uint16_t queue_id, > >> struct rte_eth_dev *dev; > >> void *rxq; > >> > >> -#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]; > >> > >> @@ -3985,14 +3984,12 @@ static inline int > >> rte_eth_tx_descriptor_status(uint16_t port_id, > >> struct rte_eth_dev *dev; > >> void *txq; > >> > >> -#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]; > >> > >> @@ -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]; > >> > >> -#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); > >> > >> 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 > >> > >> #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; > >> > >> -#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 > >> > >> dev =3D &rte_eth_devices[port_id]; > >> > >> -#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 > >> > >> if (!dev->tx_pkt_prepare) > >> return nb_pkts; > >> -- > >> 2.14.3