From: Giuseppe CAVALLARO <peppe.cavallaro@st.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net
Subject: Re: [net-next 8/8] stmmac: limit max_mtu in case of 4KiB and use __netdev_alloc_skb.
Date: Tue, 18 Oct 2011 13:33:42 +0200 [thread overview]
Message-ID: <4E9D6416.8070702@st.com> (raw)
In-Reply-To: <1318933110.2657.39.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC>
On 10/18/2011 12:18 PM, Eric Dumazet wrote:
> Le mardi 18 octobre 2011 à 12:01 +0200, Giuseppe CAVALLARO a écrit :
>> Problem using big mtu around 4096 bytes is you end allocating (4096
>> +NET_SKB_PAD + NET_IP_ALIGN + sizeof(struct skb_shared_info) bytes ->
>> 8192 bytes : order-1 pages
>>
>> It's better to limit the mtu to SKB_MAX_HEAD(NET_SKB_PAD),
>> to have no more than one page per skb.
>>
>> Also the patch changes the netdev_alloc_skb_ip_align() done in
>> init_dma_desc_rings() and uses a variant allowing GFP_KERNEL allocations
>> allowing the driver to load even in case of memory pressure.
>>
>> Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
>> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
>> ---
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 +++++++++----
>> 1 files changed, 9 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> index 1848a16..f5ca3be 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>> @@ -474,11 +474,13 @@ static void init_dma_desc_rings(struct net_device *dev)
>> for (i = 0; i < rxsize; i++) {
>> struct dma_desc *p = priv->dma_rx + i;
>>
>> - skb = netdev_alloc_skb_ip_align(dev, bfsize);
>> + skb = __netdev_alloc_skb(dev, bfsize + NET_IP_ALIGN,
>> + GFP_KERNEL);
>> if (unlikely(skb == NULL)) {
>> pr_err("%s: Rx init fails; skb is NULL\n", __func__);
>> break;
>> }
>> + skb_reserve(skb, NET_IP_ALIGN);
>> priv->rx_skbuff[i] = skb;
>> priv->rx_skbuff_dma[i] = dma_map_single(priv->device, skb->data,
>> bfsize, DMA_FROM_DEVICE);
>> @@ -1176,12 +1178,15 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv)
>>
>> skb = __skb_dequeue(&priv->rx_recycle);
>> if (skb == NULL)
>> - skb = netdev_alloc_skb_ip_align(priv->dev,
>> - bfsize);
>> + skb = __netdev_alloc_skb(priv->dev, bfsize +
>> + NET_IP_ALIGN,
>> + GFP_KERNEL);
>>
>
> No, you cant do that in softirq context. We cant sleep here and must use
> GFP_ATOMIC
> Only the init_dma_desc_rings() part is OK, we run in process context and
> are allowed to sleep in memory allocations (GFP_KERNEL)
>
>
>> if (unlikely(skb == NULL))
>> break;
>>
>> + skb_reserve(skb, NET_IP_ALIGN);
>> +
>> priv->rx_skbuff[entry] = skb;
>> priv->rx_skbuff_dma[entry] =
>> dma_map_single(priv->device, skb->data, bfsize,
>> @@ -1401,7 +1406,7 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
>> if (priv->plat->enh_desc)
>> max_mtu = JUMBO_LEN;
>> else
>> - max_mtu = BUF_SIZE_4KiB;
>> + max_mtu = SKB_MAX_HEAD(NET_SKB_PAD);
>>
>
> minor nit (since NET_IP_ALIGN is 0 anyway on modern x86)
> max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN);
>
>
>> if ((new_mtu < 46) || (new_mtu > max_mtu)) {
>> pr_err("%s: invalid MTU, max MTU is: %d\n", dev->name, max_mtu);
>
>
>
Ok! I'm reworking and sending it again.
Thx
Peppe
next prev parent reply other threads:[~2011-10-18 11:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-18 10:01 [net-next 0/8] stmmac: update to Oct 2011 version (v4) Giuseppe CAVALLARO
2011-10-18 10:01 ` [net-next 1/8] stmmac: Stop advertising 1000Base capabilties for non GMII iface (V4) Giuseppe CAVALLARO
2011-10-18 10:01 ` [net-next 2/8] stmmac: protect tx process with lock (V4) Giuseppe CAVALLARO
2011-10-18 10:01 ` [net-next 3/8] stmmac: update the driver version and doc (V4) Giuseppe CAVALLARO
2011-10-18 10:01 ` [net-next 4/8] stmmac: allow mtu bigger than 1500 in case of normal desc (V4) Giuseppe CAVALLARO
2011-10-18 10:01 ` [net-next 5/8] stmmac: use predefined macros for HW cap register fields (V4) Giuseppe CAVALLARO
2011-10-18 10:01 ` [net-next 6/8] stmmac: allow mmc usage only if feature actually available (V4) Giuseppe CAVALLARO
2011-10-18 10:01 ` [net-next 7/8] stmmac: add CHAINED descriptor mode support (V4) Giuseppe CAVALLARO
2011-10-18 10:01 ` [net-next 8/8] stmmac: limit max_mtu in case of 4KiB and use __netdev_alloc_skb Giuseppe CAVALLARO
2011-10-18 10:18 ` Eric Dumazet
2011-10-18 11:33 ` Giuseppe CAVALLARO [this message]
2011-10-18 11:39 ` [net-next] stmmac: limit max_mtu in case of 4KiB and use __netdev_alloc_skb (V2) Giuseppe CAVALLARO
2011-10-18 12:26 ` Eric Dumazet
2011-10-19 22:53 ` [net-next 0/8] stmmac: update to Oct 2011 version (v4) David Miller
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=4E9D6416.8070702@st.com \
--to=peppe.cavallaro@st.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--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).