From: Simon Horman <horms@kernel.org>
To: Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: intel-wired-lan@lists.osuosl.org,
Tony Nguyen <anthony.l.nguyen@intel.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Mina Almasry <almasrymina@google.com>,
nex.sw.ncis.osdt.itp.upstreaming@intel.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [PATCH iwl-next 12/12] idpf: use libeth Rx buffer management for payload buffer
Date: Sat, 15 Jun 2024 08:35:09 +0100 [thread overview]
Message-ID: <20240615073509.GA8447@kernel.org> (raw)
In-Reply-To: <2c22ba85-2338-4f16-b3c2-70c4270cd96b@intel.com>
On Thu, Jun 13, 2024 at 01:05:58PM +0200, Alexander Lobakin wrote:
> From: Simon Horman <horms@kernel.org>
> Date: Sat, 1 Jun 2024 10:08:42 +0100
>
> > + Dan Carpenter
> >
> > On Tue, May 28, 2024 at 03:48:46PM +0200, Alexander Lobakin wrote:
> >> idpf uses Page Pool for data buffers with hardcoded buffer lengths of
> >> 4k for "classic" buffers and 2k for "short" ones. This is not flexible
> >> and does not ensure optimal memory usage. Why would you need 4k buffers
> >> when the MTU is 1500?
> >> Use libeth for the data buffers and don't hardcode any buffer sizes. Let
> >> them be calculated from the MTU for "classics" and then divide the
> >> truesize by 2 for "short" ones. The memory usage is now greatly reduced
> >> and 2 buffer queues starts make sense: on frames <= 1024, you'll recycle
> >> (and resync) a page only after 4 HW writes rather than two.
> >>
> >> Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
> >
> > ...
> >
> >> diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
> >
> > ...
> >
> > Hi Alexander,
> >
> > The code above the hunk below, starting at line 3321, is:
> >
> > if (unlikely(!hdr_len && !skb)) {
> > hdr_len = idpf_rx_hsplit_wa(hdr, rx_buf, pkt_len);
> > pkt_len -= hdr_len;
> > u64_stats_update_begin(&rxq->stats_sync);
> > u64_stats_inc(&rxq->q_stats.hsplit_buf_ovf);
> > u64_stats_update_end(&rxq->stats_sync);
> > }
> > if (libeth_rx_sync_for_cpu(hdr, hdr_len)) {
> > skb = idpf_rx_build_skb(hdr, hdr_len);
> > if (!skb)
> > break;
> > u64_stats_update_begin(&rxq->stats_sync);
> > u64_stats_inc(&rxq->q_stats.hsplit_pkts);
> > u64_stats_update_end(&rxq->stats_sync);
> > }
> >
> >> @@ -3413,24 +3340,24 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget)
> >> hdr->page = NULL;
> >>
> >> payload:
> >> - if (pkt_len) {
> >> - idpf_rx_sync_for_cpu(rx_buf, pkt_len);
> >> - if (skb)
> >> - idpf_rx_add_frag(rx_buf, skb, pkt_len);
> >> - else
> >> - skb = idpf_rx_construct_skb(rxq, rx_buf,
> >> - pkt_len);
> >> - } else {
> >> - idpf_rx_put_page(rx_buf);
> >> - }
> >> + if (!libeth_rx_sync_for_cpu(rx_buf, pkt_len))
> >> + goto skip_data;
> >> +
> >> + if (skb)
> >> + idpf_rx_add_frag(rx_buf, skb, pkt_len);
> >> + else
> >> + skb = idpf_rx_build_skb(rx_buf, pkt_len);
> >>
> >> /* exit if we failed to retrieve a buffer */
> >> if (!skb)
> >> break;
> >>
> >> - idpf_rx_post_buf_refill(refillq, buf_id);
> >> +skip_data:
> >> + rx_buf->page = NULL;
> >>
> >> + idpf_rx_post_buf_refill(refillq, buf_id);
> >> IDPF_RX_BUMP_NTC(rxq, ntc);
> >> +
> >> /* skip if it is non EOP desc */
> >> if (!idpf_rx_splitq_is_eop(rx_desc))
> >> continue;
> >
> > The code following this hunk, ending at line 3372, looks like this:
> >
> > /* pad skb if needed (to make valid ethernet frame) */
> > if (eth_skb_pad(skb)) {
> > skb = NULL;
> > continue;
> > }
> > /* probably a little skewed due to removing CRC */
> > total_rx_bytes += skb->len;
> >
> > Smatch warns that:
> > .../idpf_txrx.c:3372 idpf_rx_splitq_clean() error: we previously assumed 'skb' could be null (see line 3321)
> >
> > I think, but am not sure, this is because it thinks skb might
> > be NULL at the point where "goto skip_data;" is now called above.
> >
> > Could you look into this?
>
> This is actually a good catch. skb indeed could be NULL and we needed to
> check that in the same condition where !eop is checked.
> Fixed already in my tree, so it will be fixed in v2. Thanks for catching!
>
> (BTW I fixed that in iavf when submitting the libeth series, but forgot
> to fix that here lol >_<)
> (Also, it was implicitly fixed in the later commits where I convert skb
> to xdp_buff here, so I didn't catch this one)
Thanks, much appreciated.
As I mentioned above, I wasn't sure about this one.
prev parent reply other threads:[~2024-06-15 7:35 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 13:48 [PATCH iwl-next 00/12] idpf: XDP chapter I: convert Rx to libeth Alexander Lobakin
2024-05-28 13:48 ` [PATCH iwl-next 01/12] libeth: add cacheline / struct alignment helpers Alexander Lobakin
2024-05-30 1:34 ` Jakub Kicinski
2024-06-12 10:07 ` Przemek Kitszel
2024-06-12 20:55 ` Jakub Kicinski
2024-06-13 10:47 ` Alexander Lobakin
2024-06-13 13:47 ` Jakub Kicinski
2024-05-28 13:48 ` [PATCH iwl-next 02/12] idpf: stop using macros for accessing queue descriptors Alexander Lobakin
2024-05-28 13:48 ` [PATCH iwl-next 03/12] idpf: split &idpf_queue into 4 strictly-typed queue structures Alexander Lobakin
2024-06-01 8:53 ` Simon Horman
2024-06-13 11:03 ` Alexander Lobakin
2024-06-15 7:32 ` Simon Horman
2024-05-28 13:48 ` [PATCH iwl-next 04/12] idpf: avoid bloating &idpf_q_vector with big %NR_CPUS Alexander Lobakin
2024-05-28 13:48 ` [PATCH iwl-next 05/12] idpf: strictly assert cachelines of queue and queue vector structures Alexander Lobakin
[not found] ` <b25cab15-f73c-4df8-bfca-434a8f717a31@intel.com>
2024-06-12 13:03 ` [Intel-wired-lan] " Alexander Lobakin
2024-06-12 13:08 ` Alexander Lobakin
2024-06-12 22:42 ` Jacob Keller
2024-06-12 22:40 ` Jacob Keller
2024-05-28 13:48 ` [PATCH iwl-next 06/12] idpf: merge singleq and splitq &net_device_ops Alexander Lobakin
2024-05-28 13:48 ` [PATCH iwl-next 07/12] idpf: compile singleq code only under default-n CONFIG_IDPF_SINGLEQ Alexander Lobakin
2024-05-28 13:48 ` [PATCH iwl-next 08/12] idpf: reuse libeth's definitions of parsed ptype structures Alexander Lobakin
2024-05-28 13:48 ` [PATCH iwl-next 09/12] idpf: remove legacy Page Pool Ethtool stats Alexander Lobakin
2024-05-28 13:48 ` [PATCH iwl-next 10/12] libeth: support different types of buffers for Rx Alexander Lobakin
2024-05-28 13:48 ` [PATCH iwl-next 11/12] idpf: convert header split mode to libeth + napi_build_skb() Alexander Lobakin
2024-05-30 1:40 ` Jakub Kicinski
2024-06-13 10:58 ` Alexander Lobakin
2024-05-30 13:46 ` Willem de Bruijn
2024-06-17 11:06 ` Alexander Lobakin
2024-06-17 18:13 ` Willem de Bruijn
2024-06-20 12:46 ` Alexander Lobakin
2024-06-20 16:29 ` Willem de Bruijn
2024-05-28 13:48 ` [PATCH iwl-next 12/12] idpf: use libeth Rx buffer management for payload buffer Alexander Lobakin
2024-06-01 9:08 ` Simon Horman
2024-06-13 11:05 ` Alexander Lobakin
2024-06-15 7:35 ` Simon Horman [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=20240615073509.GA8447@kernel.org \
--to=horms@kernel.org \
--cc=aleksander.lobakin@intel.com \
--cc=almasrymina@google.com \
--cc=anthony.l.nguyen@intel.com \
--cc=dan.carpenter@linaro.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nex.sw.ncis.osdt.itp.upstreaming@intel.com \
--cc=pabeni@redhat.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).