netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: Jim Baxter <jim_baxter@mentor.com>
Cc: David Miller <davem@davemloft.net>, <eric.dumazet@gmail.com>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<netdev@vger.kernel.org>, <kamal@canonical.com>,
	<edumazet@google.com>, <mszeredi@suse.cz>, <fw@strlen.de>
Subject: Re: skbuff truesize incorrect.
Date: Fri, 23 May 2014 11:33:46 +0200	[thread overview]
Message-ID: <87vbsw4z5x.fsf@nemi.mork.no> (raw)
In-Reply-To: <537F0DCA.6030901@mentor.com> (Jim Baxter's message of "Fri, 23 May 2014 09:58:50 +0100")

[-- Attachment #1: Type: text/plain, Size: 740 bytes --]

Jim Baxter <jim_baxter@mentor.com> writes:

>> I'll create and test a patch for the cdc_ncm host driver unless someone
>> else wants to do that. I haven't really played with the gadget driver
>> before, so I'd prefer if someone knowing it (Jim maybe?) could take care
>> of it.  If not, then I can always make an attempt using dummy_hcd to
>> test it.
> I can create a patch for the host driver, I will issue the gadget patch
> first to resolve any issues, the fix would be similar.

Well, I couldn't help myself.  I just had to test it.  The attached
patch works for me, briefly tested with an Ericsson H5321gw NCM device.
I have no ideas about the performance impact as that modem is limited to
21 Mbps HSDPA.


Bjørn


[-- Attachment #2: 0001-net-cdc_ncm-reduce-skb-truesize-in-rx-path.patch --]
[-- Type: text/x-diff, Size: 1443 bytes --]

>From 4c7431cd046a6972e153e23249ad490a3692f9a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bjorn@mork.no>
Date: Fri, 23 May 2014 09:40:51 +0200
Subject: [RFC] net: cdc_ncm: reduce skb truesize in rx path
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Cloning the big skbs we use for USB buffering chokes up TCP and
SCTP because the socket memory limits are hitting earlier than
they should. It is better to unconditionally copy the unwrapped
packets to freshly allocated skbs.

Reported-by: Jim Baxter <jim_baxter@mentor.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 drivers/net/usb/cdc_ncm.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 93c9ca9924eb..2bbbd65591c7 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -1289,12 +1289,11 @@ next_ndp:
 			break;
 
 		} else {
-			skb = skb_clone(skb_in, GFP_ATOMIC);
+			/* create a fresh copy to reduce truesize */
+			skb = netdev_alloc_skb_ip_align(dev->net,  len);
 			if (!skb)
 				goto error;
-			skb->len = len;
-			skb->data = ((u8 *)skb_in->data) + offset;
-			skb_set_tail_pointer(skb, len);
+			memcpy(skb_put(skb, len), skb_in->data + offset, len);
 			usbnet_skb_return(dev, skb);
 			payload += len;	/* count payload bytes in this NTB */
 		}
-- 
2.0.0.rc4


  reply	other threads:[~2014-05-23  9:33 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22 19:07 skbuff truesize incorrect Jim Baxter
2014-05-22 19:21 ` David Miller
2014-05-22 20:21   ` Jim Baxter
     [not found]     ` <537E5C63.7080607-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2014-05-22 20:30       ` Eric Dumazet
2014-05-22 20:58     ` David Miller
2014-05-23  9:21       ` Jim Baxter
2014-05-23  9:27         ` David Laight
2014-05-23 16:46         ` David Miller
2014-05-22 19:25 ` Vlad Yasevich
2014-05-22 19:39   ` Jim Baxter
2014-05-22 19:59     ` Eric Dumazet
2014-05-22 20:21       ` Jim Baxter
2014-05-22 20:58 ` Eric Dumazet
2014-05-22 21:03   ` Eric Dumazet
2014-05-22 21:10     ` David Miller
2014-05-23  7:07       ` Bjørn Mork
2014-05-23  8:58         ` Jim Baxter
2014-05-23  9:33           ` Bjørn Mork [this message]
2014-05-23 14:00             ` Eric Dumazet
2014-05-23 15:44             ` Rick Jones
2014-05-23 16:00               ` Eric Dumazet
2014-05-23  8:52   ` David Laight
2014-05-23  9:48     ` Bjørn Mork
2014-05-23 10:45       ` David Laight
2014-05-23 11:13         ` Jim Baxter
2014-05-23 13:47           ` Eric Dumazet
2014-05-23 15:00             ` Jim Baxter
2014-05-23 15:30             ` David Laight
2014-05-23 15:41               ` Eric Dumazet
2014-05-23 20:18     ` David Miller
2014-05-27 15:23       ` David Laight
     [not found]         ` <063D6719AE5E284EB5DD2968C1650D6D1724E565-VkEWCZq2GCInGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
2014-05-27 15:52           ` 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=87vbsw4z5x.fsf@nemi.mork.no \
    --to=bjorn@mork.no \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=fw@strlen.de \
    --cc=jim_baxter@mentor.com \
    --cc=kamal@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mszeredi@suse.cz \
    --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).