• Arjun Roy's avatar
    net-zerocopy: Introduce short-circuit small reads. · f21a3c48
    Arjun Roy authored
    Sometimes, we may call tcp receive zerocopy when inq is 0,
    or inq < PAGE_SIZE, or inq is generally small enough that
    it is cheaper to copy rather than remap pages.
    
    In these cases, we may want to either return early (inq=0) or
    attempt to use the provided copy buffer to simply copy
    the received data.
    
    This allows us to save both system call overhead and
    the latency of acquiring mmap_sem in read mode for cases where
    it would be useless to do so.
    
    This patchset enables this behaviour by:
    1. Returning quickly if inq is 0.
    2. Attempting to perform a regular copy if a hybrid copybuffer is
       provided and it is large enough to absorb all available bytes.
    3. Return quickly if no such buffer was provided and there are less
       than PAGE_SIZE bytes available.
    
    For small RPC ping-pong workloads, normally we would have
    1 getsockopt(), 1 recvmsg() and 1 sendmsg() call per RPC. With this
    change, we remove the recvmsg() call entirely, reducing the syscall
    overhead by about 33%. In testing with small (hundreds of bytes)
    RPC traffic, this yields a syscall reduction of about 33% and
    an efficiency gain of about 3-5% when defined as QPS/CPU Util.
    Signed-off-by: default avatarArjun Roy <arjunroy@google.com>
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    f21a3c48
tcp.c 113 KB