From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id C464E567E for ; Wed, 27 May 2015 09:52:47 +0200 (CEST) Received: by wgv5 with SMTP id 5so1969499wgv.1 for ; Wed, 27 May 2015 00:52:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-type :content-disposition:in-reply-to; bh=2onfC/ppxqiyIxZdbZY5q6HkTvbozpCF80mofUG0GWI=; b=YOw1brTyRNf9bn9aL4I5dglF5+JhaIMFgoAy2utIaWVTWT8iAC7c/DxqljDyev3ljA CjY2zufsXKxxV+T681hVHExXA8Iz2Psnfa8QSoLQS/LnbO+QyOqS+yFfhPixwGfCd0Fe L0xuIbqLFvz046GQw4oLpRFZxAe6v+C7GdeP9j/rDuxbCFwUZY44ZK8+x6ESY+fLDv69 j/KFgaqYRMC62cPVpriSCzcfqBbZPYXYl8sVFSqEYli7gX+cAwxUKAAjxz/aeJzRPINn PPPfYb2DBByc4H9r+PvjA2c4ZLQS/JtfFrSWZqWaduVj8MqKe0jetHLqyiF+PAFgiX1M 0teQ== X-Gm-Message-State: ALoCoQmjcCWjp1trfOjm/aY1WwMrC86sEXIYULCDNrEOo69JPmTGS9AEhyeQPtqUwzQYD9D3FQCG X-Received: by 10.180.92.162 with SMTP id cn2mr3422136wib.26.1432713167660; Wed, 27 May 2015 00:52:47 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by mx.google.com with ESMTPSA id uc9sm25505281wjc.7.2015.05.27.00.52.46 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 27 May 2015 00:52:46 -0700 (PDT) Date: Wed, 27 May 2015 09:52:41 +0200 From: Adrien Mazarguil To: Konstantin Ananyev Message-ID: <20150527075241.GO26795@6wind.com> Mail-Followup-To: Konstantin Ananyev , dev@dpdk.org References: <1432571266-25840-2-git-send-email-adrien.mazarguil@6wind.com> <1432687269-4696-1-git-send-email-konstantin.ananyev@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1432687269-4696-1-git-send-email-konstantin.ananyev@intel.com> Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCHv2] mempool: fix pages computation to determine number of objects X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 May 2015 07:52:48 -0000 On Wed, May 27, 2015 at 01:41:09AM +0100, Konstantin Ananyev wrote: > v2: > - As suggested in comments use slightly different approach for the fix. > > In rte_mempool_obj_iter(), when element boundary coincides with page boundary, > even if a single page is required per object, a loop checks that the next page > is contiguous and drops the first oneo therwise. > > This commit checks subsequent pages only when several are required per object. > > Signed-off-by: Konstantin Ananyev Tested and validated patch which supersedes my previous attempt in the other thread. There's only a typo in the commit log ("oneo therwise"). Reviewed-by: Adrien Mazarguil > --- > lib/librte_mempool/rte_mempool.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c > index 01972ba..ecb03b3 100644 > --- a/lib/librte_mempool/rte_mempool.c > +++ b/lib/librte_mempool/rte_mempool.c > @@ -156,7 +156,7 @@ rte_mempool_obj_iter(void *vaddr, uint32_t elt_num, size_t elt_sz, size_t align, > rte_mempool_obj_iter_t obj_iter, void *obj_iter_arg) > { > uint32_t i, j, k; > - uint32_t pgn; > + uint32_t pgn, pgf; > uintptr_t end, start, va; > uintptr_t pg_sz; > > @@ -171,10 +171,14 @@ rte_mempool_obj_iter(void *vaddr, uint32_t elt_num, size_t elt_sz, size_t align, > start = RTE_ALIGN_CEIL(va, align); > end = start + elt_sz; > > - pgn = (end >> pg_shift) - (start >> pg_shift); > + /* index of the first page for the next element. */ > + pgf = (end >> pg_shift) - (start >> pg_shift); > + > + /* index of the last page for the current element. */ > + pgn = ((end - 1) >> pg_shift) - (start >> pg_shift); > pgn += j; > > - /* do we have enough space left for the next element. */ > + /* do we have enough space left for the element. */ > if (pgn >= pg_num) > break; > > @@ -194,7 +198,7 @@ rte_mempool_obj_iter(void *vaddr, uint32_t elt_num, size_t elt_sz, size_t align, > obj_iter(obj_iter_arg, (void *)start, > (void *)end, i); > va = end; > - j = pgn; > + j += pgf; > i++; > } else { > va = RTE_ALIGN_CEIL((va + 1), pg_sz); > -- > 1.8.5.3 > -- Adrien Mazarguil 6WIND