From: Luis Henriques <luis.henriques@canonical•com>
To: Eric Dumazet <eric.dumazet@gmail•com>
Cc: Ben Hutchings <bhutchings@solarflare•com>,
Neil Horman <nhorman@tuxdriver•com>,
David Miller <davem@davemloft•net>,
netdev@vger•kernel.org, jcliburn@gmail•com
Subject: Re: [net PATCH] atl1c: Fix misuse of netdev_alloc_skb in refilling rx ring
Date: Tue, 30 Jul 2013 09:53:02 +0100 [thread overview]
Message-ID: <87fvuwh1jl.fsf@canonical.com> (raw)
In-Reply-To: <1375118644.10515.18.camel@edumazet-glaptop> (Eric Dumazet's message of "Mon, 29 Jul 2013 10:24:04 -0700")
Eric Dumazet <eric.dumazet@gmail•com> writes:
> From: Eric Dumazet <edumazet@google•com>
>
> On Mon, 2013-07-29 at 08:30 -0700, Eric Dumazet wrote:
>> On Mon, 2013-07-29 at 13:09 +0100, Luis Henriques wrote:
>>
>> >
>> > I confirm that I can't reproduce the issue using this patch.
>> >
>>
>> Thanks, I'll send a polished patch, as this one had an error if
>> build_skb() returns NULL (in case sk_buff allocation fails)
>
> Please try the following patch : It should use 2K frags instead of 4K
> for normal 1500 mtu
This patch seems to work fine as well -- I'm unable to reproduce the
issue.
Cheers,
--
Luis
>
> Thanks !
>
> [PATCH] atl1c: use custom skb allocator
>
> We had reports ( https://bugzilla.kernel.org/show_bug.cgi?id=54021 )
> that using high order pages for skb allocations is problematic for atl1c
>
> We do not know exactly what the problem is, but we suspect that crossing
> 4K pages is not well supported by this hardware.
>
> Use a custom allocator, using page allocator and 2K fragments for
> optimal stack behavior. We might make this allocator generic
> in future kernels.
>
> Signed-off-by: Eric Dumazet <edumazet@google•com>
> Cc: Luis Henriques <luis.henriques@canonical•com>
> Cc: Neil Horman <nhorman@tuxdriver•com>
> ---
> drivers/net/ethernet/atheros/atl1c/atl1c.h | 3 +
> drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 40 +++++++++++++-
> 2 files changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c.h b/drivers/net/ethernet/atheros/atl1c/atl1c.h
> index b2bf324..0f05565 100644
> --- a/drivers/net/ethernet/atheros/atl1c/atl1c.h
> +++ b/drivers/net/ethernet/atheros/atl1c/atl1c.h
> @@ -520,6 +520,9 @@ struct atl1c_adapter {
> struct net_device *netdev;
> struct pci_dev *pdev;
> struct napi_struct napi;
> + struct page *rx_page;
> + unsigned int rx_page_offset;
> + unsigned int rx_frag_size;
> struct atl1c_hw hw;
> struct atl1c_hw_stats hw_stats;
> struct mii_if_info mii; /* MII interface info */
> diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> index 786a874..a36a760 100644
> --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> @@ -481,10 +481,15 @@ static int atl1c_set_mac_addr(struct net_device *netdev, void *p)
> static void atl1c_set_rxbufsize(struct atl1c_adapter *adapter,
> struct net_device *dev)
> {
> + unsigned int head_size;
> int mtu = dev->mtu;
>
> adapter->rx_buffer_len = mtu > AT_RX_BUF_SIZE ?
> roundup(mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN, 8) : AT_RX_BUF_SIZE;
> +
> + head_size = SKB_DATA_ALIGN(adapter->rx_buffer_len + NET_SKB_PAD) +
> + SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
> + adapter->rx_frag_size = roundup_pow_of_two(head_size);
> }
>
> static netdev_features_t atl1c_fix_features(struct net_device *netdev,
> @@ -952,6 +957,10 @@ static void atl1c_free_ring_resources(struct atl1c_adapter *adapter)
> kfree(adapter->tpd_ring[0].buffer_info);
> adapter->tpd_ring[0].buffer_info = NULL;
> }
> + if (adapter->rx_page) {
> + put_page(adapter->rx_page);
> + adapter->rx_page = NULL;
> + }
> }
>
> /**
> @@ -1639,6 +1648,35 @@ static inline void atl1c_rx_checksum(struct atl1c_adapter *adapter,
> skb_checksum_none_assert(skb);
> }
>
> +static struct sk_buff *atl1c_alloc_skb(struct atl1c_adapter *adapter)
> +{
> + struct sk_buff *skb;
> + struct page *page;
> +
> + if (adapter->rx_frag_size > PAGE_SIZE)
> + return netdev_alloc_skb(adapter->netdev,
> + adapter->rx_buffer_len);
> +
> + page = adapter->rx_page;
> + if (!page) {
> + adapter->rx_page = page = alloc_page(GFP_ATOMIC);
> + if (unlikely(!page))
> + return NULL;
> + adapter->rx_page_offset = 0;
> + }
> +
> + skb = build_skb(page_address(page) + adapter->rx_page_offset,
> + adapter->rx_frag_size);
> + if (likely(skb)) {
> + adapter->rx_page_offset += adapter->rx_frag_size;
> + if (adapter->rx_page_offset >= PAGE_SIZE)
> + adapter->rx_page = NULL;
> + else
> + get_page(page);
> + }
> + return skb;
> +}
> +
> static int atl1c_alloc_rx_buffer(struct atl1c_adapter *adapter)
> {
> struct atl1c_rfd_ring *rfd_ring = &adapter->rfd_ring;
> @@ -1660,7 +1698,7 @@ static int atl1c_alloc_rx_buffer(struct atl1c_adapter *adapter)
> while (next_info->flags & ATL1C_BUFFER_FREE) {
> rfd_desc = ATL1C_RFD_DESC(rfd_ring, rfd_next_to_use);
>
> - skb = netdev_alloc_skb(adapter->netdev, adapter->rx_buffer_len);
> + skb = atl1c_alloc_skb(adapter);
> if (unlikely(!skb)) {
> if (netif_msg_rx_err(adapter))
> dev_warn(&pdev->dev, "alloc rx buffer failed\n");
>
next prev parent reply other threads:[~2013-07-30 8:53 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-26 16:47 [net PATCH] atl1c: Fix misuse of netdev_alloc_skb in refilling rx ring Neil Horman
2013-07-26 16:56 ` Luis Henriques
2013-07-26 17:02 ` Neil Horman
2013-07-26 22:56 ` David Miller
2013-07-27 16:25 ` Luis Henriques
2013-07-27 0:02 ` Ben Hutchings
2013-07-27 0:24 ` Ben Hutchings
2013-07-27 19:30 ` Luis Henriques
2013-07-27 19:49 ` Eric Dumazet
2013-07-27 21:30 ` Ben Hutchings
2013-07-27 23:59 ` Eric Dumazet
2013-07-28 3:02 ` David Miller
2013-07-28 10:44 ` Neil Horman
2013-07-28 16:15 ` Eric Dumazet
2013-07-28 18:53 ` Neil Horman
2013-07-28 19:21 ` Eric Dumazet
2013-07-28 20:08 ` Eric Dumazet
2013-07-28 20:22 ` Ben Hutchings
2013-07-28 23:01 ` Eric Dumazet
2013-07-28 23:20 ` Eric Dumazet
2013-07-28 23:25 ` Eric Dumazet
2013-07-28 23:38 ` Neil Horman
2013-07-29 0:07 ` Ben Hutchings
2013-07-29 0:21 ` David Miller
2013-07-29 0:26 ` Eric Dumazet
2013-07-29 9:55 ` Luis Henriques
2013-07-29 10:57 ` Eric Dumazet
2013-07-29 12:09 ` Luis Henriques
2013-07-29 15:30 ` Eric Dumazet
2013-07-29 17:24 ` Eric Dumazet
2013-07-30 8:53 ` Luis Henriques [this message]
2013-07-31 2:11 ` David Miller
2013-07-31 17:48 ` Benjamin Poirier
2013-07-31 17:56 ` Eric Dumazet
2013-07-31 19:01 ` David Miller
2013-08-01 1:57 ` 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=87fvuwh1jl.fsf@canonical.com \
--to=luis.henriques@canonical$(echo .)com \
--cc=bhutchings@solarflare$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=eric.dumazet@gmail$(echo .)com \
--cc=jcliburn@gmail$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nhorman@tuxdriver$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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