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 99BCDA00BE; Tue, 29 Oct 2019 18:02:23 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3F71A1BF2F; Tue, 29 Oct 2019 18:02:22 +0100 (CET) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by dpdk.org (Postfix) with ESMTP id B6A931BEF7 for ; Tue, 29 Oct 2019 18:02:20 +0100 (CET) Received: by mail-wr1-f65.google.com with SMTP id s1so14515260wro.0 for ; Tue, 29 Oct 2019 10:02:20 -0700 (PDT) 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=eeSSuIrF4O1Hg7Ul8ToAZXSMDb0tX2buHYrYs9/elaE=; b=FHIJ+11R7u8UfmzIKZCmV76IYx/tkpHNUkR7B/6a6M9vehiaf0Ij3WbsXMMwNG15+R 1XKS3P+hz515iNSIG9+XTnBc2Qi184QwEOlLeQDtzIUsyEDp9lrJiNQOQUbkYUEauPq7 /nvEWoGKTzeHaB8h9kW6N29SLdlMzRCrk6st/VuSx2ThcMHV+6/yJH5frVI3kiUUgOvN ZlhGJMhWNQvemQ0VzCFwsqoFMIleDZnhZhOc8vtOvvoItzBBoyGZFIlZTPTsaT9fbSK4 6qisZsJgpYmCl2Xi6RgOfxL4fvXe1QMF2uQ1+dyGi9ZEnYPrHrf7B+NhyK25kv/TKpIm q6yQ== 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=eeSSuIrF4O1Hg7Ul8ToAZXSMDb0tX2buHYrYs9/elaE=; b=GvG4VKOWGuAcwpSy3wMUvRQ/n5tM5p8b8WIVlXNOBWNEqzB2s23PFciF6Gq9l3cqcE v3HOX5uyICapBd2SCWW1URdFe89/r6X4E+cC6TuTdVkoZ0Z7qgkvUqtWl8fGQcdVbSMT +PHJPuQmWvmTVFE6Y5uo/qf8MHP0y2l0Yt3xnCOMwV5po+kA4qqOp0ajxxoZFkw39jbI OvCT8kGcrb2cB1wKniEEH/Yj04tQZ3ipThGuGaSnL98SUz6anGKMSWKdXt9nT191Ozqp qlng59Eu39hy0rWJ3c6gza65OH5HZ3MkOiA6gIRQmbgbl+RCgdUWev3hBzWTzBoG4are Si2w== X-Gm-Message-State: APjAAAX/XP4NPljg9NmA9Vqav/qxIcLw2SyaCpxuW//xGSmi/06eSzed J7fWFQTs6JrOE5gKXujghwh3Yg== X-Google-Smtp-Source: APXvYqyNyFeN8c7NRg92Ink5Ka3Tq28BpS6yLMtX6mFzaLFi4j3T2WUKljAinxR+7Aym0i4rsxBoUg== X-Received: by 2002:a5d:4f89:: with SMTP id d9mr21625889wru.286.1572368540427; Tue, 29 Oct 2019 10:02:20 -0700 (PDT) Received: from 6wind.com (2a01cb0c0005a6000226b0fffeed02fc.ipv6.abo.wanadoo.fr. [2a01:cb0c:5:a600:226:b0ff:feed:2fc]) by smtp.gmail.com with ESMTPSA id y16sm558184wma.39.2019.10.29.10.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2019 10:02:19 -0700 (PDT) Date: Tue, 29 Oct 2019 18:02:18 +0100 From: Olivier Matz To: Andrew Rybchenko Cc: dev@dpdk.org, Anatoly Burakov , Ferruh Yigit , "Giridharan, Ganesan" , Jerin Jacob Kollanukkaran , Kiran Kumar Kokkilagadda , Stephen Hemminger , Thomas Monjalon , Vamsi Krishna Attunuru Message-ID: <20191029170218.6be4cyvqct2oacoi@platinum> References: <20190719133845.32432-1-olivier.matz@6wind.com> <20191028140122.9592-1-olivier.matz@6wind.com> <20191028140122.9592-2-olivier.matz@6wind.com> <6db9f943-235c-7093-4e9d-eacbc6114a80@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6db9f943-235c-7093-4e9d-eacbc6114a80@solarflare.com> User-Agent: NeoMutt/20180716 Subject: Re: [dpdk-dev] [PATCH 1/5] mempool: allow unaligned addr/len in populate virt X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Andrew, On Tue, Oct 29, 2019 at 12:21:27PM +0300, Andrew Rybchenko wrote: > On 10/28/19 5:01 PM, Olivier Matz wrote: > > rte_mempool_populate_virt() currently requires that both addr > > and length are page-aligned. > > > > Remove this uneeded constraint which can be annoying with big > > hugepages (ex: 1GB). > > > > Signed-off-by: Olivier Matz > > One note below, other than that > Reviewed-by: Andrew Rybchenko > > > --- > > lib/librte_mempool/rte_mempool.c | 18 +++++++----------- > > lib/librte_mempool/rte_mempool.h | 3 +-- > > 2 files changed, 8 insertions(+), 13 deletions(-) > > > > diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c > > index 0f29e8712..76cbacdf3 100644 > > --- a/lib/librte_mempool/rte_mempool.c > > +++ b/lib/librte_mempool/rte_mempool.c > > @@ -368,17 +368,11 @@ rte_mempool_populate_virt(struct rte_mempool *mp, char *addr, > > size_t off, phys_len; > > int ret, cnt = 0; > > - /* address and len must be page-aligned */ > > - if (RTE_PTR_ALIGN_CEIL(addr, pg_sz) != addr) > > - return -EINVAL; > > - if (RTE_ALIGN_CEIL(len, pg_sz) != len) > > - return -EINVAL; > > - > > if (mp->flags & MEMPOOL_F_NO_IOVA_CONTIG) > > return rte_mempool_populate_iova(mp, addr, RTE_BAD_IOVA, > > len, free_cb, opaque); > > - for (off = 0; off + pg_sz <= len && > > + for (off = 0; off < len && > > mp->populated_size < mp->size; off += phys_len) { > > iova = rte_mem_virt2iova(addr + off); > > @@ -389,7 +383,10 @@ rte_mempool_populate_virt(struct rte_mempool *mp, char *addr, > > } > > /* populate with the largest group of contiguous pages */ > > - for (phys_len = pg_sz; off + phys_len < len; phys_len += pg_sz) { > > + for (phys_len = RTE_PTR_ALIGN_CEIL(addr + off + 1, pg_sz) - > > + (addr + off); > > + off + phys_len < len; > > If the condition is false on the first check, below we'll populate memory > outside of specified length. So, we should either apply MIN above when > phys_len > is initialized or drop MIN in the next line, but apply MIN when > rte_mempool_populate_iova() is called. Correct, I'll fix it by adding a RTE_MIN(). Maybe I'll just move it outside of the for. > Bonus question not directly related to the patch is iova == RTE_BAD_IOVA > case when !rte_eal_has_hugepages(): > Is it expected that we still use arithmetic iova + phys_len in this case? > I guess comparison will always be false and pages never merged, but it looks > suspicious anyway. Yes, this is not very elegant. I can change the test to if (iova_tmp != RTE_BAD_IOVA || iova_tmp != iova + phys_len) > > > + phys_len = RTE_MIN(phys_len + pg_sz, len - off)) { > > rte_iova_t iova_tmp; > > iova_tmp = rte_mem_virt2iova(addr + off + phys_len); > > @@ -575,8 +572,7 @@ rte_mempool_populate_default(struct rte_mempool *mp) > > * have > > */ > > mz = rte_memzone_reserve_aligned(mz_name, 0, > > - mp->socket_id, flags, > > - RTE_MAX(pg_sz, align)); > > + mp->socket_id, flags, align); > > } > > if (mz == NULL) { > > ret = -rte_errno; > > @@ -601,7 +597,7 @@ rte_mempool_populate_default(struct rte_mempool *mp) > > (void *)(uintptr_t)mz); > > else > > ret = rte_mempool_populate_virt(mp, mz->addr, > > - RTE_ALIGN_FLOOR(mz->len, pg_sz), pg_sz, > > + mz->len, pg_sz, > > rte_mempool_memchunk_mz_free, > > (void *)(uintptr_t)mz); > > if (ret < 0) { > > diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h > > index 8053f7a04..0fe8aa7b8 100644 > > --- a/lib/librte_mempool/rte_mempool.h > > +++ b/lib/librte_mempool/rte_mempool.h > > @@ -1042,9 +1042,8 @@ int rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, > > * A pointer to the mempool structure. > > * @param addr > > * The virtual address of memory that should be used to store objects. > > - * Must be page-aligned. > > * @param len > > - * The length of memory in bytes. Must be page-aligned. > > + * The length of memory in bytes. > > * @param pg_sz > > * The size of memory pages in this virtual area. > > * @param free_cb >