netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: herbert@gondor.apana.org.au
Cc: edgar.iglesias@axis.com, hadi@cyberus.ca, shemminger@osdl.org,
	mchan@broadcom.com, jesse.brandeburg@intel.com,
	auke-jan.h.kok@intel.com, netdev@vger.kernel.org
Subject: Re: [PATCH] [e1000]: Remove unnecessary tx_lock
Date: Sun, 06 Aug 2006 01:35:16 -0700 (PDT)	[thread overview]
Message-ID: <20060806.013516.35333380.davem@davemloft.net> (raw)
In-Reply-To: <20060806073655.GA28735@gondor.apana.org.au>

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Sun, 6 Aug 2006 17:36:55 +1000

> Actually, why do we charge the memory to the socket at all between
> the packet leaving the TCP stack and it entering the device?

Because it's easy to verify that it prevents all the possible
DoS scenerios a user could play out.

> Most packets spend a tiny amount of time on this journey so it seems
> silly to do atomic operations as they leave the stack only to undo
> it when they enter the device.

I agree.

> The biggest reason packets spend a non-trivial amount of time on
> this journey is traffic shaping.  In that case the memory is already
> accounted to the device anyway (in terms of queue length) so it would
> seem unfair to charge the socket as well.

Again, total agreement.

> So how about simply charging the socket for the retransmit queue
> as we do now and skip the caharge for packets leaving the stack?
> 
> For UDP it's different since it doesn't have a retransmit queue.
> However, I'm unsure how much of a positive effect the socket charge
> actually has for UDP.

UDP and other datagram protocols are a thorny case aren't they? :)

This has actually been a source of problems in the past, come to think
of it.  We used to have this bug in the output path where UDP could
build a packet of size X that fit in the socket send buffer, but if we
had to fragment this packet because "mtu < X" not all of the fragments
would fit in the socket send buffer and we'd drop the entire packet :)

What happens now is we just try to strictly charge the first fragment
to the socket's send buffer on fragmentation and then we only enfore
lighter rules (allowing up to "2 * sk_sndbuf" to be used) as we charge
for the rest of the frags.

You can see this logic in ip_append_data():

		if (transhdrlen) {
			skb = sock_alloc_send_skb(sk, 
					alloclen + hh_len + 15,
					(flags & MSG_DONTWAIT), &err);
		} else {
			skb = NULL;
			if (atomic_read(&sk->sk_wmem_alloc) <=
			    2 * sk->sk_sndbuf)
				skb = sock_wmalloc(sk, 
						   alloclen + hh_len + 15, 1,
						   sk->sk_allocation);
			if (unlikely(skb == NULL))
				err = -ENOBUFS;
		}

As you say these things are about to go out to the device, so it's
kind of silly from that perspective, BUT...  it does exist to a
certain extent for application flow control, especially for these
datagram apps.

I tried to see if there was any wisdom on this matter in TCP/IP
Illustrated Volume 2, but BSD does the same thing we do.

  parent reply	other threads:[~2006-08-06  8:35 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-03 13:15 [PATCH] [e1000]: Remove unnecessary tx_lock jamal
2006-08-03 14:02 ` Herbert Xu
2006-08-03 14:24   ` jamal
2006-08-03 16:36   ` Brandeburg, Jesse
2006-08-03 18:05     ` Michael Chan
2006-08-03 22:08       ` jamal
2006-08-04  0:09         ` Michael Chan
2006-08-04  1:10           ` Herbert Xu
2006-08-04  8:37             ` Herbert Xu
2006-08-04 10:10               ` Herbert Xu
2006-08-04 10:16                 ` jamal
2006-08-04 10:25                   ` Herbert Xu
2006-08-04 10:45                     ` jamal
2006-08-05 23:04                     ` jamal
2006-08-05 23:06                       ` Herbert Xu
2006-08-05 23:21                         ` jamal
2006-08-05 23:30                           ` Herbert Xu
2006-08-05 16:45                   ` jamal
2006-08-04 17:12                 ` Stephen Hemminger
2006-08-04 17:28                 ` Michael Chan
2006-08-04 18:08                   ` Stephen Hemminger
2006-08-04 23:31                     ` David Miller
2006-08-05 16:56                       ` jamal
2006-08-05 23:05                         ` Herbert Xu
2006-08-05 23:17                           ` jamal
2006-08-05 23:19                             ` Herbert Xu
2006-08-05 23:36                               ` jamal
2006-08-06  2:51                                 ` Herbert Xu
2006-08-06  7:14                                   ` Edgar E. Iglesias
2006-08-06  7:24                                     ` Herbert Xu
2006-08-06  7:30                                       ` Edgar E. Iglesias
2006-08-06  7:26                                     ` David Miller
2006-08-06  7:36                                       ` Herbert Xu
2006-08-06  8:06                                         ` Edgar E. Iglesias
2006-08-06  8:27                                           ` Herbert Xu
2006-08-06  9:03                                             ` Edgar E. Iglesias
2006-08-06  9:10                                               ` Herbert Xu
2006-08-06  9:18                                                 ` Edgar E. Iglesias
2006-08-06  8:35                                         ` David Miller [this message]
2006-08-06 12:24                                   ` jamal
2006-08-06 12:33                                     ` jamal
2006-08-06 23:16                                       ` Jesse Brandeburg
2006-08-07 12:50                                         ` jamal
2006-08-07 15:21                                           ` Edgar E. Iglesias
2006-08-07 15:40                                             ` jamal
2006-08-07 15:59                                               ` Edgar E. Iglesias
2006-08-07 16:31                                                 ` Jamal Hadi Salim
2006-08-07 17:04                                                   ` Edgar E. Iglesias
2006-08-07 18:00                                                     ` jamal
2006-08-07 18:47                                                       ` Edgar E. Iglesias
2006-08-07 19:03                                                         ` jamal
2006-08-07 19:14                                                           ` Edgar E. Iglesias
2006-08-07 19:34                                                             ` jamal
2006-08-07 20:28                                                               ` Edgar E. Iglesias
2006-08-08  0:52                                                                 ` jamal
2006-08-07 20:53                                                           ` Brandeburg, Jesse
2006-08-08  1:07                                                             ` jamal
2006-08-07 23:23                                                           ` Herbert Xu
2006-08-07 23:35                                                             ` Brandeburg, Jesse
2006-08-07 23:40                                                               ` Herbert Xu
2006-08-07 16:29                                               ` Edgar E. Iglesias
2006-08-07 16:36                                                 ` jamal
2006-08-06 19:22                                     ` jamal
2006-08-08  1:19                                     ` jamal
2006-08-08  1:22                                       ` Herbert Xu
2006-08-08  1:33                                         ` jamal
2006-08-08  2:17                                           ` Herbert Xu
2006-08-08  3:10                                             ` jamal
2006-08-08 12:21                                   ` jamal
2006-08-08 12:39                                     ` Herbert Xu
2006-08-06 17:20                           ` Michael Chan
2006-08-06 23:04                             ` Herbert Xu
2006-08-07  3:56                               ` Michael Chan
2006-08-07  4:21                                 ` Herbert Xu
2006-08-08 17:04                       ` Benjamin LaHaise
2006-08-08 22:06                         ` David Miller
2006-08-08 23:21                           ` Benjamin LaHaise
2006-08-09  0:25                             ` Herbert Xu
2006-08-09  1:25                               ` Benjamin LaHaise
2006-08-04  1:16           ` jamal
2006-08-04  1:18             ` Herbert Xu
2006-08-04  1:25               ` jamal
2006-08-04  4:06             ` Michael Chan
2006-08-03 22:06     ` jamal
  -- strict thread matches above, loose matches on Subject: below --
2006-08-08  5:43 Brandeburg, Jesse

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=20060806.013516.35333380.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=auke-jan.h.kok@intel.com \
    --cc=edgar.iglesias@axis.com \
    --cc=hadi@cyberus.ca \
    --cc=herbert@gondor.apana.org.au \
    --cc=jesse.brandeburg@intel.com \
    --cc=mchan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@osdl.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).