* [dpdk-dev] preallocation of void ** obj_p of rte_ring_dequeue
@ 2013-11-05 10:15 Jose Gavine Cueto
2013-11-05 10:33 ` Cyril Cressent
0 siblings, 1 reply; 7+ messages in thread
From: Jose Gavine Cueto @ 2013-11-05 10:15 UTC (permalink / raw)
To: dev
Hi,
When using *static int rte_ring_dequeue( structe rte_ring * r, void **
obj_p )*, is the user presumed to allocate obj_p , or does this method
allocates this obj_p ?
Cheers,
Pepe
--
To stop learning is like to stop loving.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] preallocation of void ** obj_p of rte_ring_dequeue
2013-11-05 10:15 [dpdk-dev] preallocation of void ** obj_p of rte_ring_dequeue Jose Gavine Cueto
@ 2013-11-05 10:33 ` Cyril Cressent
2013-11-05 10:42 ` Jose Gavine Cueto
2013-11-05 11:18 ` Thomas Monjalon
0 siblings, 2 replies; 7+ messages in thread
From: Cyril Cressent @ 2013-11-05 10:33 UTC (permalink / raw)
To: Jose Gavine Cueto; +Cc: dev
On Tue, Nov 05, 2013 at 06:15:01PM +0800, Jose Gavine Cueto wrote:
>
> When using *static int rte_ring_dequeue( structe rte_ring * r, void **
> obj_p )*, is the user presumed to allocate obj_p , or does this method
> allocates this obj_p ?
This method doesn't allocate anything ; you have to allocate the object
you want to fill yourself.
You can find more details about how to work with rings there:
- DPDK Programmer's Guide (Chapter 5 - Ring Library)
- DPDK API Documentation for rte_ring.h
Both of which are accessible at http://dpdk.org/doc
Quite a few sample applications (examples/ directory in the DPDK
distribution) also make use of rings, notably the quota_watermark one,
so it's also a good place to look at.
On a side note, it looks like the API reference page for rte_ring.h is
broken? It's missing a lot of functions. I'll look into it if I get a
chance.
http://dpdk.org/doc/api/rte__ring_8h.html#func-members
Cyril
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] preallocation of void ** obj_p of rte_ring_dequeue
2013-11-05 10:33 ` Cyril Cressent
@ 2013-11-05 10:42 ` Jose Gavine Cueto
2013-11-05 11:18 ` Thomas Monjalon
1 sibling, 0 replies; 7+ messages in thread
From: Jose Gavine Cueto @ 2013-11-05 10:42 UTC (permalink / raw)
To: Jose Gavine Cueto, dev
Thank you,
I've actually read the code & guide, but I wanted to make sure that what I
understood was correct.
Cheers,
Pepe
On Tue, Nov 5, 2013 at 6:33 PM, Cyril Cressent <cyril.cressent@intel.com>wrote:
> On Tue, Nov 05, 2013 at 06:15:01PM +0800, Jose Gavine Cueto wrote:
> >
> > When using *static int rte_ring_dequeue( structe rte_ring * r, void **
> > obj_p )*, is the user presumed to allocate obj_p , or does this method
> > allocates this obj_p ?
>
> This method doesn't allocate anything ; you have to allocate the object
> you want to fill yourself.
>
> You can find more details about how to work with rings there:
>
> - DPDK Programmer's Guide (Chapter 5 - Ring Library)
> - DPDK API Documentation for rte_ring.h
>
> Both of which are accessible at http://dpdk.org/doc
>
> Quite a few sample applications (examples/ directory in the DPDK
> distribution) also make use of rings, notably the quota_watermark one,
> so it's also a good place to look at.
>
> On a side note, it looks like the API reference page for rte_ring.h is
> broken? It's missing a lot of functions. I'll look into it if I get a
> chance.
> http://dpdk.org/doc/api/rte__ring_8h.html#func-members
>
> Cyril
>
--
To stop learning is like to stop loving.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] preallocation of void ** obj_p of rte_ring_dequeue
2013-11-05 10:33 ` Cyril Cressent
2013-11-05 10:42 ` Jose Gavine Cueto
@ 2013-11-05 11:18 ` Thomas Monjalon
2013-11-05 16:47 ` Jose Gavine Cueto
1 sibling, 1 reply; 7+ messages in thread
From: Thomas Monjalon @ 2013-11-05 11:18 UTC (permalink / raw)
To: Cyril Cressent; +Cc: dev
05/11/2013 11:33, Cyril Cressent :
> On a side note, it looks like the API reference page for rte_ring.h is
> broken? It's missing a lot of functions. I'll look into it if I get a
> chance.
> http://dpdk.org/doc/api/rte__ring_8h.html#func-members
It is fixed by the patch I just sent. Thanks for reporting.
--
Thomas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] preallocation of void ** obj_p of rte_ring_dequeue
2013-11-05 11:18 ` Thomas Monjalon
@ 2013-11-05 16:47 ` Jose Gavine Cueto
2013-11-05 17:54 ` Cyril Cressent
0 siblings, 1 reply; 7+ messages in thread
From: Jose Gavine Cueto @ 2013-11-05 16:47 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
Hi Cyril,
Your'e welcome, and by the way the multiprocess example of simple_mp seems
confusing here:
static int
lcore_recv(__attribute__((unused)) void *arg)
{
unsigned lcore_id = rte_lcore_id();
printf("Starting core %u\n", lcore_id);
while (!quit){
*void *msg;*
if (*rte_ring_dequeue(recv_ring, &msg*) < 0){
usleep(5);
continue;
}
printf("core %u: Received '%s'\n", lcore_id, (char *)msg);
rte_mempool_put(message_pool, msg);
}
return 0;
}
It seems that it isn't allocating msg here, or maybe I'm just missing
something ?
Cheers,
Pepe
On Tue, Nov 5, 2013 at 7:18 PM, Thomas Monjalon
<thomas.monjalon@6wind.com>wrote:
> 05/11/2013 11:33, Cyril Cressent :
> > On a side note, it looks like the API reference page for rte_ring.h is
> > broken? It's missing a lot of functions. I'll look into it if I get a
> > chance.
> > http://dpdk.org/doc/api/rte__ring_8h.html#func-members
>
> It is fixed by the patch I just sent. Thanks for reporting.
> --
> Thomas
>
--
To stop learning is like to stop loving.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] preallocation of void ** obj_p of rte_ring_dequeue
2013-11-05 16:47 ` Jose Gavine Cueto
@ 2013-11-05 17:54 ` Cyril Cressent
2013-11-05 23:28 ` Jose Gavine Cueto
0 siblings, 1 reply; 7+ messages in thread
From: Cyril Cressent @ 2013-11-05 17:54 UTC (permalink / raw)
To: Jose Gavine Cueto; +Cc: dev
On Wed, Nov 06, 2013 at 12:47:13AM +0800, Jose Gavine Cueto wrote:
> Your'e welcome, and by the way the multiprocess example of simple_mp seems
> confusing here:
>
> static int
> lcore_recv(__attribute__((unused)) void *arg)
> {
> unsigned lcore_id = rte_lcore_id();
>
> printf("Starting core %u\n", lcore_id);
> while (!quit){
> void *msg;
> if (rte_ring_dequeue(recv_ring, &msg) < 0){
> usleep(5);
> continue;
> }
> printf("core %u: Received '%s'\n", lcore_id, (char *)msg);
> rte_mempool_put(message_pool, msg);
> }
>
> return 0;
> }
>
> It seems that it isn't allocating msg here, or maybe I'm just missing something
I understand your question better now, and in that light I think my
previous answer was confusing. Let me try to clarify:
A ring only holds *pointers* to objects. You enqueue pointers, and
dequeue those pointers later, somewhere else, usually in another thread.
The allocation/deallocation of the actual objects is none the concern of
the ring and its enqueue/dequeue operations.
If we take the simple_mp example, the msg dequeued by the lcore_recv()
thread is created in mp_command.c and a pointer to that message is
enqueued on "send_ring". If you read carefully how the rings are created
you'll understand how "send_ring" and "recv_ring" relate to each other.
I hope this is a bit clearer,
Cyril
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [dpdk-dev] preallocation of void ** obj_p of rte_ring_dequeue
2013-11-05 17:54 ` Cyril Cressent
@ 2013-11-05 23:28 ` Jose Gavine Cueto
0 siblings, 0 replies; 7+ messages in thread
From: Jose Gavine Cueto @ 2013-11-05 23:28 UTC (permalink / raw)
To: Jose Gavine Cueto, Thomas Monjalon, dev
I see , now its clearer.
Thanks,
Pepe
On Wed, Nov 6, 2013 at 1:54 AM, Cyril Cressent <cyril.cressent@intel.com>wrote:
> On Wed, Nov 06, 2013 at 12:47:13AM +0800, Jose Gavine Cueto wrote:
>
> > Your'e welcome, and by the way the multiprocess example of simple_mp
> seems
> > confusing here:
> >
> > static int
> > lcore_recv(__attribute__((unused)) void *arg)
> > {
> > unsigned lcore_id = rte_lcore_id();
> >
> > printf("Starting core %u\n", lcore_id);
> > while (!quit){
> > void *msg;
> > if (rte_ring_dequeue(recv_ring, &msg) < 0){
> > usleep(5);
> > continue;
> > }
> > printf("core %u: Received '%s'\n", lcore_id, (char *)msg);
> > rte_mempool_put(message_pool, msg);
> > }
> >
> > return 0;
> > }
> >
> > It seems that it isn't allocating msg here, or maybe I'm just missing
> something
>
> I understand your question better now, and in that light I think my
> previous answer was confusing. Let me try to clarify:
>
> A ring only holds *pointers* to objects. You enqueue pointers, and
> dequeue those pointers later, somewhere else, usually in another thread.
> The allocation/deallocation of the actual objects is none the concern of
> the ring and its enqueue/dequeue operations.
>
> If we take the simple_mp example, the msg dequeued by the lcore_recv()
> thread is created in mp_command.c and a pointer to that message is
> enqueued on "send_ring". If you read carefully how the rings are created
> you'll understand how "send_ring" and "recv_ring" relate to each other.
>
> I hope this is a bit clearer,
>
> Cyril
>
--
To stop learning is like to stop loving.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-11-05 23:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-05 10:15 [dpdk-dev] preallocation of void ** obj_p of rte_ring_dequeue Jose Gavine Cueto
2013-11-05 10:33 ` Cyril Cressent
2013-11-05 10:42 ` Jose Gavine Cueto
2013-11-05 11:18 ` Thomas Monjalon
2013-11-05 16:47 ` Jose Gavine Cueto
2013-11-05 17:54 ` Cyril Cressent
2013-11-05 23:28 ` Jose Gavine Cueto
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).