• Eric Dumazet's avatar
    net: keep sk->sk_forward_alloc as small as possible · 4890b686
    Eric Dumazet authored
    Currently, tcp_memory_allocated can hit tcp_mem[] limits quite fast.
    
    Each TCP socket can forward allocate up to 2 MB of memory, even after
    flow became less active.
    
    10,000 sockets can have reserved 20 GB of memory,
    and we have no shrinker in place to reclaim that.
    
    Instead of trying to reclaim the extra allocations in some places,
    just keep sk->sk_forward_alloc values as small as possible.
    
    This should not impact performance too much now we have per-cpu
    reserves: Changes to tcp_memory_allocated should not be too frequent.
    
    For sockets not using SO_RESERVE_MEM:
     - idle sockets (no packets in tx/rx queues) have zero forward alloc.
     - non idle sockets have a forward alloc smaller than one page.
    
    Note:
    
     - Removal of SK_RECLAIM_CHUNK and SK_RECLAIM_THRESHOLD
       is left to MPTCP maintainers as a follow up.
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
    Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    4890b686
sm_statefuns.c 209 KB