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 58C94A046B for ; Thu, 9 Jan 2020 14:46:50 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 449B414583; Thu, 9 Jan 2020 14:46:50 +0100 (CET) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by dpdk.org (Postfix) with ESMTP id 39CE31D55E for ; Thu, 9 Jan 2020 14:46:49 +0100 (CET) Received: by mail-wm1-f65.google.com with SMTP id p17so2922164wmb.0 for ; Thu, 09 Jan 2020 05:46:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Ik/IshM/XafgywPe+m4dJS3OZbHxDoMbs6FaE/H4oaI=; b=LKRcyez10oHFs5fp2DqJhalDT46aWLxDiyUwsv/gc8ltFfNWyhFhZI9dh9/Cl6XM6Q B6/rrpjyFfiJd07+aWfPId62L2sq+xfqPdrykh/LBPsSIb7JlZ7FJg+6DNd8ynbz/A9K ffhTYT2zkwpPDulNv0T7FeG8YxYxpQuCVjIqF0wtlheDH9kY0pM6KZBCdeWvKs8TSVI7 h46zjn3tpyQ0UgLeeqbiHEzrtAeXGk1ZjrDbgNyz1KEZ7SdRXd7xcx69nA7KkvmSwWYQ nsXC2NHjvI0rBT5w3BamZ8jLwEA0i+20tgx0VDdVuGJJsUZcZu+b/BalNeWmpUSbUJgS EFlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Ik/IshM/XafgywPe+m4dJS3OZbHxDoMbs6FaE/H4oaI=; b=P9f3EThdIDsHpdwogFtapzmjoo2ggHCqLz48xYvLskGbhxR8gxEx+Oio/Dpe4MzQmd KDmZgB1bboSHgb6fJ86uWipQlyW/06pYaDkWlmEA7v1iZLwAaCosdD8dNaPjJLYUpgh8 CxYugGxTbqh2Rh6iJOL3X87bQ89QyHhyiMJ57k/Pfwy6+jw5e8r0GagobopWUXoEHYWO MMc9fGCQuFEeqKy8gsd2jzbKKb1efV3Kh0wglaxb78bfnaPukIUItq8XWiVhnuOK/qMM /BW6eQIAhjCf2Ymq46Hw48kTavANJa7RMO7P5boGVkiQDfFSnFo1IIitoZ87hlI/ntm8 pQgw== X-Gm-Message-State: APjAAAUl/n58GYbS0ZETTAG1Cgl3pJHAf/nR6tsbgCrKsFzy2FUk5M+j sZaE67NSWTwBacUsU2R/FHb2dw== X-Google-Smtp-Source: APXvYqyjlbChfpPTvf468OpoMDFQZ+3VJNtQtRigZ4J3wjgSCfjJbefuRtt4J1Gx0j9s5CmA2cqVbg== X-Received: by 2002:a7b:cb86:: with SMTP id m6mr4993950wmi.51.1578577608906; Thu, 09 Jan 2020 05:46:48 -0800 (PST) Received: from 6wind.com (2a01cb0c0005a600345636f7e65ed1a0.ipv6.abo.wanadoo.fr. [2a01:cb0c:5:a600:3456:36f7:e65e:d1a0]) by smtp.gmail.com with ESMTPSA id q3sm2824479wmc.47.2020.01.09.05.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 05:46:48 -0800 (PST) Date: Thu, 9 Jan 2020 14:46:47 +0100 From: Olivier Matz To: David Marchand Cc: dev , Andrew Rybchenko , Anatoly Burakov , dpdk stable Message-ID: <20200109134647.GI22738@platinum> References: <20200109132720.15664-1-olivier.matz@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] mempool: fix mempool virt populate with small chunks 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 Thu, Jan 09, 2020 at 02:40:06PM +0100, David Marchand wrote: > On Thu, Jan 9, 2020 at 2:27 PM Olivier Matz wrote: > > > > To populate a mempool with a virtual area, the mempool code calls > > rte_mempool_populate_iova() for each iova-contiguous area. It happens > > (rarely) that this area is too small to store one object. In this case, > > rte_mempool_populate_iova() returns an error, which is forwarded by > > rte_mempool_populate_virt(). > > > > This case should not throw an error in > > rte_mempool_populate_virt(). Instead, the area that is too small should > > just be ignored. > > > > To fix this issue, change the return value of > > rte_mempool_populate_iova() to -ENOBUFS when no object can be populated, > > so it can be ignored by the caller. As this would be an API change, add > > a compat wrapper to keep the current API unchanged. The wrapper will be > > removed for 20.11. > > > > Fixes: 354788b60cfd ("mempool: allow populating with unaligned virtual area") > > Cc: stable@dpdk.org > > > > Signed-off-by: Olivier Matz > > --- > > > > Is there a simple way to ensure that we won't forget to remove the > > wrapper for 20.11? Anatoly suggested me to use versioned symbols, but > > it's not clear to me how. > > > > doc/guides/rel_notes/deprecation.rst | 4 ++++ > > lib/librte_mempool/rte_mempool.c | 28 +++++++++++++++++++++++----- > > lib/librte_mempool/rte_mempool.h | 5 ++++- > > 3 files changed, 31 insertions(+), 6 deletions(-) > > > > diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst > > index afa94b43e..b6e89d9a2 100644 > > --- a/doc/guides/rel_notes/deprecation.rst > > +++ b/doc/guides/rel_notes/deprecation.rst > > @@ -86,3 +86,7 @@ Deprecation Notices > > to set new power environment if power environment was already initialized. > > In this case the function will return -1 unless the environment is unset first > > (using ``rte_power_unset_env``). Other function usage scenarios will not change. > > + > > +* mempool: starting from v20.11, rte_mempool_populate_iova() will > > + return -ENOBUFS instead of -EINVAL when there is not enough room to > > + store one object. > > diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c > > index 78d8eb941..bda361ce6 100644 > > --- a/lib/librte_mempool/rte_mempool.c > > +++ b/lib/librte_mempool/rte_mempool.c > > @@ -297,8 +297,8 @@ mempool_ops_alloc_once(struct rte_mempool *mp) > > * zone. Return the number of objects added, or a negative value > > * on error. > > */ > > -int > > -rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, > > +static int > > +__rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, > > rte_iova_t iova, size_t len, rte_mempool_memchunk_free_cb_t *free_cb, > > void *opaque) > > { > > @@ -332,7 +332,7 @@ rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, > > off = RTE_PTR_ALIGN_CEIL(vaddr, RTE_MEMPOOL_ALIGN) - vaddr; > > > > if (off > len) { > > - ret = -EINVAL; > > + ret = -ENOBUFS; > > goto fail; > > } > > > > @@ -343,7 +343,7 @@ rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, > > > > /* not enough room to store one object */ > > if (i == 0) { > > - ret = -EINVAL; > > + ret = -ENOBUFS; > > goto fail; > > } > > > > @@ -356,6 +356,22 @@ rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, > > return ret; > > } > > > > +/* Compat wrapper, to be removed when changing the API is allowed (v20.11). */ > > +int > > +rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, > > + rte_iova_t iova, size_t len, rte_mempool_memchunk_free_cb_t *free_cb, > > + void *opaque) > > +{ > > + int ret; > > + > > + ret = __rte_mempool_populate_iova(mp, vaddr, iova, len, free_cb, > > + opaque); > > + if (ret == -ENOBUFS) > > + ret = -EINVAL; > > + > > + return ret; > > +} > > + > > static rte_iova_t > > get_iova(void *addr) > > { > > @@ -406,8 +422,10 @@ rte_mempool_populate_virt(struct rte_mempool *mp, char *addr, > > break; > > } > > > > - ret = rte_mempool_populate_iova(mp, addr + off, iova, > > + ret = __rte_mempool_populate_iova(mp, addr + off, iova, > > phys_len, free_cb, opaque); > > + if (ret == -ENOBUFS) > > + continue; > > if (ret < 0) > > goto fail; > > /* no need to call the free callback for next chunks */ > > diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h > > index f81152af9..c08bb444f 100644 > > --- a/lib/librte_mempool/rte_mempool.h > > +++ b/lib/librte_mempool/rte_mempool.h > > @@ -1108,7 +1108,10 @@ rte_mempool_free(struct rte_mempool *mp); > > * @return > > * The number of objects added on success. > > * On error, the chunk is not added in the memory list of the > > - * mempool and a negative errno is returned. > > + * mempool and a negative errno is returned: > > + * (-ENOBUFS): not enough room in chunk for one object. > > + * (-ENOSPC): mempool is already populated. > > + * (-ENOMEM): allocation failure. > > You can't update the doc before this function does return -ENOBUFS. Indeed :) It should be EINVAL instead of ENOBUFS above. ...and I should add a reminder to update the doc for 20.11