Balbir Singh | 00f0b82 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 1 | Memory Resource Controller |
| 2 | |
| 3 | NOTE: The Memory Resource Controller has been generically been referred |
| 4 | to as the memory controller in this document. Do not confuse memory controller |
| 5 | used here with the memory controller that is used in hardware. |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 6 | |
| 7 | Salient features |
| 8 | |
Bharata B Rao | c863d83 | 2009-04-13 14:40:15 -0700 | [diff] [blame] | 9 | a. Enable control of Anonymous, Page Cache (mapped and unmapped) and |
| 10 | Swap Cache memory pages. |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 11 | b. The infrastructure allows easy addition of other types of memory to control |
| 12 | c. Provides *zero overhead* for non memory controller users |
| 13 | d. Provides a double LRU: global memory pressure causes reclaim from the |
| 14 | global LRU; a cgroup on hitting a limit, reclaims from the per |
| 15 | cgroup LRU |
| 16 | |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 17 | Benefits and Purpose of the memory controller |
| 18 | |
| 19 | The memory controller isolates the memory behaviour of a group of tasks |
| 20 | from the rest of the system. The article on LWN [12] mentions some probable |
| 21 | uses of the memory controller. The memory controller can be used to |
| 22 | |
| 23 | a. Isolate an application or a group of applications |
| 24 | Memory hungry applications can be isolated and limited to a smaller |
| 25 | amount of memory. |
| 26 | b. Create a cgroup with limited amount of memory, this can be used |
| 27 | as a good alternative to booting with mem=XXXX. |
| 28 | c. Virtualization solutions can control the amount of memory they want |
| 29 | to assign to a virtual machine instance. |
| 30 | d. A CD/DVD burner could control the amount of memory used by the |
| 31 | rest of the system to ensure that burning does not fail due to lack |
| 32 | of available memory. |
| 33 | e. There are several other use cases, find one or use the controller just |
| 34 | for fun (to learn and hack on the VM subsystem). |
| 35 | |
| 36 | 1. History |
| 37 | |
| 38 | The memory controller has a long history. A request for comments for the memory |
| 39 | controller was posted by Balbir Singh [1]. At the time the RFC was posted |
| 40 | there were several implementations for memory control. The goal of the |
| 41 | RFC was to build consensus and agreement for the minimal features required |
| 42 | for memory control. The first RSS controller was posted by Balbir Singh[2] |
| 43 | in Feb 2007. Pavel Emelianov [3][4][5] has since posted three versions of the |
| 44 | RSS controller. At OLS, at the resource management BoF, everyone suggested |
| 45 | that we handle both page cache and RSS together. Another request was raised |
| 46 | to allow user space handling of OOM. The current memory controller is |
| 47 | at version 6; it combines both mapped (RSS) and unmapped Page |
| 48 | Cache Control [11]. |
| 49 | |
| 50 | 2. Memory Control |
| 51 | |
| 52 | Memory is a unique resource in the sense that it is present in a limited |
| 53 | amount. If a task requires a lot of CPU processing, the task can spread |
| 54 | its processing over a period of hours, days, months or years, but with |
| 55 | memory, the same physical memory needs to be reused to accomplish the task. |
| 56 | |
| 57 | The memory controller implementation has been divided into phases. These |
| 58 | are: |
| 59 | |
| 60 | 1. Memory controller |
| 61 | 2. mlock(2) controller |
| 62 | 3. Kernel user memory accounting and slab control |
| 63 | 4. user mappings length controller |
| 64 | |
| 65 | The memory controller is the first controller developed. |
| 66 | |
| 67 | 2.1. Design |
| 68 | |
| 69 | The core of the design is a counter called the res_counter. The res_counter |
| 70 | tracks the current memory usage and limit of the group of processes associated |
| 71 | with the controller. Each cgroup has a memory controller specific data |
| 72 | structure (mem_cgroup) associated with it. |
| 73 | |
| 74 | 2.2. Accounting |
| 75 | |
| 76 | +--------------------+ |
| 77 | | mem_cgroup | |
| 78 | | (res_counter) | |
| 79 | +--------------------+ |
| 80 | / ^ \ |
| 81 | / | \ |
| 82 | +---------------+ | +---------------+ |
| 83 | | mm_struct | |.... | mm_struct | |
| 84 | | | | | | |
| 85 | +---------------+ | +---------------+ |
| 86 | | |
| 87 | + --------------+ |
| 88 | | |
| 89 | +---------------+ +------+--------+ |
| 90 | | page +----------> page_cgroup| |
| 91 | | | | | |
| 92 | +---------------+ +---------------+ |
| 93 | |
| 94 | (Figure 1: Hierarchy of Accounting) |
| 95 | |
| 96 | |
| 97 | Figure 1 shows the important aspects of the controller |
| 98 | |
| 99 | 1. Accounting happens per cgroup |
| 100 | 2. Each mm_struct knows about which cgroup it belongs to |
| 101 | 3. Each page has a pointer to the page_cgroup, which in turn knows the |
| 102 | cgroup it belongs to |
| 103 | |
| 104 | The accounting is done as follows: mem_cgroup_charge() is invoked to setup |
| 105 | the necessary data structures and check if the cgroup that is being charged |
| 106 | is over its limit. If it is then reclaim is invoked on the cgroup. |
| 107 | More details can be found in the reclaim section of this document. |
| 108 | If everything goes well, a page meta-data-structure called page_cgroup is |
| 109 | allocated and associated with the page. This routine also adds the page to |
| 110 | the per cgroup LRU. |
| 111 | |
| 112 | 2.2.1 Accounting details |
| 113 | |
KAMEZAWA Hiroyuki | 5b4e655 | 2008-10-18 20:28:10 -0700 | [diff] [blame] | 114 | All mapped anon pages (RSS) and cache pages (Page Cache) are accounted. |
| 115 | (some pages which never be reclaimable and will not be on global LRU |
| 116 | are not accounted. we just accounts pages under usual vm management.) |
| 117 | |
| 118 | RSS pages are accounted at page_fault unless they've already been accounted |
| 119 | for earlier. A file page will be accounted for as Page Cache when it's |
| 120 | inserted into inode (radix-tree). While it's mapped into the page tables of |
| 121 | processes, duplicate accounting is carefully avoided. |
| 122 | |
| 123 | A RSS page is unaccounted when it's fully unmapped. A PageCache page is |
| 124 | unaccounted when it's removed from radix-tree. |
| 125 | |
| 126 | At page migration, accounting information is kept. |
| 127 | |
| 128 | Note: we just account pages-on-lru because our purpose is to control amount |
| 129 | of used pages. not-on-lru pages are tend to be out-of-control from vm view. |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 130 | |
| 131 | 2.3 Shared Page Accounting |
| 132 | |
| 133 | Shared pages are accounted on the basis of the first touch approach. The |
| 134 | cgroup that first touches a page is accounted for the page. The principle |
| 135 | behind this approach is that a cgroup that aggressively uses a shared |
| 136 | page will eventually get charged for it (once it is uncharged from |
| 137 | the cgroup that brought it in -- this will happen on memory pressure). |
| 138 | |
KAMEZAWA Hiroyuki | 8c7c6e34 | 2009-01-07 18:08:00 -0800 | [diff] [blame] | 139 | Exception: If CONFIG_CGROUP_CGROUP_MEM_RES_CTLR_SWAP is not used.. |
| 140 | When you do swapoff and make swapped-out pages of shmem(tmpfs) to |
KAMEZAWA Hiroyuki | d13d144 | 2009-01-07 18:07:56 -0800 | [diff] [blame] | 141 | be backed into memory in force, charges for pages are accounted against the |
| 142 | caller of swapoff rather than the users of shmem. |
| 143 | |
| 144 | |
KAMEZAWA Hiroyuki | 8c7c6e34 | 2009-01-07 18:08:00 -0800 | [diff] [blame] | 145 | 2.4 Swap Extension (CONFIG_CGROUP_MEM_RES_CTLR_SWAP) |
| 146 | Swap Extension allows you to record charge for swap. A swapped-in page is |
| 147 | charged back to original page allocator if possible. |
| 148 | |
| 149 | When swap is accounted, following files are added. |
| 150 | - memory.memsw.usage_in_bytes. |
| 151 | - memory.memsw.limit_in_bytes. |
| 152 | |
| 153 | usage of mem+swap is limited by memsw.limit_in_bytes. |
| 154 | |
KAMEZAWA Hiroyuki | 22a668d | 2009-06-17 16:27:19 -0700 | [diff] [blame] | 155 | * why 'mem+swap' rather than swap. |
KAMEZAWA Hiroyuki | 8c7c6e34 | 2009-01-07 18:08:00 -0800 | [diff] [blame] | 156 | The global LRU(kswapd) can swap out arbitrary pages. Swap-out means |
| 157 | to move account from memory to swap...there is no change in usage of |
KAMEZAWA Hiroyuki | 22a668d | 2009-06-17 16:27:19 -0700 | [diff] [blame] | 158 | mem+swap. In other words, when we want to limit the usage of swap without |
| 159 | affecting global LRU, mem+swap limit is better than just limiting swap from |
| 160 | OS point of view. |
KAMEZAWA Hiroyuki | 8c7c6e34 | 2009-01-07 18:08:00 -0800 | [diff] [blame] | 161 | |
KAMEZAWA Hiroyuki | 22a668d | 2009-06-17 16:27:19 -0700 | [diff] [blame] | 162 | * What happens when a cgroup hits memory.memsw.limit_in_bytes |
| 163 | When a cgroup his memory.memsw.limit_in_bytes, it's useless to do swap-out |
| 164 | in this cgroup. Then, swap-out will not be done by cgroup routine and file |
| 165 | caches are dropped. But as mentioned above, global LRU can do swapout memory |
| 166 | from it for sanity of the system's memory management state. You can't forbid |
| 167 | it by cgroup. |
KAMEZAWA Hiroyuki | 8c7c6e34 | 2009-01-07 18:08:00 -0800 | [diff] [blame] | 168 | |
| 169 | 2.5 Reclaim |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 170 | |
| 171 | Each cgroup maintains a per cgroup LRU that consists of an active |
| 172 | and inactive list. When a cgroup goes over its limit, we first try |
| 173 | to reclaim memory from the cgroup so as to make space for the new |
| 174 | pages that the cgroup has touched. If the reclaim is unsuccessful, |
| 175 | an OOM routine is invoked to select and kill the bulkiest task in the |
| 176 | cgroup. |
| 177 | |
| 178 | The reclaim algorithm has not been modified for cgroups, except that |
| 179 | pages that are selected for reclaiming come from the per cgroup LRU |
| 180 | list. |
| 181 | |
Balbir Singh | 4b3bde4 | 2009-09-23 15:56:32 -0700 | [diff] [blame] | 182 | NOTE: Reclaim does not work for the root cgroup, since we cannot set any |
| 183 | limits on the root cgroup. |
| 184 | |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 185 | 2. Locking |
| 186 | |
| 187 | The memory controller uses the following hierarchy |
| 188 | |
| 189 | 1. zone->lru_lock is used for selecting pages to be isolated |
KAMEZAWA Hiroyuki | dfc05c2 | 2008-02-07 00:14:41 -0800 | [diff] [blame] | 190 | 2. mem->per_zone->lru_lock protects the per cgroup LRU (per zone) |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 191 | 3. lock_page_cgroup() is used to protect page->page_cgroup |
| 192 | |
| 193 | 3. User Interface |
| 194 | |
| 195 | 0. Configuration |
| 196 | |
| 197 | a. Enable CONFIG_CGROUPS |
| 198 | b. Enable CONFIG_RESOURCE_COUNTERS |
Balbir Singh | 00f0b82 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 199 | c. Enable CONFIG_CGROUP_MEM_RES_CTLR |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 200 | |
| 201 | 1. Prepare the cgroups |
| 202 | # mkdir -p /cgroups |
| 203 | # mount -t cgroup none /cgroups -o memory |
| 204 | |
| 205 | 2. Make the new group and move bash into it |
| 206 | # mkdir /cgroups/0 |
| 207 | # echo $$ > /cgroups/0/tasks |
| 208 | |
| 209 | Since now we're in the 0 cgroup, |
| 210 | We can alter the memory limit: |
Balbir Singh | fb78922 | 2008-03-04 14:28:24 -0800 | [diff] [blame] | 211 | # echo 4M > /cgroups/0/memory.limit_in_bytes |
Balbir Singh | 0eea103 | 2008-02-07 00:13:57 -0800 | [diff] [blame] | 212 | |
| 213 | NOTE: We can use a suffix (k, K, m, M, g or G) to indicate values in kilo, |
| 214 | mega or gigabytes. |
Daisuke Nishimura | c5b947b | 2009-06-17 16:27:20 -0700 | [diff] [blame] | 215 | NOTE: We can write "-1" to reset the *.limit_in_bytes(unlimited). |
Balbir Singh | 4b3bde4 | 2009-09-23 15:56:32 -0700 | [diff] [blame] | 216 | NOTE: We cannot set limits on the root cgroup any more. |
Balbir Singh | 0eea103 | 2008-02-07 00:13:57 -0800 | [diff] [blame] | 217 | |
| 218 | # cat /cgroups/0/memory.limit_in_bytes |
Li Zefan | 2324c5d | 2008-02-23 15:24:12 -0800 | [diff] [blame] | 219 | 4194304 |
Balbir Singh | 0eea103 | 2008-02-07 00:13:57 -0800 | [diff] [blame] | 220 | |
| 221 | NOTE: The interface has now changed to display the usage in bytes |
| 222 | instead of pages |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 223 | |
| 224 | We can check the usage: |
Balbir Singh | 0eea103 | 2008-02-07 00:13:57 -0800 | [diff] [blame] | 225 | # cat /cgroups/0/memory.usage_in_bytes |
Li Zefan | 2324c5d | 2008-02-23 15:24:12 -0800 | [diff] [blame] | 226 | 1216512 |
Balbir Singh | 0eea103 | 2008-02-07 00:13:57 -0800 | [diff] [blame] | 227 | |
| 228 | A successful write to this file does not guarantee a successful set of |
| 229 | this limit to the value written into the file. This can be due to a |
| 230 | number of factors, such as rounding up to page boundaries or the total |
| 231 | availability of memory on the system. The user is required to re-read |
| 232 | this file after a write to guarantee the value committed by the kernel. |
| 233 | |
Balbir Singh | fb78922 | 2008-03-04 14:28:24 -0800 | [diff] [blame] | 234 | # echo 1 > memory.limit_in_bytes |
Balbir Singh | 0eea103 | 2008-02-07 00:13:57 -0800 | [diff] [blame] | 235 | # cat memory.limit_in_bytes |
Li Zefan | 2324c5d | 2008-02-23 15:24:12 -0800 | [diff] [blame] | 236 | 4096 |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 237 | |
| 238 | The memory.failcnt field gives the number of times that the cgroup limit was |
| 239 | exceeded. |
| 240 | |
KAMEZAWA Hiroyuki | dfc05c2 | 2008-02-07 00:14:41 -0800 | [diff] [blame] | 241 | The memory.stat file gives accounting information. Now, the number of |
| 242 | caches, RSS and Active pages/Inactive pages are shown. |
| 243 | |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 244 | 4. Testing |
| 245 | |
| 246 | Balbir posted lmbench, AIM9, LTP and vmmstress results [10] and [11]. |
| 247 | Apart from that v6 has been tested with several applications and regular |
| 248 | daily use. The controller has also been tested on the PPC64, x86_64 and |
| 249 | UML platforms. |
| 250 | |
| 251 | 4.1 Troubleshooting |
| 252 | |
| 253 | Sometimes a user might find that the application under a cgroup is |
| 254 | terminated. There are several causes for this: |
| 255 | |
| 256 | 1. The cgroup limit is too low (just too low to do anything useful) |
| 257 | 2. The user is using anonymous memory and swap is turned off or too low |
| 258 | |
| 259 | A sync followed by echo 1 > /proc/sys/vm/drop_caches will help get rid of |
| 260 | some of the pages cached in the cgroup (page cache pages). |
| 261 | |
| 262 | 4.2 Task migration |
| 263 | |
| 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 |
| 266 | remain charged to it, the charge is dropped when the page is freed or |
| 267 | reclaimed. |
| 268 | |
| 269 | 4.3 Removing a cgroup |
| 270 | |
| 271 | A cgroup can be removed by rmdir, but as discussed in sections 4.1 and 4.2, a |
| 272 | cgroup might have some charge associated with it, even though all |
KAMEZAWA Hiroyuki | f817ed4 | 2009-01-07 18:07:53 -0800 | [diff] [blame] | 273 | tasks have migrated away from it. |
KAMEZAWA Hiroyuki | c1e862c | 2009-01-07 18:07:55 -0800 | [diff] [blame] | 274 | Such charges are freed(at default) or moved to its parent. When moved, |
| 275 | both of RSS and CACHES are moved to parent. |
| 276 | If both of them are busy, rmdir() returns -EBUSY. See 5.1 Also. |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 277 | |
KAMEZAWA Hiroyuki | 8c7c6e34 | 2009-01-07 18:08:00 -0800 | [diff] [blame] | 278 | Charges recorded in swap information is not updated at removal of cgroup. |
| 279 | Recorded information is discarded and a cgroup which uses swap (swapcache) |
| 280 | will be charged as a new owner of it. |
| 281 | |
| 282 | |
KAMEZAWA Hiroyuki | c1e862c | 2009-01-07 18:07:55 -0800 | [diff] [blame] | 283 | 5. Misc. interfaces. |
| 284 | |
| 285 | 5.1 force_empty |
| 286 | memory.force_empty interface is provided to make cgroup's memory usage empty. |
| 287 | You can use this interface only when the cgroup has no tasks. |
| 288 | When writing anything to this |
| 289 | |
| 290 | # echo 0 > memory.force_empty |
| 291 | |
| 292 | Almost all pages tracked by this memcg will be unmapped and freed. Some of |
| 293 | pages cannot be freed because it's locked or in-use. Such pages are moved |
| 294 | to parent and this cgroup will be empty. But this may return -EBUSY in |
| 295 | some too busy case. |
| 296 | |
| 297 | Typical use case of this interface is that calling this before rmdir(). |
| 298 | Because rmdir() moves all pages to parent, some out-of-use page caches can be |
| 299 | moved to the parent. If you want to avoid that, force_empty will be useful. |
| 300 | |
KOSAKI Motohiro | 7f016ee | 2009-01-07 18:08:22 -0800 | [diff] [blame] | 301 | 5.2 stat file |
KOSAKI Motohiro | 7f016ee | 2009-01-07 18:08:22 -0800 | [diff] [blame] | 302 | |
Bharata B Rao | c863d83 | 2009-04-13 14:40:15 -0700 | [diff] [blame] | 303 | memory.stat file includes following statistics |
KOSAKI Motohiro | 7f016ee | 2009-01-07 18:08:22 -0800 | [diff] [blame] | 304 | |
Bharata B Rao | c863d83 | 2009-04-13 14:40:15 -0700 | [diff] [blame] | 305 | cache - # of bytes of page cache memory. |
| 306 | rss - # of bytes of anonymous and swap cache memory. |
| 307 | pgpgin - # of pages paged in (equivalent to # of charging events). |
| 308 | pgpgout - # of pages paged out (equivalent to # of uncharging events). |
| 309 | active_anon - # of bytes of anonymous and swap cache memory on active |
| 310 | lru list. |
| 311 | inactive_anon - # of bytes of anonymous memory and swap cache memory on |
| 312 | inactive lru list. |
| 313 | active_file - # of bytes of file-backed memory on active lru list. |
| 314 | inactive_file - # of bytes of file-backed memory on inactive lru list. |
| 315 | unevictable - # of bytes of memory that cannot be reclaimed (mlocked etc). |
| 316 | |
| 317 | The following additional stats are dependent on CONFIG_DEBUG_VM. |
| 318 | |
| 319 | inactive_ratio - VM internal parameter. (see mm/page_alloc.c) |
| 320 | recent_rotated_anon - VM internal parameter. (see mm/vmscan.c) |
| 321 | recent_rotated_file - VM internal parameter. (see mm/vmscan.c) |
| 322 | recent_scanned_anon - VM internal parameter. (see mm/vmscan.c) |
| 323 | recent_scanned_file - VM internal parameter. (see mm/vmscan.c) |
| 324 | |
| 325 | Memo: |
KOSAKI Motohiro | 7f016ee | 2009-01-07 18:08:22 -0800 | [diff] [blame] | 326 | recent_rotated means recent frequency of lru rotation. |
| 327 | recent_scanned means recent # of scans to lru. |
| 328 | showing for better debug please see the code for meanings. |
| 329 | |
Bharata B Rao | c863d83 | 2009-04-13 14:40:15 -0700 | [diff] [blame] | 330 | Note: |
| 331 | Only anonymous and swap cache memory is listed as part of 'rss' stat. |
| 332 | This should not be confused with the true 'resident set size' or the |
| 333 | amount of physical memory used by the cgroup. Per-cgroup rss |
| 334 | accounting is not done yet. |
KOSAKI Motohiro | 7f016ee | 2009-01-07 18:08:22 -0800 | [diff] [blame] | 335 | |
KOSAKI Motohiro | a7885eb | 2009-01-07 18:08:24 -0800 | [diff] [blame] | 336 | 5.3 swappiness |
| 337 | Similar to /proc/sys/vm/swappiness, but affecting a hierarchy of groups only. |
| 338 | |
Bharata B Rao | c863d83 | 2009-04-13 14:40:15 -0700 | [diff] [blame] | 339 | Following cgroups' swapiness can't be changed. |
KOSAKI Motohiro | a7885eb | 2009-01-07 18:08:24 -0800 | [diff] [blame] | 340 | - root cgroup (uses /proc/sys/vm/swappiness). |
| 341 | - a cgroup which uses hierarchy and it has child cgroup. |
| 342 | - a cgroup which uses hierarchy and not the root of hierarchy. |
| 343 | |
| 344 | |
Balbir Singh | 52bc0d8 | 2009-01-07 18:08:03 -0800 | [diff] [blame] | 345 | 6. Hierarchy support |
KAMEZAWA Hiroyuki | c1e862c | 2009-01-07 18:07:55 -0800 | [diff] [blame] | 346 | |
Balbir Singh | 52bc0d8 | 2009-01-07 18:08:03 -0800 | [diff] [blame] | 347 | The memory controller supports a deep hierarchy and hierarchical accounting. |
| 348 | The hierarchy is created by creating the appropriate cgroups in the |
| 349 | cgroup filesystem. Consider for example, the following cgroup filesystem |
| 350 | hierarchy |
| 351 | |
| 352 | root |
| 353 | / | \ |
| 354 | / | \ |
| 355 | a b c |
| 356 | | \ |
| 357 | | \ |
| 358 | d e |
| 359 | |
| 360 | In the diagram above, with hierarchical accounting enabled, all memory |
| 361 | usage of e, is accounted to its ancestors up until the root (i.e, c and root), |
| 362 | that has memory.use_hierarchy enabled. If one of the ancestors goes over its |
| 363 | limit, the reclaim algorithm reclaims from the tasks in the ancestor and the |
| 364 | children of the ancestor. |
| 365 | |
| 366 | 6.1 Enabling hierarchical accounting and reclaim |
| 367 | |
| 368 | The memory controller by default disables the hierarchy feature. Support |
| 369 | can be enabled by writing 1 to memory.use_hierarchy file of the root cgroup |
| 370 | |
| 371 | # echo 1 > memory.use_hierarchy |
| 372 | |
| 373 | The feature can be disabled by |
| 374 | |
| 375 | # echo 0 > memory.use_hierarchy |
| 376 | |
| 377 | NOTE1: Enabling/disabling will fail if the cgroup already has other |
| 378 | cgroups created below it. |
| 379 | |
| 380 | NOTE2: This feature can be enabled/disabled per subtree. |
| 381 | |
| 382 | 7. TODO |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 383 | |
| 384 | 1. Add support for accounting huge pages (as a separate controller) |
KAMEZAWA Hiroyuki | dfc05c2 | 2008-02-07 00:14:41 -0800 | [diff] [blame] | 385 | 2. Make per-cgroup scanner reclaim not-shared pages first |
| 386 | 3. Teach controller to account for shared-pages |
KAMEZAWA Hiroyuki | 628f423 | 2008-07-25 01:47:20 -0700 | [diff] [blame] | 387 | 4. Start reclamation in the background when the limit is |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 388 | not yet hit but the usage is getting closer |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 389 | |
| 390 | Summary |
| 391 | |
| 392 | Overall, the memory controller has been a stable controller and has been |
| 393 | commented and discussed quite extensively in the community. |
| 394 | |
| 395 | References |
| 396 | |
| 397 | 1. Singh, Balbir. RFC: Memory Controller, http://lwn.net/Articles/206697/ |
| 398 | 2. Singh, Balbir. Memory Controller (RSS Control), |
| 399 | http://lwn.net/Articles/222762/ |
| 400 | 3. Emelianov, Pavel. Resource controllers based on process cgroups |
| 401 | http://lkml.org/lkml/2007/3/6/198 |
| 402 | 4. Emelianov, Pavel. RSS controller based on process cgroups (v2) |
Li Zefan | 2324c5d | 2008-02-23 15:24:12 -0800 | [diff] [blame] | 403 | http://lkml.org/lkml/2007/4/9/78 |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 404 | 5. Emelianov, Pavel. RSS controller based on process cgroups (v3) |
| 405 | http://lkml.org/lkml/2007/5/30/244 |
| 406 | 6. Menage, Paul. Control Groups v10, http://lwn.net/Articles/236032/ |
| 407 | 7. Vaidyanathan, Srinivasan, Control Groups: Pagecache accounting and control |
| 408 | subsystem (v3), http://lwn.net/Articles/235534/ |
Li Zefan | 2324c5d | 2008-02-23 15:24:12 -0800 | [diff] [blame] | 409 | 8. Singh, Balbir. RSS controller v2 test results (lmbench), |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 410 | http://lkml.org/lkml/2007/5/17/232 |
Li Zefan | 2324c5d | 2008-02-23 15:24:12 -0800 | [diff] [blame] | 411 | 9. Singh, Balbir. RSS controller v2 AIM9 results |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 412 | http://lkml.org/lkml/2007/5/18/1 |
Li Zefan | 2324c5d | 2008-02-23 15:24:12 -0800 | [diff] [blame] | 413 | 10. Singh, Balbir. Memory controller v6 test results, |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 414 | http://lkml.org/lkml/2007/8/19/36 |
Li Zefan | 2324c5d | 2008-02-23 15:24:12 -0800 | [diff] [blame] | 415 | 11. Singh, Balbir. Memory controller introduction (v6), |
| 416 | http://lkml.org/lkml/2007/8/17/69 |
Balbir Singh | 1b6df3a | 2008-02-07 00:13:46 -0800 | [diff] [blame] | 417 | 12. Corbet, Jonathan, Controlling memory use in cgroups, |
| 418 | http://lwn.net/Articles/243795/ |