nommu: add anonymous page memcg accounting
Subsystems (3)
PATCH v3 1/1 nommu: add anonymous page memcg accounting
Add the necessary calls to track VM anonymous page usage (only).
V3 changes:
* Use vma->vm_mm instead of current->mm when charging pages, for clarity
* Document that reclaim is not possible with only anonymous page accounting so the OOM-killer is invoked when a limit is exceeded
* Add TODO to implement file cache (reclaim) support or optimize away page_cgroup->lru
V2 changes:
* Added update of memory cgroup documentation
* Clarify use of 'file' to distinguish anonymous mappings
---
Documentation/cgroups/memory.txt +30 -1
@@ -34,6 +34,7 @@ Current Status: linux-2.6.34-mmotm(devel Features: - accounting anonymous pages, file caches, swap caches usage and limiting them. + NOTE: On NOMMU systems, only anonymous pages are accounted. - private LRU and reclaim routine. (system's global LRU and private LRU work independently from each other) - optionally, memory+swap usage can be accounted and limited.
@@ -640,13 +641,41 @@ At reading, current status of OOM is sho under_oom 0 or 1 (if 1, the memory cgroup is under OOM, tasks may be stopped.) -11. TODO +11. NOMMU Support + +Systems without a Memory Management Unit do not support virtual memory, +swapping, page faults, or migration, and are therefore limited to operating +entirely within the system's RAM. On such systems, maintaining an ability to +allocate sufficiently large blocks of contiguous memory is usually a challenge. +This makes the overhead involved in memory cgroup support more of a concern, +particularly when the memory page size is small. + +Typically, embedded systems are comparatively simple and deterministic, and are +required to remain stable over long periods. Invocation of the OOM-killer, were +it to occur in an uncontrolled manner, would likely destabilize such systems. + +Even a well-designed system may be presented with external stimuli that could +lead to OOM conditions. One example is a system that is required to check a +user-supplied removable FAT filesystem. As there is no way to bound the size +or coherence of the user's filesystem, the memory required to run dosfsck on +it may exceed the system's capacity. Running dosfsck in a memory cgroup +can preserve system stability even in the face of excessive memory demands. + +At the present time, only anonymous pages are included in NOMMU memory cgroup +accounting. As anonymous pages are not reclaimable, when a memory cgroup +exceeds its limit, reclaim will fail and the OOM-killer will be invoked. +See the Reclaim section of this document. + +12. TODO 1. Add support for accounting huge pages (as a separate controller) 2. Make per-cgroup scanner reclaim not-shared pages first 3. Teach controller to account for shared-pages 4. Start reclamation in the background when the limit is not yet hit but the usage is getting closer +5. NOMMU: implement file cache accounting (which would support reclaim) + or optimize away page_cgroup->lru, which is just per-page overhead when + reclaim is not supported. Summary
mm/nommu.c +33 -8
95 lines not on this page · raw message
Quoted 9 lines · On Thu, 21 Oct 2010 07:28:08 -0500 "Steven J. Magnani" <[email protected]>…
Add the necessary calls to track VM anonymous page usage (only).
V3 changes:
* Usevma->vm_mminstead ofcurrent->mmwhen charging pages, for clarity
* Document that reclaim is not possible with only anonymous page accounting so the OOM-killer is invoked when a limit is exceeded
* Add TODO to implement file cache (reclaim) support or optimize awaypage_cgroup->lru
Quoted 5 lines
V2 changes:
* Added update of memory cgroup documentation
* Clarify use of 'file' to distinguish anonymous mappingsSigned-off-by Steven J. Magnani <[email protected]>
Thanks,
BTW, have you tried oom_notifier+NOMMU memory limit oom-killer ? It may be a chance to implement a custom OOM-Killer in userland on EMBEDED systems.
Thanks,
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 3 lines · KAMEZAWA Hiroyuki
BTW, have you tried oom_notifier+NOMMU memory limit oom-killer ? It may be a chance to implement a custom OOM-Killer in userland on EMBEDED systems.
No - for what I need (simple sandboxing) just running my 'problem' process in a memory cgroup is sufficient. I might even be able to get away with oom_kill_allocating_task and no cgroup, but since that would allow dosfsck to run the system completely out of memory there's no guarantee that it would be the one that pushes the system over the edge.
What do you mean by "NOMMU memory limit"? (Is there some other way to achieve the same functionality?)
I looked into David's initial suggestion of using ulimit to create a sandbox but it seems that nommu.c doesn't respect RLIMIT_AS. When I can find some time I'll try to cook up a patch for that.
Also it seems that nommu.c doesn't ever decrement mm->total_vm, which if I'm reading the code correctly (before the 2.6.36 OOM-killer rewrite) could throw off badness calculations for processes that do lots of malloc/free operations. In 2.6.36 it doesn't look to me like this would have any ill effects.
Thanks for all the feedback. I fully agree that maintenance should be a strong consideration when merging new code.
Regards,
------------------------------------------------------------------------
Steven J. Magnani "I claim this network for MARS!
www.digidescorp.com Earthling, return my space modulator!"
#include <standard.disclaimer>
Quoted 5 lines · On Fri, 22 Oct 2010 08:26:08 -0500 "Steven J. Magnani" <[email protected]>…
Quoted 3 lines · KAMEZAWA Hiroyuki
BTW, have you tried oom_notifier+NOMMU memory limit oom-killer ? It may be a chance to implement a custom OOM-Killer in userland on EMBEDED systems.
Quoted 9 lines
No - for what I need (simple sandboxing) just running my 'problem' process in a memory cgroup is sufficient. I might even be able to get away with
oom_kill_allocating_taskand no cgroup, but since that would allow dosfsck to run the system completely out of memory there's no guarantee that it would be the one that pushes the system over the edge.What do you mean by "NOMMU memory limit"? (Is there some other way to achieve the same functionality?)
I just meant memory cgroup for NOMMU.
Quoted 3 lines
I looked into David's initial suggestion of using ulimit to create a sandbox but it seems that
nommu.cdoesn't respectRLIMIT_AS. When I can find some time I'll try to cook up a patch for that.
Hmm. I think fixing RLIMIT_AS is better. (but no nack to this patch.) Using memcg for _a_ program sounds like overkill...
Thanks,
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 9 lines · Steven J. Magnani
Add the necessary calls to track VM anonymous page usage (only).
V3 changes:
* Usevma->vm_mminstead ofcurrent->mmwhen charging pages, for clarity
* Document that reclaim is not possible with only anonymous page accounting so the OOM-killer is invoked when a limit is exceeded
* Add TODO to implement file cache (reclaim) support or optimize awaypage_cgroup->lru
Quoted 5 lines
V2 changes:
* Added update of memory cgroup documentation
* Clarify use of 'file' to distinguish anonymous mappingsSigned-off-by Steven J. Magnani <[email protected]>
BTW, I have no way of testing this, we need to rely on the NOMMU community to test this.
Signature · 2 lines
Three Cheers, Balbir
Quoted 15 lines · On Fri, 22 Oct 2010 09:23:03 +0530 Balbir Singh <[email protected]>…
Quoted 13 lines · Steven J. Magnani
Add the necessary calls to track VM anonymous page usage (only).
V3 changes:
* Usevma->vm_mminstead ofcurrent->mmwhen charging pages, for clarity
* Document that reclaim is not possible with only anonymous page accounting so the OOM-killer is invoked when a limit is exceeded
* Add TODO to implement file cache (reclaim) support or optimize awaypage_cgroup->lruV2 changes:
* Added update of memory cgroup documentation
* Clarify use of 'file' to distinguish anonymous mappings
Quoted 7 lines
Quoted 1 line
Signed-off-by Steven J. Magnani <[email protected]>Acked-by Balbir Singh <[email protected]>BTW, I have no way of testing this, we need to rely on the NOMMU community to test this.
Yes, that's the biggest problem.
-Kame
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>