[EXT] [PATCH 04/16] drivers/event: use previous value atomic fetch operations

Pavan Nikhilesh Bhagavatula pbhagavatula at marvell.com
Mon Mar 13 08:02:25 CET 2023



> -----Original Message-----
> From: Tyler Retzlaff <roretzla at linux.microsoft.com>
> Sent: Saturday, March 11, 2023 3:45 AM
> To: dev at dpdk.org
> Cc: Honnappa.Nagarahalli at arm.com; Ruifeng.Wang at arm.com;
> thomas at monjalon.net; Tyler Retzlaff <roretzla at linux.microsoft.com>
> Subject: [EXT] [PATCH 04/16] drivers/event: use previous value atomic fetch
> operations
> 
> External Email
> 
> ----------------------------------------------------------------------
> Use __atomic_fetch_{add,and,or,sub,xor} instead of
> __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
> allow consumption of the resulting value.
> 
> Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>

Acked-by: Pavan Nikhilesh <pbhagavatula at marvell.com>

> ---
>  drivers/event/cnxk/cnxk_tim_worker.h  | 2 +-
>  drivers/event/dsw/dsw_event.c         | 4 ++--
>  drivers/event/octeontx/timvf_worker.h | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/event/cnxk/cnxk_tim_worker.h
> b/drivers/event/cnxk/cnxk_tim_worker.h
> index a326d55..0bd66ec 100644
> --- a/drivers/event/cnxk/cnxk_tim_worker.h
> +++ b/drivers/event/cnxk/cnxk_tim_worker.h
> @@ -123,7 +123,7 @@
>  	const uint64_t v =
>  		~(TIM_BUCKET_W1_M_NUM_ENTRIES <<
> TIM_BUCKET_W1_S_NUM_ENTRIES);
> 
> -	return __atomic_and_fetch(&bktp->w1, v, __ATOMIC_ACQ_REL);
> +	return __atomic_fetch_and(&bktp->w1, v, __ATOMIC_ACQ_REL) &
> v;
>  }
> 
>  static inline uint64_t
> diff --git a/drivers/event/dsw/dsw_event.c
> b/drivers/event/dsw/dsw_event.c
> index 9932caf..cbdc03f 100644
> --- a/drivers/event/dsw/dsw_event.c
> +++ b/drivers/event/dsw/dsw_event.c
> @@ -45,8 +45,8 @@
>  	 * allocation.
>  	 */
>  	new_total_on_loan =
> -	    __atomic_add_fetch(&dsw->credits_on_loan, acquired_credits,
> -			       __ATOMIC_RELAXED);
> +	    __atomic_fetch_add(&dsw->credits_on_loan, acquired_credits,
> +			       __ATOMIC_RELAXED) + acquired_credits;
> 
>  	if (unlikely(new_total_on_loan > dsw->max_inflight)) {
>  		/* Some other port took the last credits */
> diff --git a/drivers/event/octeontx/timvf_worker.h
> b/drivers/event/octeontx/timvf_worker.h
> index 3f1e77f..aa729f8 100644
> --- a/drivers/event/octeontx/timvf_worker.h
> +++ b/drivers/event/octeontx/timvf_worker.h
> @@ -135,7 +135,7 @@
>  {
>  	const uint64_t v = ~(TIM_BUCKET_W1_M_NUM_ENTRIES <<
>  			TIM_BUCKET_W1_S_NUM_ENTRIES);
> -	return __atomic_and_fetch(&bktp->w1, v, __ATOMIC_ACQ_REL);
> +	return __atomic_fetch_and(&bktp->w1, v, __ATOMIC_ACQ_REL) &
> v;
>  }
> 
>  static inline struct tim_mem_entry *
> --
> 1.8.3.1



More information about the dev mailing list