DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v1] ixgbe/vector: add rxd 2^n check to avoid mbuf leak
@ 2015-03-02 13:28 Cunming Liang
  2015-03-05 11:44 ` Bruce Richardson
  0 siblings, 1 reply; 3+ messages in thread
From: Cunming Liang @ 2015-03-02 13:28 UTC (permalink / raw)
  To: dev

The mbuf leak happens when the assigned number of rx descriptor is not power of 2.
As it's presumed on vpmd rx(for rx_tail wrap), adding condition check to prevent it.
The root cause reference code in *_recv_raw_pkts_vec* as below.
"rxq->rx_tail = (uint16_t)(rxq->rx_tail & (rxq->nb_rx_desc - 1));".

Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Cunming Liang <cunming.liang@intel.com>
---
 The issue was reported in http://www.dpdk.org/ml/archives/dev/2015-February/014127.html

 lib/librte_pmd_ixgbe/ixgbe_rxtx.c | 51 ++++++++++++++-------------------------
 1 file changed, 18 insertions(+), 33 deletions(-)

diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
index 3059375..9ecf3e5 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
@@ -2257,7 +2257,8 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
 			     rxq->port_id, rxq->queue_id);
 		dev->rx_pkt_burst = ixgbe_recv_pkts_bulk_alloc;
 #ifdef RTE_IXGBE_INC_VECTOR
-		if (!ixgbe_rx_vec_condition_check(dev)) {
+		if (!ixgbe_rx_vec_condition_check(dev) &&
+		    (rte_is_power_of_2(nb_desc))) {
 			PMD_INIT_LOG(INFO, "Vector rx enabled, please make "
 				     "sure RX burst size no less than 32.");
 			dev->rx_pkt_burst = ixgbe_recv_pkts_vec;
@@ -3639,31 +3640,23 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
 		buf_size = (uint16_t) ((srrctl & IXGBE_SRRCTL_BSIZEPKT_MASK) <<
 				       IXGBE_SRRCTL_BSIZEPKT_SHIFT);
 
-		/* It adds dual VLAN length for supporting dual VLAN */
-		if ((dev->data->dev_conf.rxmode.max_rx_pkt_len +
+		if (dev->data->dev_conf.rxmode.enable_scatter ||
+		    /* It adds dual VLAN length for supporting dual VLAN */
+		    (dev->data->dev_conf.rxmode.max_rx_pkt_len +
 				2 * IXGBE_VLAN_TAG_SIZE) > buf_size){
 			if (!dev->data->scattered_rx)
 				PMD_INIT_LOG(DEBUG, "forcing scatter mode");
 			dev->data->scattered_rx = 1;
 #ifdef RTE_IXGBE_INC_VECTOR
-			dev->rx_pkt_burst = ixgbe_recv_scattered_pkts_vec;
-#else
-			dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
+			if (rte_is_power_of_2(rxq->nb_rx_desc))
+				dev->rx_pkt_burst =
+					ixgbe_recv_scattered_pkts_vec;
+			else
 #endif
+				dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
 		}
 	}
 
-	if (dev->data->dev_conf.rxmode.enable_scatter) {
-		if (!dev->data->scattered_rx)
-			PMD_INIT_LOG(DEBUG, "forcing scatter mode");
-#ifdef RTE_IXGBE_INC_VECTOR
-		dev->rx_pkt_burst = ixgbe_recv_scattered_pkts_vec;
-#else
-		dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
-#endif
-		dev->data->scattered_rx = 1;
-	}
-
 	/*
 	 * Device configured with multiple RX queues.
 	 */
@@ -4156,17 +4149,20 @@ ixgbevf_dev_rx_init(struct rte_eth_dev *dev)
 		buf_size = (uint16_t) ((srrctl & IXGBE_SRRCTL_BSIZEPKT_MASK) <<
 				       IXGBE_SRRCTL_BSIZEPKT_SHIFT);
 
-		/* It adds dual VLAN length for supporting dual VLAN */
-		if ((dev->data->dev_conf.rxmode.max_rx_pkt_len +
+		if (dev->data->dev_conf.rxmode.enable_scatter ||
+		    /* It adds dual VLAN length for supporting dual VLAN */
+		    (dev->data->dev_conf.rxmode.max_rx_pkt_len +
 				2 * IXGBE_VLAN_TAG_SIZE) > buf_size) {
 			if (!dev->data->scattered_rx)
 				PMD_INIT_LOG(DEBUG, "forcing scatter mode");
 			dev->data->scattered_rx = 1;
 #ifdef RTE_IXGBE_INC_VECTOR
-			dev->rx_pkt_burst = ixgbe_recv_scattered_pkts_vec;
-#else
-			dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
+			if (rte_is_power_of_2(rxq->nb_rx_desc))
+				dev->rx_pkt_burst =
+					ixgbe_recv_scattered_pkts_vec;
+			else
 #endif
+				dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
 		}
 	}
 
@@ -4184,17 +4180,6 @@ ixgbevf_dev_rx_init(struct rte_eth_dev *dev)
 		IXGBE_PSRTYPE_RQPL_SHIFT;
 	IXGBE_WRITE_REG(hw, IXGBE_VFPSRTYPE, psrtype);
 
-	if (dev->data->dev_conf.rxmode.enable_scatter) {
-		if (!dev->data->scattered_rx)
-			PMD_INIT_LOG(DEBUG, "forcing scatter mode");
-#ifdef RTE_IXGBE_INC_VECTOR
-		dev->rx_pkt_burst = ixgbe_recv_scattered_pkts_vec;
-#else
-		dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
-#endif
-		dev->data->scattered_rx = 1;
-	}
-
 	return 0;
 }
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH v1] ixgbe/vector: add rxd 2^n check to avoid mbuf leak
  2015-03-02 13:28 [dpdk-dev] [PATCH v1] ixgbe/vector: add rxd 2^n check to avoid mbuf leak Cunming Liang
@ 2015-03-05 11:44 ` Bruce Richardson
  2015-03-05 19:00   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2015-03-05 11:44 UTC (permalink / raw)
  To: Cunming Liang; +Cc: dev

On Mon, Mar 02, 2015 at 09:28:24PM +0800, Cunming Liang wrote:
> The mbuf leak happens when the assigned number of rx descriptor is not power of 2.
> As it's presumed on vpmd rx(for rx_tail wrap), adding condition check to prevent it.
> The root cause reference code in *_recv_raw_pkts_vec* as below.
> "rxq->rx_tail = (uint16_t)(rxq->rx_tail & (rxq->nb_rx_desc - 1));".
> 
> Reported-by: Stephen Hemminger <stephen@networkplumber.org>
> Signed-off-by: Cunming Liang <cunming.liang@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  The issue was reported in http://www.dpdk.org/ml/archives/dev/2015-February/014127.html
> 
>  lib/librte_pmd_ixgbe/ixgbe_rxtx.c | 51 ++++++++++++++-------------------------
>  1 file changed, 18 insertions(+), 33 deletions(-)
> 
> diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
> index 3059375..9ecf3e5 100644
> --- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
> +++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
> @@ -2257,7 +2257,8 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
>  			     rxq->port_id, rxq->queue_id);
>  		dev->rx_pkt_burst = ixgbe_recv_pkts_bulk_alloc;
>  #ifdef RTE_IXGBE_INC_VECTOR
> -		if (!ixgbe_rx_vec_condition_check(dev)) {
> +		if (!ixgbe_rx_vec_condition_check(dev) &&
> +		    (rte_is_power_of_2(nb_desc))) {
>  			PMD_INIT_LOG(INFO, "Vector rx enabled, please make "
>  				     "sure RX burst size no less than 32.");
>  			dev->rx_pkt_burst = ixgbe_recv_pkts_vec;
> @@ -3639,31 +3640,23 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
>  		buf_size = (uint16_t) ((srrctl & IXGBE_SRRCTL_BSIZEPKT_MASK) <<
>  				       IXGBE_SRRCTL_BSIZEPKT_SHIFT);
>  
> -		/* It adds dual VLAN length for supporting dual VLAN */
> -		if ((dev->data->dev_conf.rxmode.max_rx_pkt_len +
> +		if (dev->data->dev_conf.rxmode.enable_scatter ||
> +		    /* It adds dual VLAN length for supporting dual VLAN */
> +		    (dev->data->dev_conf.rxmode.max_rx_pkt_len +
>  				2 * IXGBE_VLAN_TAG_SIZE) > buf_size){
>  			if (!dev->data->scattered_rx)
>  				PMD_INIT_LOG(DEBUG, "forcing scatter mode");
>  			dev->data->scattered_rx = 1;
>  #ifdef RTE_IXGBE_INC_VECTOR
> -			dev->rx_pkt_burst = ixgbe_recv_scattered_pkts_vec;
> -#else
> -			dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
> +			if (rte_is_power_of_2(rxq->nb_rx_desc))
> +				dev->rx_pkt_burst =
> +					ixgbe_recv_scattered_pkts_vec;
> +			else
>  #endif
> +				dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
>  		}
>  	}
>  
> -	if (dev->data->dev_conf.rxmode.enable_scatter) {
> -		if (!dev->data->scattered_rx)
> -			PMD_INIT_LOG(DEBUG, "forcing scatter mode");
> -#ifdef RTE_IXGBE_INC_VECTOR
> -		dev->rx_pkt_burst = ixgbe_recv_scattered_pkts_vec;
> -#else
> -		dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
> -#endif
> -		dev->data->scattered_rx = 1;
> -	}
> -
>  	/*
>  	 * Device configured with multiple RX queues.
>  	 */
> @@ -4156,17 +4149,20 @@ ixgbevf_dev_rx_init(struct rte_eth_dev *dev)
>  		buf_size = (uint16_t) ((srrctl & IXGBE_SRRCTL_BSIZEPKT_MASK) <<
>  				       IXGBE_SRRCTL_BSIZEPKT_SHIFT);
>  
> -		/* It adds dual VLAN length for supporting dual VLAN */
> -		if ((dev->data->dev_conf.rxmode.max_rx_pkt_len +
> +		if (dev->data->dev_conf.rxmode.enable_scatter ||
> +		    /* It adds dual VLAN length for supporting dual VLAN */
> +		    (dev->data->dev_conf.rxmode.max_rx_pkt_len +
>  				2 * IXGBE_VLAN_TAG_SIZE) > buf_size) {
>  			if (!dev->data->scattered_rx)
>  				PMD_INIT_LOG(DEBUG, "forcing scatter mode");
>  			dev->data->scattered_rx = 1;
>  #ifdef RTE_IXGBE_INC_VECTOR
> -			dev->rx_pkt_burst = ixgbe_recv_scattered_pkts_vec;
> -#else
> -			dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
> +			if (rte_is_power_of_2(rxq->nb_rx_desc))
> +				dev->rx_pkt_burst =
> +					ixgbe_recv_scattered_pkts_vec;
> +			else
>  #endif
> +				dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
>  		}
>  	}
>  
> @@ -4184,17 +4180,6 @@ ixgbevf_dev_rx_init(struct rte_eth_dev *dev)
>  		IXGBE_PSRTYPE_RQPL_SHIFT;
>  	IXGBE_WRITE_REG(hw, IXGBE_VFPSRTYPE, psrtype);
>  
> -	if (dev->data->dev_conf.rxmode.enable_scatter) {
> -		if (!dev->data->scattered_rx)
> -			PMD_INIT_LOG(DEBUG, "forcing scatter mode");
> -#ifdef RTE_IXGBE_INC_VECTOR
> -		dev->rx_pkt_burst = ixgbe_recv_scattered_pkts_vec;
> -#else
> -		dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
> -#endif
> -		dev->data->scattered_rx = 1;
> -	}
> -
>  	return 0;
>  }
>  
> -- 
> 1.8.1.4
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH v1] ixgbe/vector: add rxd 2^n check to avoid mbuf leak
  2015-03-05 11:44 ` Bruce Richardson
@ 2015-03-05 19:00   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2015-03-05 19:00 UTC (permalink / raw)
  To: Cunming Liang; +Cc: dev

> > The mbuf leak happens when the assigned number of rx descriptor is not power of 2.
> > As it's presumed on vpmd rx(for rx_tail wrap), adding condition check to prevent it.
> > The root cause reference code in *_recv_raw_pkts_vec* as below.
> > "rxq->rx_tail = (uint16_t)(rxq->rx_tail & (rxq->nb_rx_desc - 1));".
> > 
> > Reported-by: Stephen Hemminger <stephen@networkplumber.org>
> > Signed-off-by: Cunming Liang <cunming.liang@intel.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-05 19:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-02 13:28 [dpdk-dev] [PATCH v1] ixgbe/vector: add rxd 2^n check to avoid mbuf leak Cunming Liang
2015-03-05 11:44 ` Bruce Richardson
2015-03-05 19:00   ` Thomas Monjalon

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).