From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <david.hunt@intel.com>
Received: from mga04.intel.com (mga04.intel.com [192.55.52.120])
 by dpdk.org (Postfix) with ESMTP id ADAC62B84;
 Mon, 26 Nov 2018 12:14:52 +0100 (CET)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga002.jf.intel.com ([10.7.209.21])
 by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 26 Nov 2018 03:14:51 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.56,281,1539673200"; d="scan'208";a="111554856"
Received: from dhunt5-mobl2.ger.corp.intel.com (HELO [10.237.221.115])
 ([10.237.221.115])
 by orsmga002.jf.intel.com with ESMTP; 26 Nov 2018 03:14:50 -0800
To: Anatoly Burakov <anatoly.burakov@intel.com>, dev@dpdk.org
Cc: thomas@monjalon.net, stable@dpdk.org
References: <294f089848bf803ff134979c612bbf28e0e2e6b9.1543229588.git.anatoly.burakov@intel.com>
From: "Hunt, David" <david.hunt@intel.com>
Message-ID: <73443011-2b32-ce73-ef0d-896858f7503d@intel.com>
Date: Mon, 26 Nov 2018 11:14:49 +0000
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101
 Thunderbird/60.3.0
MIME-Version: 1.0
In-Reply-To: <294f089848bf803ff134979c612bbf28e0e2e6b9.1543229588.git.anatoly.burakov@intel.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-US
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] mem: fix division by zero in
	no-NUMA mode
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>
X-List-Received-Date: Mon, 26 Nov 2018 11:14:53 -0000

Hi Anatoly,

On 26/11/2018 10:57 AM, Anatoly Burakov wrote:
> When RTE_EAL_NUMA_AWARE_HUGEPAGES is set to "n", not all memtypes
> will be valid, because we skip some due to not supporting other
> NUMA nodes, leading to a division by zero error down the line
> because the necessary memtype fields weren't populated.
>
> Fix it by limiting number of memtypes to number of memtypes we
> have actually created.
>
> Fixes: 1dd342d0fdc4 ("mem: improve segment list preallocation")
> Cc: stable@dpdk.org
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>   lib/librte_eal/linuxapp/eal/eal_memory.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
> index 6f94621d4..32feb415d 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
> @@ -2230,6 +2230,8 @@ memseg_primary_init(void)
>   				socket_id, hugepage_sz);
>   		}
>   	}
> +	/* number of memtypes could have been lower due to no NUMA support */
> +	n_memtypes = cur_type;
>   
>   	/* set up limits for types */
>   	max_mem = (uint64_t)RTE_MAX_MEM_MB << 20;

Fixes the issue on my machine. vm_power_manager crashes with floating point
exception without patch, starts successfully with patch.

Tested-by: David Hunt <david.hunt@intel.com>