History

net: add new socket option SO_RESERVE_MEM

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.

Wei Wang committed 5 years ago

Commit 2bb2f5f1 parent 4075a6a5 files · +112 −7Browse files

Showing the changes to include/uapi (1 of 5 files). Show all

Unified · Split

include/uapi/asm-generic/socket.h+2−0
@@ -126,6 +126,8 @@ · 125 unmodified lines
126 126
127#define SO_BUF_LOCK 72127#define SO_BUF_LOCK 72
128 128
129#define SO_RESERVE_MEM 73
130
129#if !defined(__KERNEL__)131#if !defined(__KERNEL__)
130 132
131#if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__))133#if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t