All of lore.kernel.org
 help / color / mirror / Atom feed
* preallocation of void ** obj_p of rte_ring_dequeue
@ 2013-11-05 10:15 Jose Gavine Cueto
       [not found] ` <CAJ5bv6EVB-oQuVqghaPq+6UQjkiLbhy6x3ascsYZhT_14bBYRg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Jose Gavine Cueto @ 2013-11-05 10:15 UTC (permalink / raw)
  To: dev-VfR2kkLFssw

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: preallocation of void ** obj_p of rte_ring_dequeue
       [not found] ` <CAJ5bv6EVB-oQuVqghaPq+6UQjkiLbhy6x3ascsYZhT_14bBYRg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 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-VfR2kkLFssw

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: 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-VfR2kkLFssw

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-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>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: 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
       [not found]       ` <201311051218.27016.thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Thomas Monjalon @ 2013-11-05 11:18 UTC (permalink / raw)
  To: Cyril Cressent; +Cc: dev-VfR2kkLFssw

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: preallocation of void ** obj_p of rte_ring_dequeue
       [not found]       ` <201311051218.27016.thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
@ 2013-11-05 16:47         ` Jose Gavine Cueto
       [not found]           ` <CAJ5bv6GcUvNHib02_Xaxs2xaz=J0XaxrqHistnKSQKz5zyYdOQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  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-VfR2kkLFssw

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-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>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: preallocation of void ** obj_p of rte_ring_dequeue
       [not found]           ` <CAJ5bv6GcUvNHib02_Xaxs2xaz=J0XaxrqHistnKSQKz5zyYdOQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 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-VfR2kkLFssw

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: 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-VfR2kkLFssw

I see , now its clearer.

Thanks,
Pepe


On Wed, Nov 6, 2013 at 1:54 AM, Cyril Cressent <cyril.cressent-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>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:28 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 preallocation of void ** obj_p of rte_ring_dequeue Jose Gavine Cueto
     [not found] ` <CAJ5bv6EVB-oQuVqghaPq+6UQjkiLbhy6x3ascsYZhT_14bBYRg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-05 10:33   ` Cyril Cressent
2013-11-05 10:42     ` Jose Gavine Cueto
2013-11-05 11:18     ` Thomas Monjalon
     [not found]       ` <201311051218.27016.thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2013-11-05 16:47         ` Jose Gavine Cueto
     [not found]           ` <CAJ5bv6GcUvNHib02_Xaxs2xaz=J0XaxrqHistnKSQKz5zyYdOQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-05 17:54             ` Cyril Cressent
2013-11-05 23:28               ` Jose Gavine Cueto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.