• Wei Wang's avatar
    net: add new socket option SO_RESERVE_MEM · 2bb2f5fb
    Wei Wang authored
    This socket option provides a mechanism for users to reserve a certain
    amount of memory for the socket to use. When this option is set, kernel
    charges the user specified amount of memory to memcg, as well as
    sk_forward_alloc. This amount of memory is not reclaimable and is
    available in sk_forward_alloc for this socket.
    With this socket option set, the networking stack spends less cycles
    doing forward alloc and reclaim, which should lead to better system
    performance, with the cost of an amount of pre-allocated and
    unreclaimable memory, even under memory pressure.
    
    Note:
    This socket option is only available when memory cgroup is enabled and we
    require this reserved memory to be charged to the user's memcg. We hope
    this could avoid mis-behaving users to abused this feature to reserve a
    large amount on certain sockets and cause unfairness for others.
    Signed-off-by: default avatarWei Wang <weiwan@google.com>
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    2bb2f5fb
sock.c 93.4 KB