* [dpdk-dev] [PATCH] ivshmem: add all memzones of mempool to metada
@ 2016-06-01 13:18 Ferruh Yigit
2016-06-01 15:07 ` Burakov, Anatoly
2016-06-02 7:04 ` Olivier MATZ
0 siblings, 2 replies; 7+ messages in thread
From: Ferruh Yigit @ 2016-06-01 13:18 UTC (permalink / raw)
To: dev; +Cc: Anatoly Burakov, Olivier Matz, Ferruh Yigit
Mempool consist of multiple memzones, at least from two of them.
ivshmem assumes mempool and elements are all in same memzone.
Updating code to add all memzones when a mempool added.
Fixes: d1d914ebbc25 ("mempool: allocate in several memory chunks by
default")
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
lib/librte_ivshmem/rte_ivshmem.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/lib/librte_ivshmem/rte_ivshmem.c b/lib/librte_ivshmem/rte_ivshmem.c
index c8b332c..5c83920 100644
--- a/lib/librte_ivshmem/rte_ivshmem.c
+++ b/lib/librte_ivshmem/rte_ivshmem.c
@@ -548,25 +548,39 @@ add_ring_to_metadata(const struct rte_ring * r,
}
static int
-add_mempool_to_metadata(const struct rte_mempool * mp,
- struct ivshmem_config * config)
+add_mempool_memzone_to_metadata(const void *addr,
+ struct ivshmem_config *config)
{
- struct rte_memzone * mz;
- int ret;
+ struct rte_memzone *mz;
- mz = get_memzone_by_addr(mp);
- ret = 0;
+ mz = get_memzone_by_addr(addr);
if (!mz) {
RTE_LOG(ERR, EAL, "Cannot find memzone for mempool!\n");
return -1;
}
- /* mempool consists of memzone and ring */
- ret = add_memzone_to_metadata(mz, config);
+ return add_memzone_to_metadata(mz, config);
+}
+
+static int
+add_mempool_to_metadata(const struct rte_mempool *mp,
+ struct ivshmem_config *config)
+{
+ struct rte_mempool_memhdr *memhdr;
+ int ret;
+
+ ret = add_mempool_memzone_to_metadata(mp, config);
if (ret < 0)
return -1;
+ STAILQ_FOREACH(memhdr, &mp->mem_list, next) {
+ ret = add_mempool_memzone_to_metadata(memhdr->addr, config);
+ if (ret < 0)
+ return -1;
+ }
+
+ /* mempool consists of memzone and ring */
return add_ring_to_metadata(mp->ring, config);
}
--
2.5.5
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH] ivshmem: add all memzones of mempool to metada
2016-06-01 13:18 [dpdk-dev] [PATCH] ivshmem: add all memzones of mempool to metada Ferruh Yigit
@ 2016-06-01 15:07 ` Burakov, Anatoly
2016-06-02 7:04 ` Olivier MATZ
1 sibling, 0 replies; 7+ messages in thread
From: Burakov, Anatoly @ 2016-06-01 15:07 UTC (permalink / raw)
To: Yigit, Ferruh, dev; +Cc: Olivier Matz
> From: Yigit, Ferruh
> Sent: Wednesday, June 1, 2016 2:18 PM
> To: dev@dpdk.org
> Cc: Burakov, Anatoly <anatoly.burakov@intel.com>; Olivier Matz
> <olivier.matz@6wind.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: [PATCH] ivshmem: add all memzones of mempool to metada
>
> Mempool consist of multiple memzones, at least from two of them.
> ivshmem assumes mempool and elements are all in same memzone.
>
> Updating code to add all memzones when a mempool added.
>
> Fixes: d1d914ebbc25 ("mempool: allocate in several memory chunks by
> default")
>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
> lib/librte_ivshmem/rte_ivshmem.c | 30 ++++++++++++++++++++++--------
> 1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/lib/librte_ivshmem/rte_ivshmem.c
> b/lib/librte_ivshmem/rte_ivshmem.c
> index c8b332c..5c83920 100644
> --- a/lib/librte_ivshmem/rte_ivshmem.c
> +++ b/lib/librte_ivshmem/rte_ivshmem.c
> @@ -548,25 +548,39 @@ add_ring_to_metadata(const struct rte_ring * r,
> }
>
> static int
> -add_mempool_to_metadata(const struct rte_mempool * mp,
> - struct ivshmem_config * config)
> +add_mempool_memzone_to_metadata(const void *addr,
> + struct ivshmem_config *config)
> {
> - struct rte_memzone * mz;
> - int ret;
> + struct rte_memzone *mz;
>
> - mz = get_memzone_by_addr(mp);
> - ret = 0;
> + mz = get_memzone_by_addr(addr);
>
> if (!mz) {
> RTE_LOG(ERR, EAL, "Cannot find memzone for
> mempool!\n");
> return -1;
> }
>
> - /* mempool consists of memzone and ring */
> - ret = add_memzone_to_metadata(mz, config);
> + return add_memzone_to_metadata(mz, config);
> +}
> +
> +static int
> +add_mempool_to_metadata(const struct rte_mempool *mp,
> + struct ivshmem_config *config)
> +{
> + struct rte_mempool_memhdr *memhdr;
> + int ret;
> +
> + ret = add_mempool_memzone_to_metadata(mp, config);
> if (ret < 0)
> return -1;
>
> + STAILQ_FOREACH(memhdr, &mp->mem_list, next) {
> + ret = add_mempool_memzone_to_metadata(memhdr-
> >addr, config);
> + if (ret < 0)
> + return -1;
> + }
> +
> + /* mempool consists of memzone and ring */
> return add_ring_to_metadata(mp->ring, config);
> }
>
> --
> 2.5.5
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH] ivshmem: add all memzones of mempool to metada
2016-06-01 13:18 [dpdk-dev] [PATCH] ivshmem: add all memzones of mempool to metada Ferruh Yigit
2016-06-01 15:07 ` Burakov, Anatoly
@ 2016-06-02 7:04 ` Olivier MATZ
2016-06-03 11:05 ` Ferruh Yigit
1 sibling, 1 reply; 7+ messages in thread
From: Olivier MATZ @ 2016-06-02 7:04 UTC (permalink / raw)
To: Ferruh Yigit, dev; +Cc: Anatoly Burakov
Hi Ferruh,
Thank you for fixing this issue.
On 06/01/2016 03:18 PM, Ferruh Yigit wrote:
> [PATCH] ivshmem: add all memzones of mempool to metada
Minor comment: it seems the title is truncated
> +static int
> +add_mempool_to_metadata(const struct rte_mempool *mp,
> + struct ivshmem_config *config)
> +{
> + struct rte_mempool_memhdr *memhdr;
> + int ret;
> +
> + ret = add_mempool_memzone_to_metadata(mp, config);
> if (ret < 0)
> return -1;
>
> + STAILQ_FOREACH(memhdr, &mp->mem_list, next) {
> + ret = add_mempool_memzone_to_metadata(memhdr->addr, config);
> + if (ret < 0)
> + return -1;
> + }
> +
> + /* mempool consists of memzone and ring */
> return add_ring_to_metadata(mp->ring, config);
> }
>
In case you missed it: there is a function
rte_mempool_mem_iter() that can be used to browse the
memory chunks of a mempool. It's probably less convenient
to use compared to directly browsing the list, but it
may be more resistant to api changes.
Apart from that:
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Thanks
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH] ivshmem: add all memzones of mempool to metada
2016-06-02 7:04 ` Olivier MATZ
@ 2016-06-03 11:05 ` Ferruh Yigit
2016-06-03 16:29 ` Ferruh Yigit
0 siblings, 1 reply; 7+ messages in thread
From: Ferruh Yigit @ 2016-06-03 11:05 UTC (permalink / raw)
To: Olivier MATZ, dev; +Cc: Anatoly Burakov
On 6/2/2016 8:04 AM, Olivier MATZ wrote:
> Hi Ferruh,
>
> Thank you for fixing this issue.
>
> On 06/01/2016 03:18 PM, Ferruh Yigit wrote:
>> [PATCH] ivshmem: add all memzones of mempool to metada
>
> Minor comment: it seems the title is truncated
>
Right, I will fix in next version of patch.
>> +static int
>> +add_mempool_to_metadata(const struct rte_mempool *mp,
>> + struct ivshmem_config *config)
>> +{
>> + struct rte_mempool_memhdr *memhdr;
>> + int ret;
>> +
>> + ret = add_mempool_memzone_to_metadata(mp, config);
>> if (ret < 0)
>> return -1;
>>
>> + STAILQ_FOREACH(memhdr, &mp->mem_list, next) {
>> + ret = add_mempool_memzone_to_metadata(memhdr->addr, config);
>> + if (ret < 0)
>> + return -1;
>> + }
>> +
>> + /* mempool consists of memzone and ring */
>> return add_ring_to_metadata(mp->ring, config);
>> }
>>
>
> In case you missed it: there is a function
> rte_mempool_mem_iter() that can be used to browse the
> memory chunks of a mempool. It's probably less convenient
> to use compared to directly browsing the list, but it
> may be more resistant to api changes.
I wasn't aware rte_mempool_mem_iter(), I will update the patch to use this.
>
> Apart from that:
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
>
> Thanks
>
Thanks,
ferruh
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH] ivshmem: add all memzones of mempool to metada
2016-06-03 11:05 ` Ferruh Yigit
@ 2016-06-03 16:29 ` Ferruh Yigit
2016-06-03 16:38 ` [dpdk-dev] [PATCH v2] ivshmem: add all memzones of mempool to metadata Ferruh Yigit
0 siblings, 1 reply; 7+ messages in thread
From: Ferruh Yigit @ 2016-06-03 16:29 UTC (permalink / raw)
To: Olivier MATZ, dev; +Cc: Anatoly Burakov
On 6/3/2016 12:05 PM, Ferruh Yigit wrote:
> On 6/2/2016 8:04 AM, Olivier MATZ wrote:
>> Hi Ferruh,
>>
>> Thank you for fixing this issue.
>>
>> On 06/01/2016 03:18 PM, Ferruh Yigit wrote:
>>> [PATCH] ivshmem: add all memzones of mempool to metada
>>
>> Minor comment: it seems the title is truncated
>>
>
> Right, I will fix in next version of patch.
>
>>> +static int
>>> +add_mempool_to_metadata(const struct rte_mempool *mp,
>>> + struct ivshmem_config *config)
>>> +{
>>> + struct rte_mempool_memhdr *memhdr;
>>> + int ret;
>>> +
>>> + ret = add_mempool_memzone_to_metadata(mp, config);
>>> if (ret < 0)
>>> return -1;
>>>
>>> + STAILQ_FOREACH(memhdr, &mp->mem_list, next) {
>>> + ret = add_mempool_memzone_to_metadata(memhdr->addr, config);
>>> + if (ret < 0)
>>> + return -1;
>>> + }
>>> +
>>> + /* mempool consists of memzone and ring */
>>> return add_ring_to_metadata(mp->ring, config);
>>> }
>>>
>>
>> In case you missed it: there is a function
>> rte_mempool_mem_iter() that can be used to browse the
>> memory chunks of a mempool. It's probably less convenient
>> to use compared to directly browsing the list, but it
>> may be more resistant to api changes.
>
> I wasn't aware rte_mempool_mem_iter(), I will update the patch to use this.
>
Although I prefer using the rte_mempool_mem_iter(); it is not
straightforward because of the const qualifier of mp, and
rte_mempool_mem_iter() doesn't accepts the const type, and casting const
to non-const causes a compile warning:
_"error: cast discards ‘const’ qualifier from pointer target type"_
An option is duplicating mp, (or part of it mp->mem_list) but that is
ugly and can cause potentials defects in the future, another option is
to use uint64_t to do pointer conversion, even uglier :), so I don't
want to use this API for this case.
So, I will only update the patch title and send a v2.
>>
>> Apart from that:
>> Acked-by: Olivier Matz <olivier.matz@6wind.com>
>>
>> Thanks
>>
>
> Thanks,
> ferruh
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [dpdk-dev] [PATCH v2] ivshmem: add all memzones of mempool to metadata
2016-06-03 16:29 ` Ferruh Yigit
@ 2016-06-03 16:38 ` Ferruh Yigit
2016-06-07 10:08 ` Thomas Monjalon
0 siblings, 1 reply; 7+ messages in thread
From: Ferruh Yigit @ 2016-06-03 16:38 UTC (permalink / raw)
To: dev; +Cc: Anatoly Burakov, Olivier Matz, Ferruh Yigit
Mempool consist of multiple memzones, at least from two of them.
ivshmem assumes mempool and elements are all in same memzone.
Updating code to add all memzones when a mempool added.
Fixes: d1d914ebbc25 ("mempool: allocate in several memory chunks by
default")
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
---
v2:
* fix patch title metada -> metadata
---
lib/librte_ivshmem/rte_ivshmem.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/lib/librte_ivshmem/rte_ivshmem.c b/lib/librte_ivshmem/rte_ivshmem.c
index c8b332c..5c83920 100644
--- a/lib/librte_ivshmem/rte_ivshmem.c
+++ b/lib/librte_ivshmem/rte_ivshmem.c
@@ -548,25 +548,39 @@ add_ring_to_metadata(const struct rte_ring * r,
}
static int
-add_mempool_to_metadata(const struct rte_mempool * mp,
- struct ivshmem_config * config)
+add_mempool_memzone_to_metadata(const void *addr,
+ struct ivshmem_config *config)
{
- struct rte_memzone * mz;
- int ret;
+ struct rte_memzone *mz;
- mz = get_memzone_by_addr(mp);
- ret = 0;
+ mz = get_memzone_by_addr(addr);
if (!mz) {
RTE_LOG(ERR, EAL, "Cannot find memzone for mempool!\n");
return -1;
}
- /* mempool consists of memzone and ring */
- ret = add_memzone_to_metadata(mz, config);
+ return add_memzone_to_metadata(mz, config);
+}
+
+static int
+add_mempool_to_metadata(const struct rte_mempool *mp,
+ struct ivshmem_config *config)
+{
+ struct rte_mempool_memhdr *memhdr;
+ int ret;
+
+ ret = add_mempool_memzone_to_metadata(mp, config);
if (ret < 0)
return -1;
+ STAILQ_FOREACH(memhdr, &mp->mem_list, next) {
+ ret = add_mempool_memzone_to_metadata(memhdr->addr, config);
+ if (ret < 0)
+ return -1;
+ }
+
+ /* mempool consists of memzone and ring */
return add_ring_to_metadata(mp->ring, config);
}
--
2.5.5
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] [PATCH v2] ivshmem: add all memzones of mempool to metadata
2016-06-03 16:38 ` [dpdk-dev] [PATCH v2] ivshmem: add all memzones of mempool to metadata Ferruh Yigit
@ 2016-06-07 10:08 ` Thomas Monjalon
0 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2016-06-07 10:08 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, Anatoly Burakov, Olivier Matz
2016-06-03 17:38, Ferruh Yigit:
> Mempool consist of multiple memzones, at least from two of them.
> ivshmem assumes mempool and elements are all in same memzone.
>
> Updating code to add all memzones when a mempool added.
>
> Fixes: d1d914ebbc25 ("mempool: allocate in several memory chunks by
> default")
>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
Applied, thanks
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-06-07 10:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-01 13:18 [dpdk-dev] [PATCH] ivshmem: add all memzones of mempool to metada Ferruh Yigit
2016-06-01 15:07 ` Burakov, Anatoly
2016-06-02 7:04 ` Olivier MATZ
2016-06-03 11:05 ` Ferruh Yigit
2016-06-03 16:29 ` Ferruh Yigit
2016-06-03 16:38 ` [dpdk-dev] [PATCH v2] ivshmem: add all memzones of mempool to metadata Ferruh Yigit
2016-06-07 10:08 ` Thomas Monjalon
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).