From: Tariq Toukan <ttoukan.linux@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Eric Dumazet <edumazet@google.com>,
"David S . Miller" <davem@davemloft.net>,
netdev <netdev@vger.kernel.org>,
Tariq Toukan <tariqt@mellanox.com>,
Martin KaFai Lau <kafai@fb.com>,
Willem de Bruijn <willemb@google.com>,
Jesper Dangaard Brouer <brouer@redhat.com>,
Brenden Blanco <bblanco@plumgrid.com>,
Alexei Starovoitov <ast@kernel.org>
Subject: Re: [PATCH net-next 0/9] mlx4: order-0 allocations and page recycling
Date: Thu, 9 Feb 2017 14:00:03 +0200 [thread overview]
Message-ID: <a536bb6d-3596-188e-bc99-548b02f8eb91@gmail.com> (raw)
In-Reply-To: <1486569156.7793.79.camel@edumazet-glaptop3.roam.corp.google.com>
On 08/02/2017 5:52 PM, Eric Dumazet wrote:
> On Wed, 2017-02-08 at 11:02 +0200, Tariq Toukan wrote:
>> On 07/02/2017 5:50 PM, Tariq Toukan wrote:
>>> Hi Eric,
>>>
>>> Thanks for your series.
>>>
>>> On 07/02/2017 5:02 AM, Eric Dumazet wrote:
>>>> As mentioned half a year ago, we better switch mlx4 driver to order-0
>>>> allocations and page recycling.
>>>>
>>>> This reduces vulnerability surface thanks to better skb->truesize
>>>> tracking
>>>> and provides better performance in most cases.
>>> The series makes significant change in the RX data-path, that requires
>>> deeper checks, in addition to code review.
>>> We applied your series and started running both our functional and
>>> performance regression.
>>> We will have results by tomorrow morning, and will analyze them during
>>> the day. I'll update about that.
>> We hit a kernel panic when running traffic after configuring a large MTU
>> (9000).
>> I will take deeper look into this soon and will keep you updated.
> Hmm... I saw a typo for XDP, but not for the non XDP path...
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> index 8f16ec8dfadd0f95646c498c14d53f7266a0..e572e175edfe0f7392b9833b5b3f867fd6db 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> @@ -132,7 +132,7 @@ static int mlx4_en_prepare_rx_desc(const struct mlx4_en_priv *priv,
> (index << priv->log_rx_info);
>
> if (ring->page_cache.index > 0) {
> - if (frags[0].page) {
> + if (!frags[0].page) {
> ring->page_cache.index--;
> frags[0].page = ring->page_cache.buf[ring->page_cache.index].page;
> frags[0].dma = ring->page_cache.buf[ring->page_cache.index].dma;
>
>
Yes.
Here it is:
Large MTU enlarges priv->log_rx_info.
1115 priv->log_rx_info = ROUNDUP_LOG2(i * sizeof(struct
mlx4_en_rx_alloc));
In the free_frag function, only frag->page is cleared (dma and offset
are not!), leaving non-zero garbage that is read later as a page field.
90 static void mlx4_en_free_frag(const struct mlx4_en_priv *priv,
91 struct mlx4_en_rx_alloc *frag)
92 {
93 if (frag->page) {
94 dma_unmap_page(priv->ddev, frag->dma,
95 PAGE_SIZE, priv->dma_dir);
96 put_page(frag->page);
97 }
Later, on line 82, we stay with a garbage page pointer.
74 static int mlx4_en_alloc_frags(const struct mlx4_en_priv *priv,
75 struct mlx4_en_rx_desc *rx_desc,
76 struct mlx4_en_rx_alloc *frags,
77 gfp_t gfp)
78 {
79 int i;
80
81 for (i = 0; i < priv->num_frags; i++, frags++) {
82 if (!frags->page && mlx4_alloc_page(priv, frags, gfp))
83 return -ENOMEM;
84 rx_desc->data[i].addr = cpu_to_be64(frags->dma +
85 frags->page_offset);
86 }
87 return 0;
88 }
It can be fixed with this:
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 6854a19087ed..d97ee69393f0 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -94,8 +94,8 @@ static void mlx4_en_free_frag(const struct
mlx4_en_priv *priv,
dma_unmap_page(priv->ddev, frag->dma,
PAGE_SIZE, priv->dma_dir);
put_page(frag->page);
- frag->page = NULL;
}
+ memset(frag, 0, sizeof(*frag));
}
static void mlx4_en_init_rx_desc(const struct mlx4_en_priv *priv,
Regards,
Tariq Toukan.
next prev parent reply other threads:[~2017-02-09 12:00 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-07 3:02 [PATCH net-next 0/9] mlx4: order-0 allocations and page recycling Eric Dumazet
2017-02-07 3:02 ` [PATCH net-next 1/9] mlx4: use __skb_fill_page_desc() Eric Dumazet
2017-02-07 3:02 ` [PATCH net-next 2/9] mlx4: dma_dir is a mlx4_en_priv attribute Eric Dumazet
2017-02-07 3:02 ` [PATCH net-next 3/9] mlx4: remove order field from mlx4_en_frag_info Eric Dumazet
2017-02-07 3:02 ` [PATCH net-next 4/9] mlx4: get rid of frag_prefix_size Eric Dumazet
2017-02-09 12:28 ` Tariq Toukan
2017-02-09 14:06 ` Eric Dumazet
2017-02-07 3:02 ` [PATCH net-next 5/9] mlx4: rx_headroom is a per port attribute Eric Dumazet
2017-02-07 3:02 ` [PATCH net-next 6/9] mlx4: reduce rx ring page_cache size Eric Dumazet
2017-02-07 3:02 ` [PATCH net-next 7/9] mlx4: removal of frag_sizes[] Eric Dumazet
2017-02-07 3:02 ` [PATCH net-next 8/9] mlx4: use order-0 pages for RX Eric Dumazet
2017-02-07 3:02 ` [PATCH net-next 9/9] mlx4: add page recycling in receive path Eric Dumazet
2017-02-07 16:20 ` Tariq Toukan
2017-02-07 16:34 ` Eric Dumazet
2017-02-08 10:27 ` Tariq Toukan
2017-02-07 15:50 ` [PATCH net-next 0/9] mlx4: order-0 allocations and page recycling Tariq Toukan
2017-02-07 16:06 ` Eric Dumazet
2017-02-07 16:26 ` Eric Dumazet
2017-02-07 16:28 ` Eric Dumazet
2017-02-07 19:05 ` Alexei Starovoitov
2017-02-07 19:18 ` Eric Dumazet
2017-02-08 9:02 ` Tariq Toukan
2017-02-08 10:29 ` Tariq Toukan
2017-02-08 15:52 ` Eric Dumazet
2017-02-09 12:00 ` Tariq Toukan [this message]
2017-02-09 13:31 ` Eric Dumazet
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=a536bb6d-3596-188e-bc99-548b02f8eb91@gmail.com \
--to=ttoukan.linux@gmail.com \
--cc=ast@kernel.org \
--cc=bblanco@plumgrid.com \
--cc=brouer@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=kafai@fb.com \
--cc=netdev@vger.kernel.org \
--cc=tariqt@mellanox.com \
--cc=willemb@google.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).