Skip to contentSkip to conversation

Regarding rte_memzone_reserve with len =0

DISCUSSION Gonzalez Monroy, Sergio 3 participants 4 messages May 6, 2015 – May 13, 2015

lore
Share & tools
lore
#0 lore raw

Hi,

I was wondering about the use case of rte_memzone_reserve_xxxx APIs with len=0.

From the docs (http://dpdk.org/doc/api/rte__memzone_8h.html):
len The size of the memory to be reserved. If it is 0, the biggest contiguous zone will be reserved.

What are the use cases?
When would you want a memzone of undetermined size?

Any thoughts appreciated.

Sergio

#1 lore raw

Hi Sergio,

Quoted 5 lines · Sergio

Hi,

I was wondering about the use case of rte_memzone_reserve_xxxx APIs with len=0.

Quoted 8 lines

From the docs (http://dpdk.org/doc/api/rte__memzone_8h.html):
len The size of the memory to be reserved. If it is 0, the
biggest contiguous zone will be reserved.

What are the use cases?
When would you want a memzone of undetermined size?

Any thoughts appreciated.

As the application does not have access to the lengths of memory segments, probably the initial idea is when an application wants to allocate more memory that the biggest segment.

Example, the application wants to allocate 1G (even fragmented):

- the easy case is when it can be done in one call to rte_memzone_reserve(1G)

- else, the application can iterate like in this sample:

     remain = 1 * 1024 * 1024 * 1024;
     while (remain > 0) {
         mz = rte_memzone_reserve(remain);
         if (mz != NULL)
            return 0;
         mz = rte_memzone_reserve(remain);
         if (mz == NULL)
            return -1;
         remain -= mz->len;
     }

Regards,
Olivier

#2 lore raw
Quoted 26 lines · Olivier MATZ

Hi Sergio,

Quoted 5 lines · Sergio

Hi,

I was wondering about the use case of rte_memzone_reserve_xxxx APIs with len=0.

Quoted 8 lines

From the docs (http://dpdk.org/doc/api/rte__memzone_8h.html):
len The size of the memory to be reserved. If it is 0, the
biggest contiguous zone will be reserved.

What are the use cases?
When would you want a memzone of undetermined size?

Any thoughts appreciated.

As the application does not have access to the lengths of memory segments, probably the initial idea is when an application wants to allocate more memory that the biggest segment.

Example, the application wants to allocate 1G (even fragmented):

- the easy case is when it can be done in one call to rte_memzone_reserve(1G)

Quoted 8 lines

- else, the application can iterate like in this sample:

     remain = 1 * 1024 * 1024 * 1024;
     while (remain > 0) {
         mz = rte_memzone_reserve(remain);
         if (mz != NULL)
            return 0;
         mz = rte_memzone_reserve(remain);

You meant rte_memzone_reserve(0) here, right?

Quoted 5 lines

if (mz == NULL)

            return -1;
         remain -= mz->len;
     }

Thanks Olivier, that makes sense.

Sergio

Quoted 3 lines

Regards,
Olivier

#3 lore raw
Quoted 29 lines · Sergio
Quoted 28 lines · Olivier MATZ

Hi Sergio,

Quoted 5 lines · Sergio

Hi,

I was wondering about the use case of rte_memzone_reserve_xxxx APIs with len=0.

Quoted 8 lines

From the docs (http://dpdk.org/doc/api/rte__memzone_8h.html):
len The size of the memory to be reserved. If it is 0, the
biggest contiguous zone will be reserved.

What are the use cases?
When would you want a memzone of undetermined size?

Any thoughts appreciated.

As the application does not have access to the lengths of memory segments, probably the initial idea is when an application wants to allocate more memory that the biggest segment.

Example, the application wants to allocate 1G (even fragmented):

- the easy case is when it can be done in one call to rte_memzone_reserve(1G)

- else, the application can iterate like in this sample:

Quoted 7 lines
Quoted 6 lines
     remain = 1 * 1024 * 1024 * 1024;
     while (remain > 0) {
         mz = rte_memzone_reserve(remain);
         if (mz != NULL)
            return 0;
         mz = rte_memzone_reserve(remain);

You meant rte_memzone_reserve(0) here, right?

yes, sorry for the typo