patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Qi Zhang <qi.z.zhang@intel.com>
Cc: stable@dpdk.org
Subject: Re: [dpdk-stable] [PATCH] net/i40e: fix out of order Rx read
Date: Wed, 9 Nov 2016 12:54:13 +0800	[thread overview]
Message-ID: <20161109045413.GQ10323@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <1478454368-61614-1-git-send-email-qi.z.zhang@intel.com>

Applied to dpdk-stable branch 16.07.

Thanks.

	--yliu


On Mon, Nov 07, 2016 at 01:46:08AM +0800, Qi Zhang wrote:
> In vPMD, when we load Rx desc with _mm_loadu_si128, the volatile
> modifier will be cast away, allowing the compiler to reorder the
> load instructions.
> 
> The Rx recv function's correctness is relying on these load
> instructions following a strict sequence, reading the descriptors
> in reverse order, so we add compiler barrier to prevent compiler
> reorder.
> 
> Fixes: 9ed94e5bb04e ("i40e: add vector Rx")
> 
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
>  drivers/net/i40e/i40e_rxtx_vec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/i40e/i40e_rxtx_vec.c b/drivers/net/i40e/i40e_rxtx_vec.c
> index 82571ee..a9649d3 100644
> --- a/drivers/net/i40e/i40e_rxtx_vec.c
> +++ b/drivers/net/i40e/i40e_rxtx_vec.c
> @@ -282,7 +282,7 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
>  		/* Read desc statuses backwards to avoid race condition */
>  		/* A.1 load 4 pkts desc */
>  		descs[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
> -
> +		rte_compiler_barrier();
>  		/* B.2 copy 2 mbuf point into rx_pkts  */
>  		_mm_storeu_si128((__m128i *)&rx_pkts[pos], mbp1);
>  
> @@ -290,8 +290,10 @@ _recv_raw_pkts_vec(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_pkts,
>  		mbp2 = _mm_loadu_si128((__m128i *)&sw_ring[pos+2]);
>  
>  		descs[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
> +		rte_compiler_barrier();
>  		/* B.1 load 2 mbuf point */
>  		descs[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
> +		rte_compiler_barrier();
>  		descs[0] = _mm_loadu_si128((__m128i *)(rxdp));
>  
>  		/* B.2 copy 2 mbuf point into rx_pkts  */
> -- 
> 2.7.4

           reply	other threads:[~2016-11-09  4:53 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1478454368-61614-1-git-send-email-qi.z.zhang@intel.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161109045413.GQ10323@yliu-dev.sh.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).