diff options
author | Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> | 2010-03-10 18:22:13 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-12 18:52:36 -0500 |
commit | 7dc74be032bfcaa2f9d9e4296ff5bbddfa9e2f19 (patch) | |
tree | 8bd10dcca3cfb3f4f6a0e6222c7f2048995a7d5f /Documentation/cgroups/memory.txt | |
parent | b70cc5fdb445a6929a01e9c406593265b136c99d (diff) |
memcg: add interface to move charge at task migration
In current memcg, charges associated with a task aren't moved to the new
cgroup at task migration. Some users feel this behavior to be strange.
These patches are for this feature, that is, for charging to the new
cgroup and, of course, uncharging from the old cgroup at task migration.
This patch adds "memory.move_charge_at_immigrate" file, which is a flag
file to determine whether charges should be moved to the new cgroup at
task migration or not and what type of charges should be moved. This
patch also adds read and write handlers of the file.
This patch also adds no-op handlers for this feature. These handlers will
be implemented in later patches. And you cannot write any values other
than 0 to move_charge_at_immigrate yet.
Signed-off-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Paul Menage <menage@google.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation/cgroups/memory.txt')
-rw-r--r-- | Documentation/cgroups/memory.txt | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt index b871f2552b45..e726fb0df719 100644 --- a/Documentation/cgroups/memory.txt +++ b/Documentation/cgroups/memory.txt | |||
@@ -262,10 +262,12 @@ some of the pages cached in the cgroup (page cache pages). | |||
262 | 4.2 Task migration | 262 | 4.2 Task migration |
263 | 263 | ||
264 | When a task migrates from one cgroup to another, it's charge is not | 264 | When a task migrates from one cgroup to another, it's charge is not |
265 | carried forward. The pages allocated from the original cgroup still | 265 | carried forward by default. The pages allocated from the original cgroup still |
266 | remain charged to it, the charge is dropped when the page is freed or | 266 | remain charged to it, the charge is dropped when the page is freed or |
267 | reclaimed. | 267 | reclaimed. |
268 | 268 | ||
269 | Note: You can move charges of a task along with task migration. See 8. | ||
270 | |||
269 | 4.3 Removing a cgroup | 271 | 4.3 Removing a cgroup |
270 | 272 | ||
271 | A cgroup can be removed by rmdir, but as discussed in sections 4.1 and 4.2, a | 273 | A cgroup can be removed by rmdir, but as discussed in sections 4.1 and 4.2, a |
@@ -414,7 +416,57 @@ NOTE1: Soft limits take effect over a long period of time, since they involve | |||
414 | NOTE2: It is recommended to set the soft limit always below the hard limit, | 416 | NOTE2: It is recommended to set the soft limit always below the hard limit, |
415 | otherwise the hard limit will take precedence. | 417 | otherwise the hard limit will take precedence. |
416 | 418 | ||
417 | 8. TODO | 419 | 8. Move charges at task migration |
420 | |||
421 | Users can move charges associated with a task along with task migration, that | ||
422 | is, uncharge task's pages from the old cgroup and charge them to the new cgroup. | ||
423 | |||
424 | 8.1 Interface | ||
425 | |||
426 | This feature is disabled by default. It can be enabled(and disabled again) by | ||
427 | writing to memory.move_charge_at_immigrate of the destination cgroup. | ||
428 | |||
429 | If you want to enable it: | ||
430 | |||
431 | # echo (some positive value) > memory.move_charge_at_immigrate | ||
432 | |||
433 | Note: Each bits of move_charge_at_immigrate has its own meaning about what type | ||
434 | of charges should be moved. See 8.2 for details. | ||
435 | Note: Charges are moved only when you move mm->owner, IOW, a leader of a thread | ||
436 | group. | ||
437 | Note: If we cannot find enough space for the task in the destination cgroup, we | ||
438 | try to make space by reclaiming memory. Task migration may fail if we | ||
439 | cannot make enough space. | ||
440 | Note: It can take several seconds if you move charges in giga bytes order. | ||
441 | |||
442 | And if you want disable it again: | ||
443 | |||
444 | # echo 0 > memory.move_charge_at_immigrate | ||
445 | |||
446 | 8.2 Type of charges which can be move | ||
447 | |||
448 | Each bits of move_charge_at_immigrate has its own meaning about what type of | ||
449 | charges should be moved. | ||
450 | |||
451 | bit | what type of charges would be moved ? | ||
452 | -----+------------------------------------------------------------------------ | ||
453 | 0 | A charge of an anonymous page(or swap of it) used by the target task. | ||
454 | | Those pages and swaps must be used only by the target task. You must | ||
455 | | enable Swap Extension(see 2.4) to enable move of swap charges. | ||
456 | |||
457 | Note: Those pages and swaps must be charged to the old cgroup. | ||
458 | Note: More type of pages(e.g. file cache, shmem,) will be supported by other | ||
459 | bits in future. | ||
460 | |||
461 | 8.3 TODO | ||
462 | |||
463 | - Add support for other types of pages(e.g. file cache, shmem, etc.). | ||
464 | - Implement madvise(2) to let users decide the vma to be moved or not to be | ||
465 | moved. | ||
466 | - All of moving charge operations are done under cgroup_mutex. It's not good | ||
467 | behavior to hold the mutex too long, so we may need some trick. | ||
468 | |||
469 | 9. TODO | ||
418 | 470 | ||
419 | 1. Add support for accounting huge pages (as a separate controller) | 471 | 1. Add support for accounting huge pages (as a separate controller) |
420 | 2. Make per-cgroup scanner reclaim not-shared pages first | 472 | 2. Make per-cgroup scanner reclaim not-shared pages first |