13 Dec, 2011

1 commit

  • This patch allows each namespace to independently set up
    its levels for tcp memory pressure thresholds. This patch
    alone does not buy much: we need to make this values
    per group of process somehow. This is achieved in the
    patches that follows in this patchset.

    Signed-off-by: Glauber Costa
    Reviewed-by: KAMEZAWA Hiroyuki
    CC: David S. Miller
    CC: Eric W. Biederman
    Signed-off-by: David S. Miller

    Glauber Costa
     

06 Dec, 2011

1 commit


05 Dec, 2011

1 commit

  • If our TCP_PAGE(sk) is not shared (page_count() == 1), we can set page
    offset to 0.

    This permits better filling of the pages on small to medium tcp writes.

    "tbench 16" results on my dev server (2x4x2 machine) :

    Before : 3072 MB/s
    After : 3146 MB/s (2.4 % gain)

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

30 Nov, 2011

1 commit

  • tcp_sendmsg() uses select_size() helper to choose skb head size when a
    new skb must be allocated.

    If GSO is enabled for the socket, current strategy is to force all
    payload data to be outside of headroom, in PAGE fragments.

    This strategy is not welcome for small packets, wasting memory.

    Experiments show that best results are obtained when using 2048 bytes
    for skb head (This includes the skb overhead and various headers)

    This patch provides better len/truesize ratios for packets sent to
    loopback device, and reduce memory needs for in-flight loopback packets,
    particularly on arches with big pages.

    If a sender sends many 1-byte packets to an unresponsive application,
    receiver rmem_alloc will grow faster and will stop queuing these packets
    sooner, or will collapse its receive queue to free excess memory.

    netperf -t TCP_RR results are improved by ~4 %, and many workloads are
    improved as well (tbench, mysql...)

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

29 Nov, 2011

1 commit


17 Nov, 2011

1 commit


25 Oct, 2011

1 commit


24 Oct, 2011

1 commit


21 Oct, 2011

1 commit

  • Adding const qualifiers to pointers can ease code review, and spot some
    bugs. It might allow compiler to optimize code further.

    For example, is it legal to temporary write a null cksum into tcphdr
    in tcp_md5_hash_header() ? I am afraid a sniffer could catch the
    temporary null value...

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

19 Oct, 2011

1 commit

  • To ease skb->truesize sanitization, its better to be able to localize
    all references to skb frags size.

    Define accessors : skb_frag_size() to fetch frag size, and
    skb_frag_size_{set|add|sub}() to manipulate it.

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

04 Oct, 2011

1 commit

  • Allows ss command (iproute2) to display "ecnseen" if at least one packet
    with ECT(0) or ECT(1) or ECN was received by this socket.

    "ecn" means ECN was negotiated at session establishment (TCP level)

    "ecnseen" means we received at least one packet with ECT fields set (IP
    level)

    ss -i
    ...
    ESTAB 0 0 192.168.20.110:22 192.168.20.144:38016
    ino:5950 sk:f178e400
    mem:(r0,w0,f0,t0) ts sack ecn ecnseen bic wscale:7,8 rto:210
    rtt:12.5/7.5 cwnd:10 send 9.3Mbps rcv_space:14480

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

28 Sep, 2011

1 commit

  • Rename struct tcp_skb_cb "flags" to "tcp_flags" to ease code review and
    maintenance.

    Its content is a combination of FIN/SYN/RST/PSH/ACK/URG/ECE/CWR flags

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

17 Sep, 2011

1 commit

  • tcp_md5sig_pool is currently an 'array' (a percpu object) of pointers to
    struct tcp_md5sig_pool. Only the pointers are NUMA aware, but objects
    themselves are all allocated on a single node.

    Remove this extra indirection to get proper percpu memory (NUMA aware)
    and make code simpler.

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

25 Aug, 2011

1 commit


07 Jul, 2011

1 commit

  • Current tcp/udp/sctp global memory limits are not taking into account
    hugepages allocations, and allow 50% of ram to be used by buffers of a
    single protocol [ not counting space used by sockets / inodes ...]

    Lets use nr_free_buffer_pages() and allow a default of 1/8 of kernel ram
    per protocol, and a minimum of 128 pages.
    Heavy duty machines sysadmins probably need to tweak limits anyway.

    References: https://bugzilla.stlinux.com/show_bug.cgi?id=38032
    Reported-by: starlight
    Suggested-by: Andrew Morton
    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

05 Apr, 2011

1 commit

  • This patch uses __copy_from_user_nocache on transmit to bypass data
    cache for a performance improvement. skb_add_data_nocache and
    skb_copy_to_page_nocache can be called by sendmsg functions to use
    this feature, initial support is in tcp_sendmsg. This functionality is
    configurable per device using ethtool.

    Presumably, this feature would only be useful when the driver does
    not touch the data. The feature is turned on by default if a device
    indicates that it does some form of checksum offload; it is off by
    default for devices that do no checksum offload or indicate no checksum
    is necessary. For the former case copy-checksum is probably done
    anyway, in the latter case the device is likely loopback in which case
    the no cache copy is probably not beneficial.

    This patch was tested using 200 instances of netperf TCP_RR with
    1400 byte request and one byte reply. Platform is 16 core AMD x86.

    No-cache copy disabled:
    672703 tps, 97.13% utilization
    50/90/99% latency:244.31 484.205 1028.41

    No-cache copy enabled:
    702113 tps, 96.16% utilization,
    50/90/99% latency 238.56 467.56 956.955

    Using 14000 byte request and response sizes demonstrate the
    effects more dramatically:

    No-cache copy disabled:
    79571 tps, 34.34 %utlization
    50/90/95% latency 1584.46 2319.59 5001.76

    No-cache copy enabled:
    83856 tps, 34.81% utilization
    50/90/95% latency 2508.42 2622.62 2735.88

    Note especially the effect on latency tail (95th percentile).

    This seems to provide a nice performance improvement and is
    consistent in the tests I ran. Presumably, this would provide
    the greatest benfits in the presence of an application workload
    stressing the cache and a lot of transmit data happening.

    Signed-off-by: Tom Herbert
    Signed-off-by: David S. Miller

    Tom Herbert
     

10 Mar, 2011

1 commit

  • In contrast to SIOCOUTQ which returns the amount of data sent
    but not yet acknowledged plus data not yet sent this patch only
    returns the data not sent.

    For various methods of live streaming bitrate control it may
    be helpful to know how much data are in the tcp outqueue are
    not sent yet.

    Signed-off-by: Mario Schuknecht
    Signed-off-by: Steffen Sledz
    Signed-off-by: David S. Miller

    Mario Schuknecht
     

21 Feb, 2011

1 commit


25 Jan, 2011

1 commit

  • Quoting Ben Hutchings: we presumably won't be defining features that
    can only be enabled on 64-bit architectures.

    Occurences found by `grep -r` on net/, drivers/net, include/

    [ Move features and vlan_features next to each other in
    struct netdev, as per Eric Dumazet's suggestion -DaveM ]

    Signed-off-by: Michał Mirosław
    Signed-off-by: David S. Miller

    Michał Mirosław
     

09 Dec, 2010

1 commit


25 Nov, 2010

1 commit


15 Nov, 2010

1 commit


11 Nov, 2010

2 commits

  • As noted by Steve Chen, since commit
    f5fff5dc8a7a3f395b0525c02ba92c95d42b7390 ("tcp: advertise MSS
    requested by user") we can end up with a situation where
    tcp_select_initial_window() does a divide by a zero (or
    even negative) mss value.

    The problem is that sometimes we effectively subtract
    TCPOLEN_TSTAMP_ALIGNED and/or TCPOLEN_MD5SIG_ALIGNED from the mss.

    Fix this by increasing the minimum from 8 to 64.

    Reported-by: Steve Chen
    Signed-off-by: David S. Miller

    David S. Miller
     
  • Robin Holt tried to boot a 16TB machine and found some limits were
    reached : sysctl_tcp_mem[2], sysctl_udp_mem[2]

    We can switch infrastructure to use long "instead" of "int", now
    atomic_long_t primitives are available for free.

    Signed-off-by: Eric Dumazet
    Reported-by: Robin Holt
    Reviewed-by: Robin Holt
    Signed-off-by: Andrew Morton
    Signed-off-by: David S. Miller

    Eric Dumazet
     

10 Nov, 2010

1 commit


05 Oct, 2010

1 commit


28 Sep, 2010

1 commit

  • Fixes kernel bugzilla #16603

    tcp_sendmsg() truncates iov_len to an 'int' which a 4GB write to write
    zero bytes, for example.

    There is also the problem higher up of how verify_iovec() works. It
    wants to prevent the total length from looking like an error return
    value.

    However it does this using 'int', but syscalls return 'long' (and
    thus signed 64-bit on 64-bit machines). So it could trigger
    false-positives on 64-bit as written. So fix it to use 'long'.

    Reported-by: Olaf Bonorden
    Reported-by: Daniel Büse
    Reported-by: Andrew Morton
    Signed-off-by: David S. Miller

    David S. Miller
     

27 Sep, 2010

1 commit


21 Sep, 2010

1 commit

  • If a RST comes in immediately after checking sk->sk_err, tcp_poll will
    return POLLIN but not POLLOUT. Fix this by checking sk->sk_err at the end
    of tcp_poll. Additionally, ensure the correct order of operations on SMP
    machines with memory barriers.

    Signed-off-by: Tom Marshall
    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Tom Marshall
     

10 Sep, 2010

1 commit


31 Aug, 2010

1 commit

  • This patch provides a "user timeout" support as described in RFC793. The
    socket option is also needed for the the local half of RFC5482 "TCP User
    Timeout Option".

    TCP_USER_TIMEOUT is a TCP level socket option that takes an unsigned int,
    when > 0, to specify the maximum amount of time in ms that transmitted
    data may remain unacknowledged before TCP will forcefully close the
    corresponding connection and return ETIMEDOUT to the application. If
    0 is given, TCP will continue to use the system default.

    Increasing the user timeouts allows a TCP connection to survive extended
    periods without end-to-end connectivity. Decreasing the user timeouts
    allows applications to "fail fast" if so desired. Otherwise it may take
    upto 20 minutes with the current system defaults in a normal WAN
    environment.

    The socket option can be made during any state of a TCP connection, but
    is only effective during the synchronized states of a connection
    (ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, or LAST-ACK).
    Moreover, when used with the TCP keepalive (SO_KEEPALIVE) option,
    TCP_USER_TIMEOUT will overtake keepalive to determine when to close a
    connection due to keepalive failure.

    The option does not change in anyway when TCP retransmits a packet, nor
    when a keepalive probe will be sent.

    This option, like many others, will be inherited by an acceptor from its
    listener.

    Signed-off-by: H.K. Jerry Chu
    Signed-off-by: David S. Miller

    Jerry Chu
     

26 Aug, 2010

2 commits

  • This issue come from ruby language community. Below test program
    hang up when only run on Linux.

    % uname -mrsv
    Linux 2.6.26-2-486 #1 Sat Dec 26 08:37:39 UTC 2009 i686
    % ruby -rsocket -ve '
    BasicSocket.do_not_reverse_lookup = true
    serv = TCPServer.open("127.0.0.1", 0)
    s1 = TCPSocket.open("127.0.0.1", serv.addr[1])
    s2 = serv.accept
    s2.close
    s1.write("a") rescue p $!
    s1.write("a") rescue p $!
    Thread.new {
    s1.write("a")
    }.join'
    ruby 1.9.3dev (2010-07-06 trunk 28554) [i686-linux]
    #
    [Hang Here]

    FreeBSD, Solaris, Mac doesn't. because Ruby's write() method call
    select() internally. and tcp_poll has a bug.

    SUS defined 'ready for writing' of select() as following.

    | A descriptor shall be considered ready for writing when a call to an output
    | function with O_NONBLOCK clear would not block, whether or not the function
    | would transfer data successfully.

    That said, EPIPE situation is clearly one of 'ready for writing'.

    We don't have read-side issue because tcp_poll() already has read side
    shutdown care.

    | if (sk->sk_shutdown & RCV_SHUTDOWN)
    | mask |= POLLIN | POLLRDNORM | POLLRDHUP;

    So, Let's insert same logic in write side.

    - reference url
    http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/31065
    http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/31068

    Signed-off-by: KOSAKI Motohiro
    Signed-off-by: David S. Miller

    KOSAKI Motohiro
     
  • As discovered by Anton Blanchard, current code to autotune
    tcp_death_row.sysctl_max_tw_buckets, sysctl_tcp_max_orphans and
    sysctl_max_syn_backlog makes little sense.

    The bigger a page is, the less tcp_max_orphans is : 4096 on a 512GB
    machine in Anton's case.

    (tcp_hashinfo.bhash_size * sizeof(struct inet_bind_hashbucket))
    is much bigger if spinlock debugging is on. Its wrong to select bigger
    limits in this case (where kernel structures are also bigger)

    bhash_size max is 65536, and we get this value even for small machines.

    A better ground is to use size of ehash table, this also makes code
    shorter and more obvious.

    Based on a patch from Anton, and another from David.

    Reported-and-tested-by: Anton Blanchard
    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

25 Aug, 2010

1 commit

  • As reported by Anton Blanchard when we use
    percpu_counter_read_positive() to make our orphan socket limit checks,
    the check can be off by up to num_cpus_online() * batch (which is 32
    by default) which on a 128 cpu machine can be as large as the default
    orphan limit itself.

    Fix this by doing the full expensive sum check if the optimized check
    triggers.

    Reported-by: Anton Blanchard
    Signed-off-by: David S. Miller
    Acked-by: Eric Dumazet

    David S. Miller
     

03 Aug, 2010

2 commits


31 Jul, 2010

1 commit

  • There is a bug in do_tcp_setsockopt(net/ipv4/tcp.c),
    TCP_COOKIE_TRANSACTIONS case.
    In some cases (when tp->cookie_values == NULL) new tcp_cookie_values
    structure can be allocated (at cvp), but not bound to
    tp->cookie_values. So a memory leak occurs.

    Signed-off-by: Dmitry Popov
    Signed-off-by: David S. Miller

    Dmitry Popov
     

21 Jul, 2010

1 commit


15 Jul, 2010

1 commit


13 Jul, 2010

1 commit

  • a new boolean flag no_autobind is added to structure proto to avoid the autobind
    calls when the protocol is TCP. Then sock_rps_record_flow() is called int the
    TCP's sendmsg() and sendpage() pathes.

    Signed-off-by: Changli Gao
    ----
    include/net/inet_common.h | 4 ++++
    include/net/sock.h | 1 +
    include/net/tcp.h | 8 ++++----
    net/ipv4/af_inet.c | 15 +++++++++------
    net/ipv4/tcp.c | 11 +++++------
    net/ipv4/tcp_ipv4.c | 3 +++
    net/ipv6/af_inet6.c | 8 ++++----
    net/ipv6/tcp_ipv6.c | 3 +++
    8 files changed, 33 insertions(+), 20 deletions(-)
    Signed-off-by: David S. Miller

    Changli Gao