mempool: fix comments for mempool create functions
PATCH 1/2 mempool: fix comments for mempool create functions
--- lib/librte_mempool/rte_mempool.c | 4 +--- lib/librte_mempool/rte_mempool.h | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-)
lib/librte_mempool/rte_mempool.c +1 -3
@@ -908,9 +908,7 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,/* * Create the mempool over already allocated chunk of memory. * That external memory buffer can consists of physically disjoint pages. -* Setting vaddr to NULL, makes mempool to fallback to original behaviour -* and allocate space for mempool and it's elements as one big chunk of -* physically continuos memory. +* Setting vaddr to NULL, makes mempool to fallback to original behaviour. */ struct rte_mempool * rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
lib/librte_mempool/rte_mempool.h +1 -3
@@ -591,8 +591,6 @@ typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *);* * This function uses ``memzone_reserve()`` to allocate memory. The * pool contains n elements of elt_size. Its size is set to n. -* All elements of the mempool are allocated together with the mempool header, -* in one physically continuous chunk of memory. * * @param name * The name of the mempool.
@@ -748,7 +746,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,* * The mempool is allocated and initialized, but it is not populated: no * memory is allocated for the mempool elements. The user has to call -* rte_mempool_populate_*() or to add memory chunks to the pool. Once +* rte_mempool_populate_*() to add memory chunks to the pool. Once * populated, the user may also want to initialize each object with * rte_mempool_obj_iter(). *
Signature · 1 line
2.7.4
PATCH 2/2 mempool: fix comments for no contiguous flag
--- lib/librte_mempool/rte_mempool.c | 4 +++- lib/librte_mempool/rte_mempool.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)
lib/librte_mempool/rte_mempool.c +3 -1
@@ -340,7 +340,9 @@ rte_mempool_free_memchunks(struct rte_mempool *mp) }/* Add objects in the pool, using a physically contiguous memory -* zone. Return the number of objects added, or a negative value +* zone if MEMPOOL_F_NO_PHYS_CONTIG flag is not set. +* +* Return the number of objects added, or a negative value * on error. */ int
lib/librte_mempool/rte_mempool.h +3 -0
@@ -798,6 +798,9 @@ rte_mempool_free(struct rte_mempool *mp);* Add a virtually and physically contiguous memory chunk in the pool * where objects can be instanciated. * +* mempool flag MEMPOOL_F_NO_PHYS_CONTIG changes behavior of the function +* and removes physical contiguous constraint. +* * @param mp * A pointer to the mempool structure. * @param vaddr
Signature · 1 line
2.7.4
Hi Ferruh,
Thanks for checking the API documentation.
Please see few comments below.
Quoted 14 lines · Ferruh Yigit
Fixes 85226f9c526b ("mempool: introduce a function to create an empty pool")Fixes d1d914ebbc25 ("mempool: allocate in several memory chunks by default")Signed-off-by Ferruh Yigit <[email protected]>--- lib/librte_mempool/rte_mempool.c | 4 +--- lib/librte_mempool/rte_mempool.h | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-)lib/librte_mempool/rte_mempool.c +0
-0
lib/librte_mempool/rte_mempool.c rte_mempool_create(const char *name, unsigned n, unsigned elt_size, · line 911
Quoted 7 lines
lib/librte_mempool/rte_mempool.c +1
-3@@ -908,9 +908,7 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,/* * Create the mempool over already allocated chunk of memory. * That external memory buffer can consists of physically disjoint pages. -* Setting vaddr to NULL, makes mempool to fallback to original behaviour -* and allocate space for mempool and it's elements as one big chunk of -* physically continuos memory. +* Setting vaddr to NULL, makes mempool to fallback to original behaviour.
I would replace "original behaviour" by "rte_mempool_create() behaviour".
lib/librte_mempool/rte_mempool.h typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *); · line 595
Quoted 13 lines
lib/librte_mempool/rte_mempool.c +0
-0*/ struct rte_mempool * rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,lib/librte_mempool/rte_mempool.h +0
-2@@ -591,8 +591,6 @@ typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *);* * This function uses ``memzone_reserve()`` to allocate memory. The * pool contains n elements of elt_size. Its size is set to n. -* All elements of the mempool are allocated together with the mempool header, -* in one physically continuous chunk of memory.
While there, maybe we could replace ``memzone_reserve()`` by ``rte_memzone_reserve()``.
Quoted 13 lines
lib/librte_mempool/rte_mempool.h +1
-1* * @param name * The name of the mempool. @@ -748,7 +746,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,* * The mempool is allocated and initialized, but it is not populated: no * memory is allocated for the mempool elements. The user has to call -* rte_mempool_populate_*() or to add memory chunks to the pool. Once +* rte_mempool_populate_*() to add memory chunks to the pool. Once * populated, the user may also want to initialize each object with * rte_mempool_obj_iter(). *
Re: [PATCH 2/2] mempool: fix comments for no contiguous flag
In reply to Ferruh YigitHi Ferruh,
Quoted 29 lines · Ferruh Yigit
Fixes ce94a51ff05c ("mempool: add flag for removing phys contiguous constraint")Signed-off-by Ferruh Yigit <[email protected]>--- lib/librte_mempool/rte_mempool.c | 4 +++- lib/librte_mempool/rte_mempool.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)lib/librte_mempool/rte_mempool.c +3
-1@@ -340,7 +340,9 @@ rte_mempool_free_memchunks(struct rte_mempool *mp) }/* Add objects in the pool, using a physically contiguous memory -* zone. Return the number of objects added, or a negative value +* zone if MEMPOOL_F_NO_PHYS_CONTIG flag is not set. +* +* Return the number of objects added, or a negative value * on error. */ int lib/librte_mempool/rte_mempool.h +0
-0
lib/librte_mempool/rte_mempool.h rte_mempool_free(struct rte_mempool *mp); · line 806
Quoted 9 lines
lib/librte_mempool/rte_mempool.h +3
-0@@ -798,6 +798,9 @@ rte_mempool_free(struct rte_mempool *mp);* Add a virtually and physically contiguous memory chunk in the pool * where objects can be instanciated. * +* mempool flag MEMPOOL_F_NO_PHYS_CONTIG changes behavior of the function +* and removes physical contiguous constraint. +* * @param mp * A pointer to the mempool structure. * @param vaddr
Not sure I'm getting why you add these comments, as I don't see any usage of MEMPOOL_F_NO_PHYS_CONTIG in rte_mempool_populate_phys().
Could you describe what makes you think the API comments are wrong here?
Thanks,
Olivier
Re: [PATCH 2/2] mempool: fix comments for no contiguous flag
Hi Olivier,
Quoted 45 lines · Olivier Matz
Hi Ferruh,
Quoted 29 lines · Ferruh Yigit
Fixes ce94a51ff05c ("mempool: add flag for removing phys contiguous constraint")Signed-off-by Ferruh Yigit <[email protected]>--- lib/librte_mempool/rte_mempool.c | 4 +++- lib/librte_mempool/rte_mempool.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)lib/librte_mempool/rte_mempool.c +3
-1@@ -340,7 +340,9 @@ rte_mempool_free_memchunks(struct rte_mempool *mp) }/* Add objects in the pool, using a physically contiguous memory -* zone. Return the number of objects added, or a negative value +* zone if MEMPOOL_F_NO_PHYS_CONTIG flag is not set. +* +* Return the number of objects added, or a negative value * on error. */ int lib/librte_mempool/rte_mempool.h +0
-0lib/librte_mempool/rte_mempool.h rte_mempool_free(struct rte_mempool *mp); · line 806
Quoted 9 lines
lib/librte_mempool/rte_mempool.h +3
-0@@ -798,6 +798,9 @@ rte_mempool_free(struct rte_mempool *mp);* Add a virtually and physically contiguous memory chunk in the pool * where objects can be instanciated. * +* mempool flag MEMPOOL_F_NO_PHYS_CONTIG changes behavior of the function +* and removes physical contiguous constraint. +* * @param mp * A pointer to the mempool structure. * @param vaddr Not sure I'm getting why you add these comments, as I don't see any usage of
MEMPOOL_F_NO_PHYS_CONTIGinrte_mempool_populate_phys().
Quoted 1 line
Could you describe what makes you think the API comments are wrong here?
rte_mempool_populate_phys() now can get RTE_BAD_PHYS_ADDR as "paddr" variable, and when paddr == RTE_BAD_PHYS_ADDR, function no more quarantines that populated items are physically continuous.
Like how this is used in rte_mempool_populate_phys_tab(), if MEMPOOL_F_NO_PHYS_CONTIG is set rte_mempool_populate_phys() called for whole virtually continuous memory (len: pg_num * pg_size), so resulting items may not be in physically continuous addresses, so function comment becomes wrong.
Although MEMPOOL_F_NO_PHYS_CONTIG is not used within the rte_mempool_populate_phys(), as far as I can see flag has a side effect on the functionality.
And please help on wording if it is not accurate.
Quoted 4 lines
Thanks,
Olivier
Quoted 47 lines · Olivier Matz
Hi Ferruh,
Thanks for checking the API documentation.
Please see few comments below.Quoted 14 lines · Ferruh Yigit
Fixes 85226f9c526b ("mempool: introduce a function to create an empty pool")Fixes d1d914ebbc25 ("mempool: allocate in several memory chunks by default")Signed-off-by Ferruh Yigit <[email protected]>--- lib/librte_mempool/rte_mempool.c | 4 +--- lib/librte_mempool/rte_mempool.h | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-)lib/librte_mempool/rte_mempool.c +0
-0lib/librte_mempool/rte_mempool.c rte_mempool_create(const char *name, unsigned n, unsigned elt_size, · line 911
Quoted 7 lines
lib/librte_mempool/rte_mempool.c +1
-3@@ -908,9 +908,7 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,/* * Create the mempool over already allocated chunk of memory. * That external memory buffer can consists of physically disjoint pages. -* Setting vaddr to NULL, makes mempool to fallback to original behaviour -* and allocate space for mempool and it's elements as one big chunk of -* physically continuos memory. +* Setting vaddr to NULL, makes mempool to fallback to original behaviour. I would replace "original behaviour" by "
rte_mempool_create()behaviour".lib/librte_mempool/rte_mempool.h typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *); · line 595
Quoted 13 lines
lib/librte_mempool/rte_mempool.c +0
-0*/ struct rte_mempool * rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,lib/librte_mempool/rte_mempool.h +0
-2@@ -591,8 +591,6 @@ typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *);* * This function uses ``memzone_reserve()`` to allocate memory. The * pool contains n elements of elt_size. Its size is set to n. -* All elements of the mempool are allocated together with the mempool header, -* in one physically continuous chunk of memory. While there, maybe we could replace ``memzone_reserve()`` by ``rte_memzone_reserve()``.
Quoted 13 lines
lib/librte_mempool/rte_mempool.h rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size, · line 752
Quoted 13 lines
lib/librte_mempool/rte_mempool.h +1
-1* * @param name * The name of the mempool. @@ -748,7 +746,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,* * The mempool is allocated and initialized, but it is not populated: no * memory is allocated for the mempool elements. The user has to call -* rte_mempool_populate_*() or to add memory chunks to the pool. Once +* rte_mempool_populate_*() to add memory chunks to the pool. Once * populated, the user may also want to initialize each object with * rte_mempool_obj_iter(). *
Thanks for the comments, I will send a new version of the patch with suggested fixes.
Thanks,
ferruh
Re: [PATCH 2/2] mempool: fix comments for no contiguous flag
In reply to Ferruh YigitHi Ferruh,
Quoted 60 lines · Ferruh Yigit
Hi Olivier,
Quoted 45 lines · Olivier Matz
Hi Ferruh,
Quoted 29 lines · Ferruh Yigit
Fixes ce94a51ff05c ("mempool: add flag for removing phys contiguous constraint")Signed-off-by Ferruh Yigit <[email protected]>--- lib/librte_mempool/rte_mempool.c | 4 +++- lib/librte_mempool/rte_mempool.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-)lib/librte_mempool/rte_mempool.c +3
-1@@ -340,7 +340,9 @@ rte_mempool_free_memchunks(struct rte_mempool *mp) }/* Add objects in the pool, using a physically contiguous memory -* zone. Return the number of objects added, or a negative value +* zone if MEMPOOL_F_NO_PHYS_CONTIG flag is not set. +* +* Return the number of objects added, or a negative value * on error. */ int lib/librte_mempool/rte_mempool.h +0
-0lib/librte_mempool/rte_mempool.h rte_mempool_free(struct rte_mempool *mp); · line 806
Quoted 9 lines
lib/librte_mempool/rte_mempool.h +3
-0@@ -798,6 +798,9 @@ rte_mempool_free(struct rte_mempool *mp);* Add a virtually and physically contiguous memory chunk in the pool * where objects can be instanciated. * +* mempool flag MEMPOOL_F_NO_PHYS_CONTIG changes behavior of the function +* and removes physical contiguous constraint. +* * @param mp * A pointer to the mempool structure. * @param vaddr Not sure I'm getting why you add these comments, as I don't see any usage of
MEMPOOL_F_NO_PHYS_CONTIGinrte_mempool_populate_phys().Quoted 1 line
Could you describe what makes you think the API comments are wrong here?
rte_mempool_populate_phys()now can getRTE_BAD_PHYS_ADDRas "paddr" variable, and when paddr ==RTE_BAD_PHYS_ADDR, function no more quarantines that populated items are physically continuous.Like how this is used in
rte_mempool_populate_phys_tab(), ifMEMPOOL_F_NO_PHYS_CONTIGis setrte_mempool_populate_phys()called for whole virtually continuous memory (len:pg_num*pg_size), so resulting items may not be in physically continuous addresses, so function comment becomes wrong.
Quoted 5 lines
Although
MEMPOOL_F_NO_PHYS_CONTIGis not used within therte_mempool_populate_phys(), as far as I can see flag has a side effect on the functionality.And please help on wording if it is not accurate.
OK, so I think we should just talk about paddr in the API comment of rte_mempool_populate_phys(), not about the flag which is already documented in mempool_create*().
I suggest the following:
lib/librte_mempool/rte_mempool.h +4 -0
@@ -800,6 +800,10 @@ rte_mempool_free(struct rte_mempool *mp);* Add a virtually and physically contiguous memory chunk in the pool * where objects can be instanciated. * +* If the given physical address is unknown (paddr = RTE_BAD_PHYS_ADDR), +* the chunk doesn't need to be physically contiguous (only virtually), +* and allocated objects may span two pages. +* * @param mp * A pointer to the mempool structure. * @param vaddr
What do you think?
Regards
Olivier
PATCH v2 1/2 mempool: fix comments for mempool create functions
In reply to Ferruh Yigit--- lib/librte_mempool/rte_mempool.c | 5 ++--- lib/librte_mempool/rte_mempool.h | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-)
lib/librte_mempool/rte_mempool.c +2 -3
@@ -908,9 +908,8 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size,/* * Create the mempool over already allocated chunk of memory. * That external memory buffer can consists of physically disjoint pages. -* Setting vaddr to NULL, makes mempool to fallback to original behaviour -* and allocate space for mempool and it's elements as one big chunk of -* physically continuos memory. +* Setting vaddr to NULL, makes mempool to fallback to rte_mempool_create() +* behavior. */ struct rte_mempool * rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
lib/librte_mempool/rte_mempool.h +2 -4
@@ -589,10 +589,8 @@ typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *);/** * Create a new mempool named *name* in memory. * -* This function uses ``memzone_reserve()`` to allocate memory. The +* This function uses ``rte_memzone_reserve()`` to allocate memory. The * pool contains n elements of elt_size. Its size is set to n. -* All elements of the mempool are allocated together with the mempool header, -* in one physically continuous chunk of memory. * * @param name * The name of the mempool.
@@ -748,7 +746,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,* * The mempool is allocated and initialized, but it is not populated: no * memory is allocated for the mempool elements. The user has to call -* rte_mempool_populate_*() or to add memory chunks to the pool. Once +* rte_mempool_populate_*() to add memory chunks to the pool. Once * populated, the user may also want to initialize each object with * rte_mempool_obj_iter(). *
Signature · 1 line
2.7.4
PATCH v2 2/2 mempool: fix comments for no contiguous flag
--- lib/librte_mempool/rte_mempool.h | 4 ++++ 1 file changed, 4 insertions(+)
lib/librte_mempool/rte_mempool.h +4 -0
@@ -798,6 +798,10 @@ rte_mempool_free(struct rte_mempool *mp);* Add a virtually and physically contiguous memory chunk in the pool * where objects can be instanciated. * +* If the given physical address is unknown (paddr = RTE_BAD_PHYS_ADDR), +* the chunk doesn't need to be physically contiguous (only virtually), +* and allocated objects may span two pages. +* * @param mp * A pointer to the mempool structure. * @param vaddr
Signature · 1 line
2.7.4
Quoted 5 lines · Ferruh Yigit
Fixes 85226f9c526b ("mempool: introduce a function to create an empty pool")Fixes d1d914ebbc25 ("mempool: allocate in several memory chunks by default")Signed-off-by Ferruh Yigit <[email protected]>---
Series:
Thanks
Thomas Monjalon
Applied2016-10-03 17:06, Olivier Matz:
Quoted 8 lines · Ferruh Yigit
Quoted 4 lines
Fixes 85226f9c526b ("mempool: introduce a function to create an empty pool")Fixes d1d914ebbc25 ("mempool: allocate in several memory chunks by default")Signed-off-by Ferruh Yigit <[email protected]>Series:
Acked-by Olivier Matz <[email protected]>
Applied, thanks