DPDK usage discussions
 help / color / mirror / Atom feed
* [dpdk-users] A question about the function __mempool_get_bulk() of dpdk-16.04
@ 2016-06-07 20:52 Wu, Xiaoban
  2016-06-07 22:30 ` Wiles, Keith
  2016-06-10 13:00 ` Shreyansh Jain
  0 siblings, 2 replies; 4+ messages in thread
From: Wu, Xiaoban @ 2016-06-07 20:52 UTC (permalink / raw)
  To: users

Dear DPDK Users,


I have been reading the pktgen-3.0.02 source codes with dpdk-16.04.


In the pktgen.c, function pktgen_send_pkts(), line 1098, it calls function wr_pktmbuf_alloc_bulk_noreset().  Then it calls the function rte_mempool_get_bulk() which calls the function __mempool_get_bulk().


Since in the function rte_pktmbuf_pool_create(), the "flags" is set to zero in default, this leads to that when calling __mempool_get_bulk(), the input parameter"is_mc==1". Hence the function __mempool_get_bulk() will execute the line 961-992 except that when "ret" is less that 0.


My question is why at line 992, this has to return 0? In the line 941, the comment says that  ">=0: Success; number of objects supplied." I am confused by this comment, since in line 985-990, we can see that the input parameter "obj_table" is supplied by new values and the number of the new values is "n". Does this means that we need to "return n;" instead of "return 0;"?


Am I missing something here? Thank you so much for your help.


All the best,

Xiaoban

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-users] A question about the function __mempool_get_bulk() of dpdk-16.04
  2016-06-07 20:52 [dpdk-users] A question about the function __mempool_get_bulk() of dpdk-16.04 Wu, Xiaoban
@ 2016-06-07 22:30 ` Wiles, Keith
  2016-06-08  0:12   ` Wu, Xiaoban
  2016-06-10 13:00 ` Shreyansh Jain
  1 sibling, 1 reply; 4+ messages in thread
From: Wiles, Keith @ 2016-06-07 22:30 UTC (permalink / raw)
  To: Wu, Xiaoban, users


On 6/7/16, 3:52 PM, "users on behalf of Wu, Xiaoban" <users-bounces@dpdk.org on behalf of Xiaoban_Wu@student.uml.edu> wrote:

>Dear DPDK Users,
>
>
>I have been reading the pktgen-3.0.02 source codes with dpdk-16.04.
>
>
>In the pktgen.c, function pktgen_send_pkts(), line 1098, it calls function wr_pktmbuf_alloc_bulk_noreset().  Then it calls the function rte_mempool_get_bulk() which calls the function __mempool_get_bulk().
>
>
>Since in the function rte_pktmbuf_pool_create(), the "flags" is set to zero in default, this leads to that when calling __mempool_get_bulk(), the input parameter"is_mc==1". Hence the function __mempool_get_bulk() will execute the line 961-992 except that when "ret" is less that 0.

I checked out dpdk v16.04 and could not get your line numbers to workout, maybe you are on a slightly different version then release 16.04??

>
>
>My question is why at line 992, this has to return 0? In the line 941, the comment says that  ">=0: Success; number of objects supplied." I am confused by this comment, since in line 985-990, we can see that the input parameter "obj_table" is supplied by new values and the number of the new values is "n". Does this means that we need to "return n;" instead of "return 0;"?

The statement “>=0 number of objects supplied” also confused me some, but routines rte_ring_mc/sc_dequeue_bulk() returns zero on success when all requested objects are return not the number of objects returned. It seems it would be nice to have the number of objects returned, but as it is always ‘n’ it is best to return  < 0 on error. The _bulk allocate will not return a les then ‘n’ objects, this is why the code in pktgen tests for zero and not something greater then zero. The code in pktgen could test for ret >= 0 but the results are the same. 
>
>
>Am I missing something here? Thank you so much for your help.
>
>
>All the best,
>
>Xiaoban
>




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-users] A question about the function __mempool_get_bulk() of dpdk-16.04
  2016-06-07 22:30 ` Wiles, Keith
@ 2016-06-08  0:12   ` Wu, Xiaoban
  0 siblings, 0 replies; 4+ messages in thread
From: Wu, Xiaoban @ 2016-06-08  0:12 UTC (permalink / raw)
  To: Wiles, Keith, users


Dear Keith,

Yes, I see the checking for 0 in the pktgen codes. Maybe it is more clear if returns n like the wirte() in linux, but it also means a lot of codes need to be rewritten. As long as it is consistent and we know how to work around it, it should be fine. Thanks so much for your reply.

All the best,
Xiaoban
________________________________________
From: Wiles, Keith <keith.wiles@intel.com>
Sent: Tuesday, June 7, 2016 6:30:24 PM
To: Wu, Xiaoban; users@dpdk.org
Subject: Re: [dpdk-users] A question about the function __mempool_get_bulk() of dpdk-16.04

On 6/7/16, 3:52 PM, "users on behalf of Wu, Xiaoban" <users-bounces@dpdk.org on behalf of Xiaoban_Wu@student.uml.edu> wrote:

>Dear DPDK Users,
>
>
>I have been reading the pktgen-3.0.02 source codes with dpdk-16.04.
>
>
>In the pktgen.c, function pktgen_send_pkts(), line 1098, it calls function wr_pktmbuf_alloc_bulk_noreset().  Then it calls the function rte_mempool_get_bulk() which calls the function __mempool_get_bulk().
>
>
>Since in the function rte_pktmbuf_pool_create(), the "flags" is set to zero in default, this leads to that when calling __mempool_get_bulk(), the input parameter"is_mc==1". Hence the function __mempool_get_bulk() will execute the line 961-992 except that when "ret" is less that 0.

I checked out dpdk v16.04 and could not get your line numbers to workout, maybe you are on a slightly different version then release 16.04??

>
>
>My question is why at line 992, this has to return 0? In the line 941, the comment says that  ">=0: Success; number of objects supplied." I am confused by this comment, since in line 985-990, we can see that the input parameter "obj_table" is supplied by new values and the number of the new values is "n". Does this means that we need to "return n;" instead of "return 0;"?

The statement “>=0 number of objects supplied” also confused me some, but routines rte_ring_mc/sc_dequeue_bulk() returns zero on success when all requested objects are return not the number of objects returned. It seems it would be nice to have the number of objects returned, but as it is always ‘n’ it is best to return  < 0 on error. The _bulk allocate will not return a les then ‘n’ objects, this is why the code in pktgen tests for zero and not something greater then zero. The code in pktgen could test for ret >= 0 but the results are the same.
>
>
>Am I missing something here? Thank you so much for your help.
>
>
>All the best,
>
>Xiaoban
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-users] A question about the function __mempool_get_bulk() of dpdk-16.04
  2016-06-07 20:52 [dpdk-users] A question about the function __mempool_get_bulk() of dpdk-16.04 Wu, Xiaoban
  2016-06-07 22:30 ` Wiles, Keith
@ 2016-06-10 13:00 ` Shreyansh Jain
  1 sibling, 0 replies; 4+ messages in thread
From: Shreyansh Jain @ 2016-06-10 13:00 UTC (permalink / raw)
  To: Wu, Xiaoban; +Cc: users

Hi,

> -----Original Message-----
> From: users [mailto:users-bounces@dpdk.org] On Behalf Of Wu, Xiaoban
> Sent: Wednesday, June 08, 2016 2:22 AM
> To: users@dpdk.org
> Subject: [dpdk-users] A question about the function __mempool_get_bulk() of
> dpdk-16.04
> 
> Dear DPDK Users,
> 
> 
> I have been reading the pktgen-3.0.02 source codes with dpdk-16.04.
> 
> 
> In the pktgen.c, function pktgen_send_pkts(), line 1098, it calls function
> wr_pktmbuf_alloc_bulk_noreset().  Then it calls the function
> rte_mempool_get_bulk() which calls the function __mempool_get_bulk().
> 
> 
> Since in the function rte_pktmbuf_pool_create(), the "flags" is set to zero
> in default, this leads to that when calling __mempool_get_bulk(), the input
> parameter"is_mc==1". Hence the function __mempool_get_bulk() will execute the
> line 961-992 except that when "ret" is less that 0.

I too observed this issue a few days back. 
[I ended up changing DPDK code to get around it - some use-case I don't recall now].

> 
> 
> My question is why at line 992, this has to return 0? In the line 941, the
> comment says that  ">=0: Success; number of objects supplied." I am confused
> by this comment, since in line 985-990, we can see that the input parameter
> "obj_table" is supplied by new values and the number of the new values is
> "n". Does this means that we need to "return n;" instead of "return 0;"?

Probably, what is happening is that all calls to __mempool_get_bulk in DPDK code base are not worrying about a return value stating number of objects/buffers handled. They just require a positive number and are satisfied with '0'.
Reading through the API itself, I was not sure if it indeed should return the count or not. Given the pktgen use-case, 'count' looks more probable. And even if modified, it wouldn't break any call flow - AFAIK.

Probably guys on devel@ can help us.

> 
> 
> Am I missing something here? Thank you so much for your help.
> 
> 
> All the best,
> 
> Xiaoban

-
Shreyansh

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-10 13:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-07 20:52 [dpdk-users] A question about the function __mempool_get_bulk() of dpdk-16.04 Wu, Xiaoban
2016-06-07 22:30 ` Wiles, Keith
2016-06-08  0:12   ` Wu, Xiaoban
2016-06-10 13:00 ` Shreyansh Jain

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).