1. 15 Jun, 2022 11 commits
  2. 14 Jun, 2022 3 commits
  3. 13 Jun, 2022 20 commits
  4. 11 Jun, 2022 3 commits
  5. 10 Jun, 2022 3 commits
    • Jakub Kicinski's avatar
      Merge branch 'net-reduce-tcp_memory_allocated-inflation' · e10b02ee
      Jakub Kicinski authored
      Eric Dumazet says:
      
      ====================
      net: reduce tcp_memory_allocated inflation
      
      Hosts with a lot of sockets tend to hit so called TCP memory pressure,
      leading to very bad TCP performance and/or OOM.
      
      The problem is that some TCP sockets can hold up to 2MB of 'forward
      allocations' in their per-socket cache (sk->sk_forward_alloc),
      and there is no mechanism to make them relinquish their share
      under mem pressure.
      Only under some potentially rare events their share is reclaimed,
      one socket at a time.
      
      In this series, I implemented a per-cpu cache instead of a per-socket one.
      
      Each CPU has a +1/-1 MB (256 pages on x86) forward alloc cache, in order
      to not dirty tcp_memory_allocated shared cache line too often.
      
      We keep sk->sk_forward_alloc values as small as possible, to meet
      memcg page granularity constraint.
      
      Note that memcg already has a per-cpu cache, although MEMCG_CHARGE_BATCH
      is defined to 32 pages, which seems a bit small.
      
      Note that while this cover letter mentions TCP, this work is generic
      and supports TCP, UDP, DECNET, SCTP.
      ====================
      
      Link: https://lore.kernel.org/r/20220609063412.2205738-1-eric.dumazet@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      e10b02ee
    • Eric Dumazet's avatar
      net: unexport __sk_mem_{raise|reduce}_allocated · 0f2c2693
      Eric Dumazet authored
      These two helpers are only used from core networking.
      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>
      0f2c2693
    • 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