Skip to content

Commit

Permalink
memcg: implement memory thresholds
Browse files Browse the repository at this point in the history
It allows to register multiple memory and memsw thresholds and gets
notifications when it crosses.

To register a threshold application need:
- create an eventfd;
- open memory.usage_in_bytes or memory.memsw.usage_in_bytes;
- write string like "<event_fd> <memory.usage_in_bytes> <threshold>" to
  cgroup.event_control.

Application will be notified through eventfd when memory usage crosses
threshold in any direction.

It's applicable for root and non-root cgroup.

It uses stats to track memory usage, simmilar to soft limits. It checks
if we need to send event to userspace on every 100 page in/out. I guess
it's good compromise between performance and accuracy of thresholds.

[[email protected]: coding-style fixes]
[[email protected]: fix documentation merge issue]
Signed-off-by: Kirill A. Shutemov <[email protected]>
Cc: Li Zefan <[email protected]>
Cc: KAMEZAWA Hiroyuki <[email protected]>
Cc: Balbir Singh <[email protected]>
Cc: Pavel Emelyanov <[email protected]>
Cc: Dan Malek <[email protected]>
Cc: Vladislav Buzov <[email protected]>
Cc: Daisuke Nishimura <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
kiryl authored and torvalds committed Mar 12, 2010
1 parent 378ce72 commit 2e72b63
Show file tree
Hide file tree
Showing 2 changed files with 327 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Documentation/cgroups/memory.txt
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,24 @@ Note: More type of pages(e.g. file cache, shmem,) will be supported by other
- All of moving charge operations are done under cgroup_mutex. It's not good
behavior to hold the mutex too long, so we may need some trick.

9. TODO
9. Memory thresholds

Memory controler implements memory thresholds using cgroups notification
API (see cgroups.txt). It allows to register multiple memory and memsw
thresholds and gets notifications when it crosses.

To register a threshold application need:
- create an eventfd using eventfd(2);
- open memory.usage_in_bytes or memory.memsw.usage_in_bytes;
- write string like "<event_fd> <memory.usage_in_bytes> <threshold>" to
cgroup.event_control.

Application will be notified through eventfd when memory usage crosses
threshold in any direction.

It's applicable for root and non-root cgroup.

10. TODO

1. Add support for accounting huge pages (as a separate controller)
2. Make per-cgroup scanner reclaim not-shared pages first
Expand Down
Loading

0 comments on commit 2e72b63

Please sign in to comment.