From: David Miller <davem@davemloft.net>
To: tariqt@mellanox.com
Cc: netdev@vger.kernel.org, eranbe@mellanox.com, kafai@fb.com,
saeedm@mellanox.com, edumazet@google.com
Subject: Re: [PATCH net] net/mlx4_en: Don't reuse RX page when XDP is set
Date: Mon, 16 Jul 2018 14:08:33 -0700 (PDT) [thread overview]
Message-ID: <20180716.140833.1871284102811541207.davem@davemloft.net> (raw)
In-Reply-To: <1531652079-27380-1-git-send-email-tariqt@mellanox.com>
From: Tariq Toukan <tariqt@mellanox.com>
Date: Sun, 15 Jul 2018 13:54:39 +0300
> From: Saeed Mahameed <saeedm@mellanox.com>
>
> When a new rx packet arrives, the rx path will decide whether to reuse
> the remainder of the page or not according to one of the below conditions:
> 1. frag_info->frag_stride == PAGE_SIZE / 2
> 2. frags->page_offset + frag_info->frag_size > PAGE_SIZE;
>
> The first condition is no met for when XDP is set.
> For XDP, page_offset is always set to priv->rx_headroom which is
> XDP_PACKET_HEADROOM and frag_info->frag_size is around mtu size + some
> padding, still the 2nd release condition will hold since
> XDP_PACKET_HEADROOM + 1536 < PAGE_SIZE, as a result the page will not
> be released and will be _wrongly_ reused for next free rx descriptor.
>
> In XDP there is an assumption to have a page per packet and reuse can
> break such assumption and might cause packet data corruptions.
>
> Fix this by adding an extra condition (!priv->rx_headroom) to the 2nd
> case to avoid page reuse when XDP is set, since rx_headroom is set to 0
> for non XDP setup and set to XDP_PACKET_HEADROOM for XDP setup.
>
> No additional cache line is required for the new condition.
>
> Fixes: 34db548bfb95 ("mlx4: add page recycling in receive path")
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
> Suggested-by: Martin KaFai Lau <kafai@fb.com>
Applied and queued up for -stable.
prev parent reply other threads:[~2018-07-16 21:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-15 10:54 [PATCH net] net/mlx4_en: Don't reuse RX page when XDP is set Tariq Toukan
2018-07-16 21:08 ` David Miller [this message]
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=20180716.140833.1871284102811541207.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eranbe@mellanox.com \
--cc=kafai@fb.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@mellanox.com \
--cc=tariqt@mellanox.com \
/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).