From: Stanislaw Gruszka <sgruszka@redhat.com>
To: Jian-Hong Pan <jian-hong@endlessm.com>
Cc: Yan-Hsuan Chuang <yhchuang@realtek.com>,
Kalle Valo <kvalo@codeaurora.org>,
"David S . Miller" <davem@davemloft.net>,
David Laight <David.Laight@aculab.com>,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, linux@endlessm.com,
stable@vger.kernel.org
Subject: Re: [PATCH] rtw88: pci: Use general byte arrays as the elements of RX ring
Date: Tue, 30 Jul 2019 11:35:33 +0200 [thread overview]
Message-ID: <20190730093533.GC3174@redhat.com> (raw)
In-Reply-To: <20190725080925.6575-1-jian-hong@endlessm.com>
On Thu, Jul 25, 2019 at 04:09:26PM +0800, Jian-Hong Pan wrote:
> Each skb as the element in RX ring was expected with sized buffer 8216
> (RTK_PCI_RX_BUF_SIZE) bytes. However, the skb buffer's true size is
> 16640 bytes for alignment after allocated, x86_64 for example. And, the
rtw88 advertise IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454, so maximum AMSDU
packet can be approximately 12kB. This might be accidental, but having
16kB skb's allow to handle such big AMSDUs. If you shrink buf size,
you can probably override memory after buffer end.
> difference will be enlarged 512 times (RTK_MAX_RX_DESC_NUM).
> To prevent that much wasted memory, this patch follows David's
> suggestion [1] and uses general buffer arrays, instead of skbs as the
> elements in RX ring.
>
> [1] https://www.spinics.net/lists/linux-wireless/msg187870.html
>
> Signed-off-by: Jian-Hong Pan <jian-hong@endlessm.com>
> Cc: <stable@vger.kernel.org>
This does not fix any serious problem, it actually most likely
introduce memory corruption problem described above. Should not
be targeted to stable anyway.
> - dev_kfree_skb_any(skb);
> + devm_kfree(rtwdev->dev, buf);
For what this is needed? devm_ allocations are used exactly to avoid
manual freeing.
> + len = pkt_stat.pkt_len + pkt_offset;
> + skb = dev_alloc_skb(len);
> + if (WARN_ONCE(!skb, "rx routine starvation\n"))
> goto next_rp;
>
> /* put the DMA data including rx_desc from phy to new skb */
> - skb_put_data(new, skb->data, new_len);
> + skb_put_data(skb, rx_desc, len);
Coping big packets it quite inefficient. What drivers usually do is
copy only for small packets and for big ones allocate new rx buf
(drop packet alloc if fail) and pas old buf to network stack via
skb_add_rx_frag(). See iwlmvm as example.
Stanislaw
next prev parent reply other threads:[~2019-07-30 9:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-25 8:09 [PATCH] rtw88: pci: Use general byte arrays as the elements of RX ring Jian-Hong Pan
2019-07-25 9:21 ` David Laight
2019-07-26 6:18 ` Jian-Hong Pan
2019-07-26 9:23 ` David Laight
2019-07-26 9:40 ` Jian-Hong Pan
2019-07-30 3:11 ` Tony Chuang
2019-07-30 9:35 ` Stanislaw Gruszka [this message]
2019-07-30 9:48 ` David Laight
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=20190730093533.GC3174@redhat.com \
--to=sgruszka@redhat.com \
--cc=David.Laight@aculab.com \
--cc=davem@davemloft.net \
--cc=jian-hong@endlessm.com \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linux@endlessm.com \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=yhchuang@realtek.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).