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 58BECA046B for ; Thu, 9 Jan 2020 14:40:21 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4EE901DD8C; Thu, 9 Jan 2020 14:40:21 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id 906FF1DD8D for ; Thu, 9 Jan 2020 14:40:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578577220; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=igOWzDerTRRCbNeMEmOEpv+vF++F/9G0uknOe9XTS0Q=; b=BqFX+mg0jpVGHk+PDxodpzL4V8XxAV1+YkVv9nrznNV7gm5RZm+a2PPbuaod2FXwr6AOKs HkkJ6sKHgmRew7+s2qMBjuQrFSGkPhYv0HcQ9nwdVrm50O96D1EtFHoRxvTXY1Rsh55Kiw CvIiHJTIREDK2zbybQRfl+/RZ7lJ9e0= Received: from mail-ua1-f72.google.com (mail-ua1-f72.google.com [209.85.222.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-429-YFK8YLBvOuKSQ-na88B32Q-1; Thu, 09 Jan 2020 08:40:18 -0500 Received: by mail-ua1-f72.google.com with SMTP id s42so1436978uad.3 for ; Thu, 09 Jan 2020 05:40:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=riqD/A1d5Tp0KYPecoScbojhv9buJcXz5n67M3tGG/w=; b=RV55B+HALVHyUFJfJEcCUEINlezei87qMEyx8yJBH/AYosmhUyEP/t3a3vBRDDQPR6 AudOJ8q3zT/WDzrA8ykudWGhJ0C5EasnkU5m47bSQIdgArLuT1HNxmk9bRMGFFAtoPo9 ++mNeQZgiz0mJSeBwT+rEzkK8FOEhioSIAB47OgQgOEAVLbAKa2/lAp8Dz6j5wzp+WtN MrE+D2zTbg75R4g9fOOPICGYHgPHmeUwssAdXfjH0kXpZMueugUlXvrYBZU2sNr8yrAr 1xl73xht2MC+kDxLx+O2i8pgUkL6wSby8J3IJxyQ9ZiGAeo2877u33EVUez7jx10/3j3 jh3w== X-Gm-Message-State: APjAAAXIoEYOPWNwpoKBn5EFYN7mQIVZizyI192Ve37QIgvveUJhRdTe 0EsPNuU1g99MH+CPw/hKl2CZhVcy1OD3SOurpLtFAnL5GEEuIBO8PyCh/ccGzG4+yXpfOMLWx/g pl/45PS4ClKwrnn/eJyvT9Pg= X-Received: by 2002:a1f:72c3:: with SMTP id n186mr6437561vkc.12.1578577218146; Thu, 09 Jan 2020 05:40:18 -0800 (PST) X-Google-Smtp-Source: APXvYqy9SYyc/adiZPvy6m/miaA5BxM+qNyZ4trU+60070v3gFQ0GOJPDJ75ZutchBtL4j176vpbZuAVXodSrEHnaDE= X-Received: by 2002:a1f:72c3:: with SMTP id n186mr6437550vkc.12.1578577217808; Thu, 09 Jan 2020 05:40:17 -0800 (PST) MIME-Version: 1.0 References: <20200109132720.15664-1-olivier.matz@6wind.com> In-Reply-To: <20200109132720.15664-1-olivier.matz@6wind.com> From: David Marchand Date: Thu, 9 Jan 2020 14:40:06 +0100 Message-ID: To: Olivier Matz Cc: dev , Andrew Rybchenko , Anatoly Burakov , dpdk stable X-MC-Unique: YFK8YLBvOuKSQ-na88B32Q-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 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 ar= ea") > 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 initiali= zed. > In this case the function will return -1 unless the environment is uns= et first > (using ``rte_power_unset_env``). Other function usage scenarios will n= ot 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_me= mpool.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, cha= r *vaddr, > off =3D RTE_PTR_ALIGN_CEIL(vaddr, RTE_MEMPOOL_ALIGN) - va= ddr; > > if (off > len) { > - ret =3D -EINVAL; > + ret =3D -ENOBUFS; > goto fail; > } > > @@ -343,7 +343,7 @@ rte_mempool_populate_iova(struct rte_mempool *mp, cha= r *vaddr, > > /* not enough room to store one object */ > if (i =3D=3D 0) { > - ret =3D -EINVAL; > + ret =3D -ENOBUFS; > goto fail; > } > > @@ -356,6 +356,22 @@ rte_mempool_populate_iova(struct rte_mempool *mp, ch= ar *vaddr, > return ret; > } > > +/* Compat wrapper, to be removed when changing the API is allowed (v20.1= 1). */ > +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 =3D __rte_mempool_populate_iova(mp, vaddr, iova, len, free_cb= , > + opaque); > + if (ret =3D=3D -ENOBUFS) > + ret =3D -EINVAL; > + > + return ret; > +} > + > static rte_iova_t > get_iova(void *addr) > { > @@ -406,8 +422,10 @@ rte_mempool_populate_virt(struct rte_mempool *mp, ch= ar *addr, > break; > } > > - ret =3D rte_mempool_populate_iova(mp, addr + off, iova, > + ret =3D __rte_mempool_populate_iova(mp, addr + off, iova, > phys_len, free_cb, opaque); > + if (ret =3D=3D -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_me= mpool.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. --=20 David Marchand