DPDK patches and discussions
 help / color / mirror / Atom feed
* unnecessary rx callbacks when zero packets
@ 2024-01-07 17:37 Stephen Hemminger
  2024-01-07 20:57 ` Honnappa Nagarahalli
  2024-01-08 15:20 ` Konstantin Ananyev
  0 siblings, 2 replies; 5+ messages in thread
From: Stephen Hemminger @ 2024-01-07 17:37 UTC (permalink / raw)
  To: dev

I noticed while looking at packet capture that currently the receive callbacks
get called even if there are no packets. This seems unnecessary since if
nb_rx is zero, then there are no packets to look at.  My one concern is that
an application could be using callbacks as some form of scheduling mechanism
which would be broken.

The change would be:


diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 21e3a21903ec..f64bf977c46e 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -6077,7 +6077,7 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
        nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts);
 
 #ifdef RTE_ETHDEV_RXTX_CALLBACKS
-       {
+       if (nb_rx > 0) {
                void *cb;
 
                /* rte_memory_order_release memory order was used when the

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

* RE: unnecessary rx callbacks when zero packets
  2024-01-07 17:37 unnecessary rx callbacks when zero packets Stephen Hemminger
@ 2024-01-07 20:57 ` Honnappa Nagarahalli
  2024-01-08 10:19   ` Morten Brørup
  2024-01-08 15:20 ` Konstantin Ananyev
  1 sibling, 1 reply; 5+ messages in thread
From: Honnappa Nagarahalli @ 2024-01-07 20:57 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: nd, nd



> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Sunday, January 7, 2024 11:37 AM
> To: dev@dpdk.org
> Subject: unnecessary rx callbacks when zero packets
> 
> I noticed while looking at packet capture that currently the receive callbacks
> get called even if there are no packets. This seems unnecessary since if nb_rx is
> zero, then there are no packets to look at.  My one concern is that an
> application could be using callbacks as some form of scheduling mechanism
> which would be broken.
Is it possible that the call back functions are maintaining statistics on zero packet polls?

> 
> The change would be:
> 
> 
> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index
> 21e3a21903ec..f64bf977c46e 100644
> --- a/lib/ethdev/rte_ethdev.h
> +++ b/lib/ethdev/rte_ethdev.h
> @@ -6077,7 +6077,7 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t
> queue_id,
>         nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts);
> 
>  #ifdef RTE_ETHDEV_RXTX_CALLBACKS
> -       {
> +       if (nb_rx > 0) {
>                 void *cb;
> 
>                 /* rte_memory_order_release memory order was used when the

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

* RE: unnecessary rx callbacks when zero packets
  2024-01-07 20:57 ` Honnappa Nagarahalli
@ 2024-01-08 10:19   ` Morten Brørup
  0 siblings, 0 replies; 5+ messages in thread
From: Morten Brørup @ 2024-01-08 10:19 UTC (permalink / raw)
  To: Honnappa Nagarahalli, Stephen Hemminger, dev; +Cc: nd, nd

> From: Honnappa Nagarahalli [mailto:Honnappa.Nagarahalli@arm.com]
> Sent: Sunday, 7 January 2024 21.57
> 
> > From: Stephen Hemminger <stephen@networkplumber.org>
> > Sent: Sunday, January 7, 2024 11:37 AM
> >
> > I noticed while looking at packet capture that currently the receive
> callbacks
> > get called even if there are no packets. This seems unnecessary since
> if nb_rx is
> > zero, then there are no packets to look at.  My one concern is that
> an
> > application could be using callbacks as some form of scheduling
> mechanism
> > which would be broken.
> Is it possible that the call back functions are maintaining statistics
> on zero packet polls?

I agree with this concern. The primary argument for introducing the callbacks (instead of the application simply calling the same functions at RX and TX time) was to provide instrumentation outside of the application itself. And for instrumentation purposes, zero-packet calls may be relevant.

TX also calls its callback with zero packets. The callbacks treatment should be the same for both RX and TX: Either always call, or only call if non-zero packets.

So: NAK.

Perhaps the packet capture library can be optimized for zero packets instead.

> 
> >
> > The change would be:
> >
> >
> > diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index
> > 21e3a21903ec..f64bf977c46e 100644
> > --- a/lib/ethdev/rte_ethdev.h
> > +++ b/lib/ethdev/rte_ethdev.h
> > @@ -6077,7 +6077,7 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t
> > queue_id,
> >         nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts);
> >
> >  #ifdef RTE_ETHDEV_RXTX_CALLBACKS
> > -       {
> > +       if (nb_rx > 0) {
> >                 void *cb;
> >
> >                 /* rte_memory_order_release memory order was used
> when the

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

* RE: unnecessary rx callbacks when zero packets
  2024-01-07 17:37 unnecessary rx callbacks when zero packets Stephen Hemminger
  2024-01-07 20:57 ` Honnappa Nagarahalli
@ 2024-01-08 15:20 ` Konstantin Ananyev
  2024-01-09 11:28   ` Ferruh Yigit
  1 sibling, 1 reply; 5+ messages in thread
From: Konstantin Ananyev @ 2024-01-08 15:20 UTC (permalink / raw)
  To: Stephen Hemminger, dev


rx callbacks when zero packets
> 
> I noticed while looking at packet capture that currently the receive callbacks
> get called even if there are no packets. This seems unnecessary since if
> nb_rx is zero, then there are no packets to look at.  My one concern is that
> an application could be using callbacks as some form of scheduling mechanism
> which would be broken.

As I remember, original idea was to allow callbacks to inject new packets if needed.

> 
> The change would be:
> 
> 
> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
> index 21e3a21903ec..f64bf977c46e 100644
> --- a/lib/ethdev/rte_ethdev.h
> +++ b/lib/ethdev/rte_ethdev.h
> @@ -6077,7 +6077,7 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
>         nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts);
> 
>  #ifdef RTE_ETHDEV_RXTX_CALLBACKS
> -       {
> +       if (nb_rx > 0) {
>                 void *cb;
> 
>                 /* rte_memory_order_release memory order was used when the

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

* Re: unnecessary rx callbacks when zero packets
  2024-01-08 15:20 ` Konstantin Ananyev
@ 2024-01-09 11:28   ` Ferruh Yigit
  0 siblings, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2024-01-09 11:28 UTC (permalink / raw)
  To: Konstantin Ananyev, Stephen Hemminger, dev
  Cc: Honnappa Nagarahalli, Morten Brørup

On 1/8/2024 3:20 PM, Konstantin Ananyev wrote:
> 
> rx callbacks when zero packets
>>
>> I noticed while looking at packet capture that currently the receive callbacks
>> get called even if there are no packets. This seems unnecessary since if
>> nb_rx is zero, then there are no packets to look at.  My one concern is that
>> an application could be using callbacks as some form of scheduling mechanism
>> which would be broken.
> 
> As I remember, original idea was to allow callbacks to inject new packets if needed.
> 

Right, callback function updating 'nb_rx' enables this.

Also Honnappa has a good point that callback can be used to calculate
zero packet polls.

These points are not documented and not obvious from the code,
@Stephen does it make sense to document that callback function called
with zero packet intentionally, in the 'rte_eth_rx_burst()' function
comment?

>>
>> The change would be:
>>
>>
>> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
>> index 21e3a21903ec..f64bf977c46e 100644
>> --- a/lib/ethdev/rte_ethdev.h
>> +++ b/lib/ethdev/rte_ethdev.h
>> @@ -6077,7 +6077,7 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id,
>>         nb_rx = p->rx_pkt_burst(qd, rx_pkts, nb_pkts);
>>
>>  #ifdef RTE_ETHDEV_RXTX_CALLBACKS
>> -       {
>> +       if (nb_rx > 0) {
>>                 void *cb;
>>
>>                 /* rte_memory_order_release memory order was used when the


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

end of thread, other threads:[~2024-01-09 11:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-07 17:37 unnecessary rx callbacks when zero packets Stephen Hemminger
2024-01-07 20:57 ` Honnappa Nagarahalli
2024-01-08 10:19   ` Morten Brørup
2024-01-08 15:20 ` Konstantin Ananyev
2024-01-09 11:28   ` Ferruh Yigit

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