From 9490ff275606da012d5b373342a49610ad61cb81 Mon Sep 17 00:00:00 2001 From: KAMEZAWA Hiroyuki Date: Wed, 26 May 2010 14:42:36 -0700 Subject: memcg: oom notifier Considering containers or other resource management softwares in userland, event notification of OOM in memcg should be implemented. Now, memcg has "threshold" notifier which uses eventfd, we can make use of it for oom notification. This patch adds oom notification eventfd callback for memcg. The usage is very similar to threshold notifier, but control file is memory.oom_control and no arguments other than eventfd is required. % cgroup_event_notifier /cgroup/A/memory.oom_control dummy (About cgroup_event_notifier, see Documentation/cgroup/) Signed-off-by: KAMEZAWA Hiroyuki Cc: Daisuke Nishimura Cc: Balbir Singh Cc: Daisuke Nishimura Cc: David Rientjes Cc: Davide Libenzi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/cgroups/memory.txt | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'Documentation/cgroups/memory.txt') diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt index 6cab1f2..eac22d3 100644 --- a/Documentation/cgroups/memory.txt +++ b/Documentation/cgroups/memory.txt @@ -184,6 +184,9 @@ limits on the root cgroup. Note2: When panic_on_oom is set to "2", the whole system will panic. +When oom event notifier is registered, event will be delivered. +(See oom_control section) + 2. Locking The memory controller uses the following hierarchy @@ -488,7 +491,22 @@ threshold in any direction. It's applicable for root and non-root cgroup. -10. TODO +10. OOM Control + +Memory controler implements oom notifier using cgroup notification +API (See cgroups.txt). It allows to register multiple oom notification +delivery and gets notification when oom happens. + +To register a notifier, application need: + - create an eventfd using eventfd(2) + - open memory.oom_control file + - write string like " " to cgroup.event_control + +Application will be notifier through eventfd when oom happens. +OOM notification doesn't work for root cgroup. + + +11. TODO 1. Add support for accounting huge pages (as a separate controller) 2. Make per-cgroup scanner reclaim not-shared pages first -- cgit v1.1