ethdev: prohibit polling of a stopped queue

Message ID 20220410213550.1733330-1-dkozlyuk@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series ethdev: prohibit polling of a stopped queue |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-abi-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Dmitry Kozlyuk April 10, 2022, 9:35 p.m. UTC
  Whether it is allowed to call Rx/Tx functions for a stopped queue
was undocumented. Some PMDs make this behavior a no-op
either by explicitly checking the queue state
or by the way how their routines are implemented or HW works.

No-op behavior may be convenient for application developers.
But it also means that pollers of stopped queues
would go all the way down to PMD Rx/Tx routines, wasting cycles.
Some PMDs would do a check for the queue state on data path,
even though it may never be needed for a particular application.
Also, use cases for stopping queues or starting them deferred
do not logically require polling stopped queues.

Use case 1: a secondary that was polling the queue has crashed,
the primary is doing a recovery to free all mbufs.
By definition the queue to be restarted is not polled.

Use case 2: deferred queue start or queue reconfiguration.
The polling thread must be synchronized anyway,
because queue start and stop are non-atomic.

Prohibit calling Rx/Tx functions on stopped queues.

Fixes: 0748be2cf9a2 ("ethdev: queue start and stop")
Cc: stable@dpdk.org

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
---
This patch is was originally a part of the series:
http://patchwork.dpdk.org/project/dpdk/patch/20220307125351.697936-3-dkozlyuk@nvidia.com/
The discussion there is summarized in the commit message.

 lib/ethdev/rte_ethdev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Tyler Retzlaff April 11, 2022, 8:17 a.m. UTC | #1
On Mon, Apr 11, 2022 at 12:35:50AM +0300, Dmitry Kozlyuk wrote:
> Whether it is allowed to call Rx/Tx functions for a stopped queue
> was undocumented. Some PMDs make this behavior a no-op
> either by explicitly checking the queue state
> or by the way how their routines are implemented or HW works.
> 
> No-op behavior may be convenient for application developers.
> But it also means that pollers of stopped queues
> would go all the way down to PMD Rx/Tx routines, wasting cycles.
> Some PMDs would do a check for the queue state on data path,
> even though it may never be needed for a particular application.
> Also, use cases for stopping queues or starting them deferred
> do not logically require polling stopped queues.
> 
> Use case 1: a secondary that was polling the queue has crashed,
> the primary is doing a recovery to free all mbufs.
> By definition the queue to be restarted is not polled.
> 
> Use case 2: deferred queue start or queue reconfiguration.
> The polling thread must be synchronized anyway,
> because queue start and stop are non-atomic.
> 
> Prohibit calling Rx/Tx functions on stopped queues.
> 
> Fixes: 0748be2cf9a2 ("ethdev: queue start and stop")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>

Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
  
Thomas Monjalon April 25, 2022, 8:30 a.m. UTC | #2
10/04/2022 23:35, Dmitry Kozlyuk:
> Whether it is allowed to call Rx/Tx functions for a stopped queue
> was undocumented. Some PMDs make this behavior a no-op
> either by explicitly checking the queue state
> or by the way how their routines are implemented or HW works.
> 
> No-op behavior may be convenient for application developers.
> But it also means that pollers of stopped queues
> would go all the way down to PMD Rx/Tx routines, wasting cycles.
> Some PMDs would do a check for the queue state on data path,
> even though it may never be needed for a particular application.
> Also, use cases for stopping queues or starting them deferred
> do not logically require polling stopped queues.
> 
> Use case 1: a secondary that was polling the queue has crashed,
> the primary is doing a recovery to free all mbufs.
> By definition the queue to be restarted is not polled.
> 
> Use case 2: deferred queue start or queue reconfiguration.
> The polling thread must be synchronized anyway,
> because queue start and stop are non-atomic.
> 
> Prohibit calling Rx/Tx functions on stopped queues.
> 
> Fixes: 0748be2cf9a2 ("ethdev: queue start and stop")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> ---
> This patch is was originally a part of the series:
> http://patchwork.dpdk.org/project/dpdk/patch/20220307125351.697936-3-dkozlyuk@nvidia.com/
> The discussion there is summarized in the commit message.
[...]
>   * rte_eth_rx_queue_setup()), it must call rte_eth_dev_stop() first to stop the
>   * device and then do the reconfiguration before calling rte_eth_dev_start()
>   * again. The transmit and receive functions should not be invoked when the
> - * device is stopped.
> + * device is stopped or when the queue is stopped (for that queue).

I think we can make it simpler:

The transmit and receive functions should not be invoked when the device
or the queue is stopped.
  
Thomas Monjalon May 25, 2022, 10:34 a.m. UTC | #3
25/04/2022 10:30, Thomas Monjalon:
> 10/04/2022 23:35, Dmitry Kozlyuk:
> > Whether it is allowed to call Rx/Tx functions for a stopped queue
> > was undocumented. Some PMDs make this behavior a no-op
> > either by explicitly checking the queue state
> > or by the way how their routines are implemented or HW works.
> > 
> > No-op behavior may be convenient for application developers.
> > But it also means that pollers of stopped queues
> > would go all the way down to PMD Rx/Tx routines, wasting cycles.
> > Some PMDs would do a check for the queue state on data path,
> > even though it may never be needed for a particular application.
> > Also, use cases for stopping queues or starting them deferred
> > do not logically require polling stopped queues.
> > 
> > Use case 1: a secondary that was polling the queue has crashed,
> > the primary is doing a recovery to free all mbufs.
> > By definition the queue to be restarted is not polled.
> > 
> > Use case 2: deferred queue start or queue reconfiguration.
> > The polling thread must be synchronized anyway,
> > because queue start and stop are non-atomic.
> > 
> > Prohibit calling Rx/Tx functions on stopped queues.
> > 
> > Fixes: 0748be2cf9a2 ("ethdev: queue start and stop")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> > ---
> > This patch is was originally a part of the series:
> > http://patchwork.dpdk.org/project/dpdk/patch/20220307125351.697936-3-dkozlyuk@nvidia.com/
> > The discussion there is summarized in the commit message.
> [...]
> >   * rte_eth_rx_queue_setup()), it must call rte_eth_dev_stop() first to stop the
> >   * device and then do the reconfiguration before calling rte_eth_dev_start()
> >   * again. The transmit and receive functions should not be invoked when the
> > - * device is stopped.
> > + * device is stopped or when the queue is stopped (for that queue).
> 
> I think we can make it simpler:
> 
> The transmit and receive functions should not be invoked when the device
> or the queue is stopped.

No comment after a month.
The patch is applied in next-net with the suggested rewording.
  

Patch

diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index 04cff8ee10..435720a84e 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -74,7 +74,7 @@ 
  * rte_eth_rx_queue_setup()), it must call rte_eth_dev_stop() first to stop the
  * device and then do the reconfiguration before calling rte_eth_dev_start()
  * again. The transmit and receive functions should not be invoked when the
- * device is stopped.
+ * device is stopped or when the queue is stopped (for that queue).
  *
  * Please note that some configuration is not stored between calls to
  * rte_eth_dev_stop()/rte_eth_dev_start(). The following configuration will