From: Florian Fainelli <f.fainelli@gmail.com>
To: Sieng Piaw Liew <liew.s.piaw@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>
Cc: bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 5/6] bcm63xx_enet: convert to build_skb
Date: Mon, 28 Dec 2020 19:24:03 -0800 [thread overview]
Message-ID: <49b174e9-df1c-a2fc-f5d5-adeabd940692@gmail.com> (raw)
In-Reply-To: <20201224142421.32350-6-liew.s.piaw@gmail.com>
On 12/24/2020 6:24 AM, Sieng Piaw Liew wrote:
> We can increase the efficiency of rx path by using buffers to receive
> packets then build SKBs around them just before passing into the network
> stack. In contrast, preallocating SKBs too early reduces CPU cache
> efficiency.
>
> Check if we're in NAPI context when refilling RX. Normally we're almost
> always running in NAPI context. Dispatch to napi_alloc_frag directly
> instead of relying on netdev_alloc_frag which does the same but
> with the overhead of local_bh_disable/enable.
>
> Tested on BCM6328 320 MHz and iperf3 -M 512 to measure packet/sec
> performance. Included netif_receive_skb_list and NET_IP_ALIGN
> optimizations.
>
> Before:
> [ ID] Interval Transfer Bandwidth Retr
> [ 4] 0.00-10.00 sec 49.9 MBytes 41.9 Mbits/sec 197 sender
> [ 4] 0.00-10.00 sec 49.3 MBytes 41.3 Mbits/sec receiver
>
> After:
> [ ID] Interval Transfer Bandwidth Retr
> [ 4] 0.00-30.00 sec 171 MBytes 47.8 Mbits/sec 272 sender
> [ 4] 0.00-30.00 sec 170 MBytes 47.6 Mbits/sec receiver
This looks good, however there are a few nits and suggestions below:
[snip]
> @@ -862,6 +868,24 @@ static void bcm_enet_adjust_link(struct net_device *dev)
> priv->pause_tx ? "tx" : "off");
> }
>
> +static void bcm_enet_free_rx_buf_ring(struct device *kdev, struct bcm_enet_priv *priv)
> +{
> + int i;
> +
> + for (i = 0; i < priv->rx_ring_size; i++) {
> + struct bcm_enet_desc *desc;
> +
> + if (!priv->rx_buf[i])
> + continue;
> +
> + desc = &priv->rx_desc_cpu[i];
> + dma_unmap_single(kdev, desc->address, priv->rx_buf_size,
> + DMA_FROM_DEVICE);
> + skb_free_frag(priv->rx_buf[i]);
> + }
> + kfree(priv->rx_buf);
> +}
This is a good helper to introduced, however I would introduce it as a
preliminary patch that way it becomes clear when you are doing the
sk_buff to buf substitution in the next patch.
[snip]
> @@ -1640,9 +1641,12 @@ static int bcm_enet_change_mtu(struct net_device *dev, int new_mtu)
> * align rx buffer size to dma burst len, account FCS since
> * it's appended
> */
> - priv->rx_skb_size = ALIGN(actual_mtu + ETH_FCS_LEN,
> + priv->rx_buf_size = ALIGN(actual_mtu + ETH_FCS_LEN,
> priv->dma_maxburst * 4);
>
> + priv->rx_frag_size = SKB_DATA_ALIGN(priv->rx_buf_offset + priv->rx_buf_size)
> + + SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
The alignment of the second line is a bit off and you should aim for the
+ operator to be on the preceding line, and have SKB_DATA_ALIGN() start
on the opening parenthesis of the preceding line.
--
Florian
next prev parent reply other threads:[~2020-12-29 3:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-24 14:24 [PATCH net-next v2 0/6] bcm63xx_enet: major makeover of driver Sieng Piaw Liew
2020-12-24 14:24 ` [PATCH net-next v2 1/6] bcm63xx_enet: batch process rx path Sieng Piaw Liew
2020-12-29 3:11 ` Florian Fainelli
2020-12-24 14:24 ` [PATCH net-next v2 2/6] bcm63xx_enet: add BQL support Sieng Piaw Liew
2020-12-29 3:12 ` Florian Fainelli
2020-12-24 14:24 ` [PATCH net-next v2 3/6] bcm63xx_enet: add xmit_more support Sieng Piaw Liew
2020-12-28 20:40 ` Jakub Kicinski
2020-12-29 3:13 ` Florian Fainelli
2020-12-24 14:24 ` [PATCH net-next v2 4/6] bcm63xx_enet: alloc rx skb with NET_IP_ALIGN Sieng Piaw Liew
2020-12-29 3:14 ` Florian Fainelli
2020-12-24 14:24 ` [PATCH net-next v2 5/6] bcm63xx_enet: convert to build_skb Sieng Piaw Liew
2020-12-29 3:24 ` Florian Fainelli [this message]
2020-12-24 14:24 ` [PATCH net-next v2 6/6] bcm63xx_enet: improve rx loop Sieng Piaw Liew
2020-12-29 3:17 ` Florian Fainelli
2020-12-28 20:39 ` [PATCH net-next v2 0/6] bcm63xx_enet: major makeover of driver Jakub Kicinski
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=49b174e9-df1c-a2fc-f5d5-adeabd940692@gmail.com \
--to=f.fainelli@gmail.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=liew.s.piaw@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.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).