RE: [EXTERNAL] [RFC 05/32] bus/vmbus: replace SMP barriers with C11 memory fences

Long Li <[email protected]>
Newsgroups org.dpdk.dev
Message-ID <SA1PR21MB6683D2C66C69A918DC596C65CEDB2@SA1PR21MB6683.namprd21.prod.outlook.com>
> 
> Full barriers order the preceding index store against the following load of the
> interrupt mask or pending size and stay seq_cst; read barriers become
> acquire fences. Same code generated on x86 and arm64.
> 
> The write barrier before publishing the transmit index becomes a release
> fence. Nominally stronger on arm64, but it is immediately followed by a full
> barrier cmpset; converting that to a release compare-exchange is left for the
> rte_atomic32 removal series.
> 
> Signed-off-by: Stephen Hemminger <[email protected]>

Reviewed-by: Long Li <[email protected]>



> ---
>  drivers/bus/vmbus/vmbus_bufring.c | 6 +++---
> drivers/bus/vmbus/vmbus_channel.c | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/bus/vmbus/vmbus_bufring.c
> b/drivers/bus/vmbus/vmbus_bufring.c
> index f622869974..31478d3bfa 100644
> --- a/drivers/bus/vmbus/vmbus_bufring.c
> +++ b/drivers/bus/vmbus/vmbus_bufring.c
> @@ -58,11 +58,11 @@ void vmbus_br_setup(struct vmbus_br *br, void *buf,
> unsigned int blen)  static inline bool  vmbus_txbr_need_signal(const struct
> vmbus_bufring *vbr, uint32_t old_windex)  {
> -	rte_smp_mb();
> +	rte_atomic_thread_fence(rte_memory_order_seq_cst);
>  	if (vbr->imask)
>  		return false;
> 
> -	rte_smp_rmb();
> +	rte_atomic_thread_fence(rte_memory_order_acquire);
> 
>  	/*
>  	 * This is the only case we need to signal when the @@ -158,7 +158,7
> @@ vmbus_txbr_write(struct vmbus_br *tbr, const struct iovec iov[], int
> iovlen,
>  	RTE_ASSERT(windex == next_windex);
> 
>  	/* Ensure that data is available before updating host index */
> -	rte_smp_wmb();
> +	rte_atomic_thread_fence(rte_memory_order_release);
> 
>  	/* Checkin for our reservation. wait for our turn to update host */
>  	while (!rte_atomic32_cmpset(&vbr->windex, old_windex,
> next_windex)) diff --git a/drivers/bus/vmbus/vmbus_channel.c
> b/drivers/bus/vmbus/vmbus_channel.c
> index 2648d8e3fd..10293f59be 100644
> --- a/drivers/bus/vmbus/vmbus_channel.c
> +++ b/drivers/bus/vmbus/vmbus_channel.c
> @@ -211,7 +211,7 @@ bool rte_vmbus_chan_rx_empty(const struct
> vmbus_channel *channel)  {
>  	const struct vmbus_br *br = &channel->rxbr;
> 
> -	rte_smp_rmb();
> +	rte_atomic_thread_fence(rte_memory_order_acquire);
>  	return br->vbr->rindex == br->vbr->windex;  }
> 
> @@ -229,13 +229,13 @@ void rte_vmbus_chan_signal_read(struct
> rte_vmbus_device *dev,
>  		return;
> 
>  	/* Make sure reading of pending happens after new read index */
> -	rte_smp_mb();
> +	rte_atomic_thread_fence(rte_memory_order_seq_cst);
> 
>  	pending_sz = rbr->vbr->pending_send;
>  	if (!pending_sz)
>  		return;
> 
> -	rte_smp_rmb();
> +	rte_atomic_thread_fence(rte_memory_order_acquire);
>  	write_sz = vmbus_br_availwrite(rbr, rbr->vbr->windex);
> 
>  	/* If there was space before then host was not blocked */
> --
> 2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.