memcg: document cgroup dirty memory interfaces

Document cgroup dirty memory interfaces and statistics.

[akpm@linux-foundation.org: fix use_hierarchy description]
Signed-off-by: Andrea Righi <arighi@develer.com>
Signed-off-by: Greg Thelen <gthelen@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Greg Thelen and committed by
Linus Torvalds
ece72400 db16d5ec

+74
+74
Documentation/cgroups/memory.txt
··· 385 385 pgpgin - # of pages paged in (equivalent to # of charging events). 386 386 pgpgout - # of pages paged out (equivalent to # of uncharging events). 387 387 swap - # of bytes of swap usage 388 + dirty - # of bytes that are waiting to get written back to the disk. 389 + writeback - # of bytes that are actively being written back to the disk. 390 + nfs_unstable - # of bytes sent to the NFS server, but not yet committed to 391 + the actual storage. 388 392 inactive_anon - # of bytes of anonymous memory and swap cache memory on 389 393 LRU list. 390 394 active_anon - # of bytes of anonymous and swap cache memory on active ··· 410 406 total_pgpgin - sum of all children's "pgpgin" 411 407 total_pgpgout - sum of all children's "pgpgout" 412 408 total_swap - sum of all children's "swap" 409 + total_dirty - sum of all children's "dirty" 410 + total_writeback - sum of all children's "writeback" 411 + total_nfs_unstable - sum of all children's "nfs_unstable" 413 412 total_inactive_anon - sum of all children's "inactive_anon" 414 413 total_active_anon - sum of all children's "active_anon" 415 414 total_inactive_file - sum of all children's "inactive_file" ··· 459 452 460 453 You can reset failcnt by writing 0 to failcnt file. 461 454 # echo 0 > .../memory.failcnt 455 + 456 + 5.5 dirty memory 457 + 458 + Control the maximum amount of dirty pages a cgroup can have at any given time. 459 + 460 + Limiting dirty memory is like fixing the max amount of dirty (hard to reclaim) 461 + page cache used by a cgroup. So, in case of multiple cgroup writers, they will 462 + not be able to consume more than their designated share of dirty pages and will 463 + be forced to perform write-out if they cross that limit. 464 + 465 + The interface is equivalent to the procfs interface: /proc/sys/vm/dirty_*. It 466 + is possible to configure a limit to trigger both a direct writeback or a 467 + background writeback performed by per-bdi flusher threads. The root cgroup 468 + memory.dirty_* control files are read-only and match the contents of 469 + the /proc/sys/vm/dirty_* files. 470 + 471 + Per-cgroup dirty limits can be set using the following files in the cgroupfs: 472 + 473 + - memory.dirty_ratio: the amount of dirty memory (expressed as a percentage of 474 + cgroup memory) at which a process generating dirty pages will itself start 475 + writing out dirty data. 476 + 477 + - memory.dirty_limit_in_bytes: the amount of dirty memory (expressed in bytes) 478 + in the cgroup at which a process generating dirty pages will start itself 479 + writing out dirty data. Suffix (k, K, m, M, g, or G) can be used to indicate 480 + that value is kilo, mega or gigabytes. 481 + 482 + Note: memory.dirty_limit_in_bytes is the counterpart of memory.dirty_ratio. 483 + Only one of them may be specified at a time. When one is written it is 484 + immediately taken into account to evaluate the dirty memory limits and the 485 + other appears as 0 when read. 486 + 487 + - memory.dirty_background_ratio: the amount of dirty memory of the cgroup 488 + (expressed as a percentage of cgroup memory) at which background writeback 489 + kernel threads will start writing out dirty data. 490 + 491 + - memory.dirty_background_limit_in_bytes: the amount of dirty memory (expressed 492 + in bytes) in the cgroup at which background writeback kernel threads will 493 + start writing out dirty data. Suffix (k, K, m, M, g, or G) can be used to 494 + indicate that value is kilo, mega or gigabytes. 495 + 496 + Note: memory.dirty_background_limit_in_bytes is the counterpart of 497 + memory.dirty_background_ratio. Only one of them may be specified at a time. 498 + When one is written it is immediately taken into account to evaluate the dirty 499 + memory limits and the other appears as 0 when read. 500 + 501 + A cgroup may contain more dirty memory than its dirty limit. This is possible 502 + because of the principle that the first cgroup to touch a page is charged for 503 + it. Subsequent page counting events (dirty, writeback, nfs_unstable) are also 504 + counted to the originally charged cgroup. 505 + 506 + Example: If page is allocated by a cgroup A task, then the page is charged to 507 + cgroup A. If the page is later dirtied by a task in cgroup B, then the cgroup A 508 + dirty count will be incremented. If cgroup A is over its dirty limit but cgroup 509 + B is not, then dirtying a cgroup A page from a cgroup B task may push cgroup A 510 + over its dirty limit without throttling the dirtying cgroup B task. 511 + 512 + When use_hierarchy=0, each cgroup has dirty memory usage and limits. 513 + System-wide dirty limits are also consulted. Dirty memory consumption is 514 + checked against both system-wide and per-cgroup dirty limits. 515 + 516 + The current implementation does not enforce per-cgroup dirty limits when 517 + use_hierarchy=1. System-wide dirty limits are used for processes in such 518 + cgroups. Attempts to read memory.dirty_* files return the system-wide 519 + values. Writes to the memory.dirty_* files return error. An enhanced 520 + implementation is needed to check the chain of parents to ensure that no 521 + dirty limit is exceeded. 462 522 463 523 6. Hierarchy support 464 524