[PATCH v1 24/25] net/ntnic: avoid possible deadlock

Stephen Hemminger stephen at networkplumber.org
Wed Apr 30 16:05:21 CEST 2025


On Wed, 30 Apr 2025 15:48:36 +0200
Oleksandr Kolomeiets <okl-plv at napatech.com> wrote:

> From: Danylo Vodopianov <dvo-plv at napatech.com>
> 
> Sometimes during  high flow learn performance two threads
> could cause deadlock using queue and mutex.
> 
> learn_ignored variable sets when flow learn and gets
> when flow removes. Hence, learn_ignore should not be protected
> as far as two thread could not access to the same flow
> at the same time.
> 
> Signed-off-by: Danylo Vodopianov <dvo-plv at napatech.com>

If you are going to do this, then you need to use rte_atomic_store/fetch.
If two threads read/write same variable outside of lock, need the CPU
to use special instructions on weakly ordered platforms like ARM.

> --- a/drivers/net/ntnic/include/flow_api_engine.h
> +++ b/drivers/net/ntnic/include/flow_api_engine.h
> @@ -297,7 +297,7 @@ struct flow_handle {
>  	enum flow_handle_type type;
>  	uint32_t flm_id;
>  	uint16_t caller_id;
> -	uint16_t learn_ignored;
> +	RTE_ATOMIC(uint16_t)learn_ignored;

The preferred spacing would be:
	RTE_ATOMIC(uint16_t) learn_ignored;
  


More information about the dev mailing list