diff options
Diffstat (limited to 'include/linux/memcontrol.h')
| -rw-r--r-- | include/linux/memcontrol.h | 50 |
1 files changed, 11 insertions, 39 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index ecc82b37c4cc..b3e7a667e03c 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
| @@ -137,47 +137,24 @@ extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, | |||
| 137 | extern void mem_cgroup_replace_page_cache(struct page *oldpage, | 137 | extern void mem_cgroup_replace_page_cache(struct page *oldpage, |
| 138 | struct page *newpage); | 138 | struct page *newpage); |
| 139 | 139 | ||
| 140 | /** | 140 | static inline void mem_cgroup_oom_enable(void) |
| 141 | * mem_cgroup_toggle_oom - toggle the memcg OOM killer for the current task | ||
| 142 | * @new: true to enable, false to disable | ||
| 143 | * | ||
| 144 | * Toggle whether a failed memcg charge should invoke the OOM killer | ||
| 145 | * or just return -ENOMEM. Returns the previous toggle state. | ||
| 146 | * | ||
| 147 | * NOTE: Any path that enables the OOM killer before charging must | ||
| 148 | * call mem_cgroup_oom_synchronize() afterward to finalize the | ||
| 149 | * OOM handling and clean up. | ||
| 150 | */ | ||
| 151 | static inline bool mem_cgroup_toggle_oom(bool new) | ||
| 152 | { | 141 | { |
| 153 | bool old; | 142 | WARN_ON(current->memcg_oom.may_oom); |
| 154 | 143 | current->memcg_oom.may_oom = 1; | |
| 155 | old = current->memcg_oom.may_oom; | ||
| 156 | current->memcg_oom.may_oom = new; | ||
| 157 | |||
| 158 | return old; | ||
| 159 | } | 144 | } |
| 160 | 145 | ||
| 161 | static inline void mem_cgroup_enable_oom(void) | 146 | static inline void mem_cgroup_oom_disable(void) |
| 162 | { | 147 | { |
| 163 | bool old = mem_cgroup_toggle_oom(true); | 148 | WARN_ON(!current->memcg_oom.may_oom); |
| 164 | 149 | current->memcg_oom.may_oom = 0; | |
| 165 | WARN_ON(old == true); | ||
| 166 | } | ||
| 167 | |||
| 168 | static inline void mem_cgroup_disable_oom(void) | ||
| 169 | { | ||
| 170 | bool old = mem_cgroup_toggle_oom(false); | ||
| 171 | |||
| 172 | WARN_ON(old == false); | ||
| 173 | } | 150 | } |
| 174 | 151 | ||
| 175 | static inline bool task_in_memcg_oom(struct task_struct *p) | 152 | static inline bool task_in_memcg_oom(struct task_struct *p) |
| 176 | { | 153 | { |
| 177 | return p->memcg_oom.in_memcg_oom; | 154 | return p->memcg_oom.memcg; |
| 178 | } | 155 | } |
| 179 | 156 | ||
| 180 | bool mem_cgroup_oom_synchronize(void); | 157 | bool mem_cgroup_oom_synchronize(bool wait); |
| 181 | 158 | ||
| 182 | #ifdef CONFIG_MEMCG_SWAP | 159 | #ifdef CONFIG_MEMCG_SWAP |
| 183 | extern int do_swap_account; | 160 | extern int do_swap_account; |
| @@ -402,16 +379,11 @@ static inline void mem_cgroup_end_update_page_stat(struct page *page, | |||
| 402 | { | 379 | { |
| 403 | } | 380 | } |
| 404 | 381 | ||
| 405 | static inline bool mem_cgroup_toggle_oom(bool new) | 382 | static inline void mem_cgroup_oom_enable(void) |
| 406 | { | ||
| 407 | return false; | ||
| 408 | } | ||
| 409 | |||
| 410 | static inline void mem_cgroup_enable_oom(void) | ||
| 411 | { | 383 | { |
| 412 | } | 384 | } |
| 413 | 385 | ||
| 414 | static inline void mem_cgroup_disable_oom(void) | 386 | static inline void mem_cgroup_oom_disable(void) |
| 415 | { | 387 | { |
| 416 | } | 388 | } |
| 417 | 389 | ||
| @@ -420,7 +392,7 @@ static inline bool task_in_memcg_oom(struct task_struct *p) | |||
| 420 | return false; | 392 | return false; |
| 421 | } | 393 | } |
| 422 | 394 | ||
| 423 | static inline bool mem_cgroup_oom_synchronize(void) | 395 | static inline bool mem_cgroup_oom_synchronize(bool wait) |
| 424 | { | 396 | { |
| 425 | return false; | 397 | return false; |
| 426 | } | 398 | } |
