• Eric Dumazet's avatar
    tcp: avoid extra wakeups for SO_RCVLOWAT users · 03f45c88
    Eric Dumazet authored
    SO_RCVLOWAT is properly handled in tcp_poll(), so that POLLIN is only
    generated when enough bytes are available in receive queue, after
    David change (commit c7004482
     "tcp: Respect SO_RCVLOWAT in tcp_poll().")
    But TCP still calls sk->sk_data_ready() for each chunk added in receive
    queue, meaning thread is awaken, and goes back to sleep shortly after.
    tcp_mmap test program, receiving 32768 MB of data with SO_RCVLOWAT set to 512KB
    -> Should get ~2 wakeups (c-switches) per MB, regardless of how many
    (tiny or big) packets were received.
    High speed (mostly full size GRO packets)
    received 32768 MB (100 % mmap'ed) in 8.03112 s, 34.2266 Gbit,
      cpu usage user:0.037 sys:1.404, 43.9758 usec per MB, 65497 c-switches
    received 32768 MB (99.9954 % mmap'ed) in 7.98453 s, 34.4263 Gbit,
      cpu usage user:0.03 sys:1.422, 44.3115 usec per MB, 65485 c-switches
    Low speed (sender is ratelimited and sends 1-MSS at a time, so GRO is not helping)
    received 22474.5 MB (100 % mmap'ed) in 6015.35 s, 0.0313414 Gbit,
      cpu usage user:0.05 sys:1.586, 72.7952 usec per MB, 44950 c-switches
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
tcp.h 62.4 KB