DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Aaron Conole <aconole@redhat.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>,
	Marcelo Leitner <mleitner@redhat.com>,
	Shahaf Shuler <shahafs@mellanox.com>,
	Ori Kam <orika@mellanox.com>,
	Thomas Monjalon <thomas@monjalon.net>
Subject: Re: [dpdk-dev] [PATCH] ethdev: move sanity checks to non-debug paths
Date: Mon, 23 Jul 2018 06:12:31 +0000	[thread overview]
Message-ID: <VI1PR0501MB2608CD1D62B016EE81F4DE0DD2560@VI1PR0501MB2608.eurprd05.prod.outlook.com> (raw)
In-Reply-To: <20180722112116.8419-1-aconole@redhat.com>

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 call?
Did you check the performance impact?
I think that performance numbers must be added for the discussion of this patch.



> The logs are left as DEBUG only.
> 
> Cc: Marcelo Leitner <mleitner@redhat.com>
> Signed-off-by: Aaron Conole <aconole@redhat.com>
> ---
>  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 = &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 >= dev->data->nb_rx_queues) {
> +#ifdef RTE_LIBRTE_ETHDEV_DEBUG
>  		RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n",
> queue_id);
> +#endif
>  		return 0;
>  	}
> -#endif
> +
>  	nb_rx = (*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 = &rte_eth_devices[port_id];
> -#ifdef RTE_LIBRTE_ETHDEV_DEBUG
> +
>  	if (queue_id >= dev->data->nb_rx_queues)
>  		return -ENODEV;
> -#endif
> +
>  	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_descriptor_status, -
> ENOTSUP);
>  	rxq = 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 = &rte_eth_devices[port_id];
> -#ifdef RTE_LIBRTE_ETHDEV_DEBUG
> +
>  	if (queue_id >= dev->data->nb_tx_queues)
>  		return -ENODEV;
> -#endif
> +
>  	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_descriptor_status, -
> ENOTSUP);
>  	txq = 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 = &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 >= dev->data->nb_tx_queues) {
> +#ifdef RTE_LIBRTE_ETHDEV_DEBUG
>  		RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n",
> queue_id);
> +#endif
>  		return 0;
>  	}
> -#endif
> 
>  #ifdef RTE_ETHDEV_RXTX_CALLBACKS
>  	struct rte_eth_rxtx_callback *cb = 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=%u\n", port_id);
> +#endif
>  		rte_errno = -EINVAL;
>  		return 0;
>  	}
> -#endif
> 
>  	dev = &rte_eth_devices[port_id];
> 
> -#ifdef RTE_LIBRTE_ETHDEV_DEBUG
>  	if (queue_id >= dev->data->nb_tx_queues) {
> +#ifdef RTE_LIBRTE_ETHDEV_DEBUG
>  		RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n",
> queue_id);
> +#endif
>  		rte_errno = -EINVAL;
>  		return 0;
>  	}
> -#endif
> 
>  	if (!dev->tx_pkt_prepare)
>  		return nb_pkts;
> --
> 2.14.3

  reply	other threads:[~2018-07-23  6:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-22 11:21 Aaron Conole
2018-07-23  6:12 ` Matan Azrad [this message]
2018-07-23 11:51   ` Aaron Conole
2018-07-23 12:13     ` Matan Azrad
2018-07-23 14:19       ` Ananyev, Konstantin
2018-07-23 20:07         ` Andrew Rybchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR0501MB2608CD1D62B016EE81F4DE0DD2560@VI1PR0501MB2608.eurprd05.prod.outlook.com \
    --to=matan@mellanox.com \
    --cc=aconole@redhat.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=mleitner@redhat.com \
    --cc=orika@mellanox.com \
    --cc=shahafs@mellanox.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).