From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 04AFFA0540 for ; Tue, 14 Jul 2020 11:32:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 840611D5B6; Tue, 14 Jul 2020 11:32:52 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 3EAD62C57; Tue, 14 Jul 2020 11:32:49 +0200 (CEST) IronPort-SDR: hE4fhmgoYZv7FVx7KfG1ZC6/FOSGrhOkLoFDIRR1VZgeroRGNcZ5mFojI/Bz/pw+NMlo+3CMWX cAunUz8h8lSQ== X-IronPort-AV: E=McAfee;i="6000,8403,9681"; a="146862560" X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="146862560" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2020 02:32:46 -0700 IronPort-SDR: KkcF50mAactjsYP2YRIL35cRh1N1OWS13I6J6zh3l8v3fcVYNnoyU4Yd4s+IlGtf39Ce4i8Fpi yQhZAdyzg0Zg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,350,1589266800"; d="scan'208";a="299475786" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.252.55.216]) ([10.252.55.216]) by orsmga002.jf.intel.com with ESMTP; 14 Jul 2020 02:32:46 -0700 To: Zhike Wang , dev@dpdk.org Cc: olivier.matz@6wind.com, arybchenko@solarflare.com, stable@dpdk.org References: <1594611634-7730-1-git-send-email-wangzhike@jd.com> <1594711565-28309-1-git-send-email-wangzhike@jd.com> From: "Burakov, Anatoly" Message-ID: <0256a601-f2d2-2621-0ab4-1a1d0b7b932b@intel.com> Date: Tue, 14 Jul 2020 10:32:44 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1594711565-28309-1-git-send-email-wangzhike@jd.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH v2] mempool: fix memory allocation in memzones during retry. X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On 14-Jul-20 8:26 AM, Zhike Wang wrote: > If allocation is successful on the first attempt, typically > there is no problem since we allocated everything required and > we'll terminate the loop (if memory chunk is really sufficient > to populate required number of mempool elements). > > If the first attempt fails, we try to allocate half > of mem_size and it succeed, we'll have one more iteration of > the for-loop to allocate memory for remaining elements and > should not try the next time with quarter of the mem_size. > > It is wrong that max_alloc_size is divided by 2 in the > case of successful allocation as well, or invalid memory > can be allocated, and leads to population failure, then errno > other than ENOMEM may be returned. > > Fixes: 3a3d0c75b43e ("mempool: fix slow allocation of large pools") > > Signed-off-by: Andrew Rybchenko > Signed-off-by: Zhike Wang > --- > lib/librte_mempool/rte_mempool.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c > index a2bd249..7774f0c 100644 > --- a/lib/librte_mempool/rte_mempool.c > +++ b/lib/librte_mempool/rte_mempool.c > @@ -635,7 +635,7 @@ struct pagesz_walk_arg { > RTE_MIN((size_t)mem_size, max_alloc_size), > mp->socket_id, mz_flags, align); > > - if (mz == NULL && rte_errno != ENOMEM) > + if (mz != NULL || rte_errno != ENOMEM) > break; > > max_alloc_size = RTE_MIN(max_alloc_size, > Acked-by: Anatoly Burakov -- Thanks, Anatoly