From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by dpdk.space (Postfix) with ESMTP id F26F4A0096
	for <public@inbox.dpdk.org>; Wed, 10 Apr 2019 11:15:07 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id A7C195F0F;
	Wed, 10 Apr 2019 11:15:07 +0200 (CEST)
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by dpdk.org (Postfix) with ESMTP id BA6955B2C;
 Wed, 10 Apr 2019 11:15:01 +0200 (CEST)
X-Amp-Result: UNKNOWN
X-Amp-Original-Verdict: FILE UNKNOWN
X-Amp-File-Uploaded: False
Received: from orsmga007.jf.intel.com ([10.7.209.58])
 by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 10 Apr 2019 02:15:00 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.60,332,1549958400"; d="scan'208";a="130123383"
Received: from bricha3-mobl.ger.corp.intel.com ([10.237.221.35])
 by orsmga007.jf.intel.com with SMTP; 10 Apr 2019 02:14:58 -0700
Received: by  (sSMTP sendmail emulation); Wed, 10 Apr 2019 10:14:57 +0100
Date: Wed, 10 Apr 2019 10:14:57 +0100
From: Bruce Richardson <bruce.richardson@intel.com>
To: Yongseok Koh <yskoh@mellanox.com>
Cc: anatoly.burakov@intel.com, dev@dpdk.org, stable@dpdk.org
Message-ID: <20190410091457.GC700@bricha3-MOBL.ger.corp.intel.com>
References: <20190409225937.9269-1-yskoh@mellanox.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20190409225937.9269-1-yskoh@mellanox.com>
User-Agent: Mutt/1.11.4 (2019-03-13)
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] examples/multi_process: fix
	buffer underrun
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org
Sender: "stable" <stable-bounces@dpdk.org>

On Tue, Apr 09, 2019 at 03:59:37PM -0700, Yongseok Koh wrote:
> For client_server_mp, the total number of buffers for the mbuf mempool
> should be correctly calculated. Otherwise, having more clients will stop
> traffic.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
> ---
>  examples/multi_process/client_server_mp/mp_server/init.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/examples/multi_process/client_server_mp/mp_server/init.c b/examples/multi_process/client_server_mp/mp_server/init.c
> index 30c8e44bc0..0491ba8a1a 100644
> --- a/examples/multi_process/client_server_mp/mp_server/init.c
> +++ b/examples/multi_process/client_server_mp/mp_server/init.c
> @@ -37,8 +37,6 @@
>  #include "args.h"
>  #include "init.h"
>  
> -#define MBUFS_PER_CLIENT 1536
> -#define MBUFS_PER_PORT 1536
>  #define MBUF_CACHE_SIZE 512
>  
>  #define RTE_MP_RX_DESC_DEFAULT 1024
> @@ -63,8 +61,12 @@ struct port_info *ports;
>  static int
>  init_mbuf_pools(void)
>  {
> -	const unsigned num_mbufs = (num_clients * MBUFS_PER_CLIENT) \
> -			+ (ports->num_ports * MBUFS_PER_PORT);
> +	const unsigned int num_mbufs =
> +		RTE_MP_RX_DESC_DEFAULT * ports->num_ports + /* Sever */

typo: server

> +		num_clients *
> +		(CLIENT_QUEUE_RINGSIZE +
> +		 RTE_MP_TX_DESC_DEFAULT * ports->num_ports) + /* Clients */
> +		(num_clients + 1) * MBUF_CACHE_SIZE; /* Mempool cache */
>  

The calculation looks correct to me, it's just rather long with strange
wrapping. I'd suggest either splitting up the calculation to have a
separate variable for per-client mbuf counts, or else just use a longer
line for readability for the client calculation.

>  	/* don't pass single-producer/single-consumer flags to mbuf create as it
>  	 * seems faster to use a cache instead */
> -- 
> 2.11.0
>