From: Konstantin Ananyev <konstantin.ananyev@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCHv2] mempool: fix pages computation to determine number of objects
Date: Wed, 27 May 2015 01:41:09 +0100 [thread overview]
Message-ID: <1432687269-4696-1-git-send-email-konstantin.ananyev@intel.com> (raw)
In-Reply-To: <1432571266-25840-2-git-send-email-adrien.mazarguil@6wind.com>
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 <konstantin.ananyev@intel.com>
---
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
next prev parent reply other threads:[~2015-05-27 0:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-25 16:27 [dpdk-dev] [PATCH 1/2] mempool: fix returned value on 64 bit after counting objects Adrien Mazarguil
2015-05-25 16:27 ` [dpdk-dev] [PATCH 2/2] mempool: fix pages computation to determine number of objects Adrien Mazarguil
2015-05-25 18:20 ` Ananyev, Konstantin
2015-05-26 9:14 ` Adrien Mazarguil
2015-05-27 0:41 ` Konstantin Ananyev [this message]
2015-05-27 7:52 ` [dpdk-dev] [PATCHv2] " Adrien Mazarguil
2015-05-27 8:40 ` [dpdk-dev] [PATCHv3] " Konstantin Ananyev
2015-05-29 15:58 ` Thomas Monjalon
2015-05-27 0:43 ` [dpdk-dev] [PATCH 1/2] mempool: fix returned value on 64 bit after counting objects Ananyev, Konstantin
2015-05-29 15:57 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432687269-4696-1-git-send-email-konstantin.ananyev@intel.com \
--to=konstantin.ananyev@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).