Balbir Singh | 8cdea7c | 2008-02-07 00:13:50 -0800 | [diff] [blame] | 1 | /* memcontrol.h - Memory Controller |
| 2 | * |
| 3 | * Copyright IBM Corporation, 2007 |
| 4 | * Author Balbir Singh <balbir@linux.vnet.ibm.com> |
| 5 | * |
Pavel Emelianov | 78fb746 | 2008-02-07 00:13:51 -0800 | [diff] [blame] | 6 | * Copyright 2007 OpenVZ SWsoft Inc |
| 7 | * Author: Pavel Emelianov <xemul@openvz.org> |
| 8 | * |
Balbir Singh | 8cdea7c | 2008-02-07 00:13:50 -0800 | [diff] [blame] | 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | */ |
| 19 | |
| 20 | #ifndef _LINUX_MEMCONTROL_H |
| 21 | #define _LINUX_MEMCONTROL_H |
Hirokazu Takahashi | f8d66542 | 2009-01-07 18:08:02 -0800 | [diff] [blame] | 22 | #include <linux/cgroup.h> |
Ying Han | 456f998 | 2011-05-26 16:25:38 -0700 | [diff] [blame] | 23 | #include <linux/vm_event_item.h> |
| 24 | |
Pavel Emelianov | 78fb746 | 2008-02-07 00:13:51 -0800 | [diff] [blame] | 25 | struct mem_cgroup; |
| 26 | struct page_cgroup; |
Balbir Singh | 8697d33 | 2008-02-07 00:13:59 -0800 | [diff] [blame] | 27 | struct page; |
| 28 | struct mm_struct; |
Pavel Emelianov | 78fb746 | 2008-02-07 00:13:51 -0800 | [diff] [blame] | 29 | |
Greg Thelen | 2a7106f | 2011-01-13 15:47:37 -0800 | [diff] [blame] | 30 | /* Stats that can be updated by kernel. */ |
| 31 | enum mem_cgroup_page_stat_item { |
| 32 | MEMCG_NR_FILE_MAPPED, /* # of pages charged as file rss */ |
| 33 | }; |
| 34 | |
Johannes Weiner | 5660048 | 2012-01-12 17:17:59 -0800 | [diff] [blame] | 35 | struct mem_cgroup_reclaim_cookie { |
| 36 | struct zone *zone; |
| 37 | int priority; |
| 38 | unsigned int generation; |
| 39 | }; |
| 40 | |
Andrew Morton | c255a45 | 2012-07-31 16:43:02 -0700 | [diff] [blame] | 41 | #ifdef CONFIG_MEMCG |
KAMEZAWA Hiroyuki | 2c26fdd | 2009-01-07 18:08:10 -0800 | [diff] [blame] | 42 | /* |
| 43 | * All "charge" functions with gfp_mask should use GFP_KERNEL or |
| 44 | * (gfp_mask & GFP_RECLAIM_MASK). In current implementatin, memcg doesn't |
| 45 | * alloc memory but reclaims memory from all available zones. So, "where I want |
| 46 | * memory from" bits of gfp_mask has no meaning. So any bits of that field is |
| 47 | * available but adding a rule is better. charge functions' gfp_mask should |
| 48 | * be set to GFP_KERNEL or gfp_mask & GFP_RECLAIM_MASK for avoiding ambiguous |
| 49 | * codes. |
| 50 | * (Of course, if memcg does memory allocation in future, GFP_KERNEL is sane.) |
| 51 | */ |
Pavel Emelianov | 78fb746 | 2008-02-07 00:13:51 -0800 | [diff] [blame] | 52 | |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 53 | extern int mem_cgroup_newpage_charge(struct page *page, struct mm_struct *mm, |
Balbir Singh | e1a1cd5 | 2008-02-07 00:14:02 -0800 | [diff] [blame] | 54 | gfp_t gfp_mask); |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 55 | /* for swap handling */ |
KAMEZAWA Hiroyuki | 8c7c6e34 | 2009-01-07 18:08:00 -0800 | [diff] [blame] | 56 | extern int mem_cgroup_try_charge_swapin(struct mm_struct *mm, |
Johannes Weiner | 72835c8 | 2012-01-12 17:18:32 -0800 | [diff] [blame] | 57 | struct page *page, gfp_t mask, struct mem_cgroup **memcgp); |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 58 | extern void mem_cgroup_commit_charge_swapin(struct page *page, |
Johannes Weiner | 72835c8 | 2012-01-12 17:18:32 -0800 | [diff] [blame] | 59 | struct mem_cgroup *memcg); |
| 60 | extern void mem_cgroup_cancel_charge_swapin(struct mem_cgroup *memcg); |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 61 | |
Hugh Dickins | 8289546 | 2008-03-04 14:29:08 -0800 | [diff] [blame] | 62 | extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, |
| 63 | gfp_t gfp_mask); |
Johannes Weiner | 925b767 | 2012-01-12 17:18:15 -0800 | [diff] [blame] | 64 | |
| 65 | struct lruvec *mem_cgroup_zone_lruvec(struct zone *, struct mem_cgroup *); |
Hugh Dickins | fa9add6 | 2012-05-29 15:07:09 -0700 | [diff] [blame] | 66 | struct lruvec *mem_cgroup_page_lruvec(struct page *, struct zone *); |
KAMEZAWA Hiroyuki | 569b846 | 2009-12-15 16:47:03 -0800 | [diff] [blame] | 67 | |
| 68 | /* For coalescing uncharge for reducing memcg' overhead*/ |
| 69 | extern void mem_cgroup_uncharge_start(void); |
| 70 | extern void mem_cgroup_uncharge_end(void); |
| 71 | |
Balbir Singh | 3c541e1 | 2008-02-07 00:14:41 -0800 | [diff] [blame] | 72 | extern void mem_cgroup_uncharge_page(struct page *page); |
KAMEZAWA Hiroyuki | 69029cd | 2008-07-25 01:47:14 -0700 | [diff] [blame] | 73 | extern void mem_cgroup_uncharge_cache_page(struct page *page); |
KAMEZAWA Hiroyuki | c9b0ed5 | 2008-07-25 01:47:15 -0700 | [diff] [blame] | 74 | |
Johannes Weiner | c3ac9a8 | 2012-05-29 15:06:25 -0700 | [diff] [blame] | 75 | bool __mem_cgroup_same_or_subtree(const struct mem_cgroup *root_memcg, |
| 76 | struct mem_cgroup *memcg); |
Raghavendra K T | c0ff4b8 | 2011-11-02 13:38:15 -0700 | [diff] [blame] | 77 | int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *memcg); |
David Rientjes | 3062fc6 | 2008-02-07 00:14:03 -0800 | [diff] [blame] | 78 | |
Wu Fengguang | e42d9d5 | 2009-12-16 12:19:59 +0100 | [diff] [blame] | 79 | extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page); |
Balbir Singh | cf475ad | 2008-04-29 01:00:16 -0700 | [diff] [blame] | 80 | extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); |
KOSAKI Motohiro | a433658 | 2011-06-15 15:08:13 -0700 | [diff] [blame] | 81 | extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm); |
Balbir Singh | cf475ad | 2008-04-29 01:00:16 -0700 | [diff] [blame] | 82 | |
Glauber Costa | e1aab16 | 2011-12-11 21:47:03 +0000 | [diff] [blame] | 83 | extern struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg); |
Glauber Costa | d1a4c0b | 2011-12-11 21:47:04 +0000 | [diff] [blame] | 84 | extern struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont); |
Glauber Costa | e1aab16 | 2011-12-11 21:47:03 +0000 | [diff] [blame] | 85 | |
Lai Jiangshan | 2e4d409 | 2009-01-07 18:08:07 -0800 | [diff] [blame] | 86 | static inline |
| 87 | int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup) |
| 88 | { |
Raghavendra K T | c0ff4b8 | 2011-11-02 13:38:15 -0700 | [diff] [blame] | 89 | struct mem_cgroup *memcg; |
Johannes Weiner | c3ac9a8 | 2012-05-29 15:06:25 -0700 | [diff] [blame] | 90 | int match; |
| 91 | |
Lai Jiangshan | 2e4d409 | 2009-01-07 18:08:07 -0800 | [diff] [blame] | 92 | rcu_read_lock(); |
Raghavendra K T | c0ff4b8 | 2011-11-02 13:38:15 -0700 | [diff] [blame] | 93 | memcg = mem_cgroup_from_task(rcu_dereference((mm)->owner)); |
Johannes Weiner | c3ac9a8 | 2012-05-29 15:06:25 -0700 | [diff] [blame] | 94 | match = __mem_cgroup_same_or_subtree(cgroup, memcg); |
Lai Jiangshan | 2e4d409 | 2009-01-07 18:08:07 -0800 | [diff] [blame] | 95 | rcu_read_unlock(); |
Johannes Weiner | c3ac9a8 | 2012-05-29 15:06:25 -0700 | [diff] [blame] | 96 | return match; |
Lai Jiangshan | 2e4d409 | 2009-01-07 18:08:07 -0800 | [diff] [blame] | 97 | } |
Balbir Singh | 8a9f3cc | 2008-02-07 00:13:53 -0800 | [diff] [blame] | 98 | |
Raghavendra K T | c0ff4b8 | 2011-11-02 13:38:15 -0700 | [diff] [blame] | 99 | extern struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *memcg); |
Wu Fengguang | d324236 | 2009-12-16 12:19:59 +0100 | [diff] [blame] | 100 | |
Johannes Weiner | 0030f53 | 2012-07-31 16:45:25 -0700 | [diff] [blame] | 101 | extern void |
| 102 | mem_cgroup_prepare_migration(struct page *page, struct page *newpage, |
| 103 | struct mem_cgroup **memcgp); |
Raghavendra K T | c0ff4b8 | 2011-11-02 13:38:15 -0700 | [diff] [blame] | 104 | extern void mem_cgroup_end_migration(struct mem_cgroup *memcg, |
Daisuke Nishimura | 50de1dd | 2011-01-13 15:47:43 -0800 | [diff] [blame] | 105 | struct page *oldpage, struct page *newpage, bool migration_ok); |
KAMEZAWA Hiroyuki | ae41be3 | 2008-02-07 00:14:10 -0800 | [diff] [blame] | 106 | |
Johannes Weiner | 5660048 | 2012-01-12 17:17:59 -0800 | [diff] [blame] | 107 | struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *, |
| 108 | struct mem_cgroup *, |
| 109 | struct mem_cgroup_reclaim_cookie *); |
| 110 | void mem_cgroup_iter_break(struct mem_cgroup *, struct mem_cgroup *); |
| 111 | |
KAMEZAWA Hiroyuki | 58ae83d | 2008-02-07 00:14:32 -0800 | [diff] [blame] | 112 | /* |
| 113 | * For memory reclaim. |
| 114 | */ |
Konstantin Khlebnikov | c56d5c7 | 2012-05-29 15:07:00 -0700 | [diff] [blame] | 115 | int mem_cgroup_inactive_anon_is_low(struct lruvec *lruvec); |
| 116 | int mem_cgroup_inactive_file_is_low(struct lruvec *lruvec); |
Ying Han | 889976d | 2011-05-26 16:25:33 -0700 | [diff] [blame] | 117 | int mem_cgroup_select_victim_node(struct mem_cgroup *memcg); |
Hugh Dickins | 4d7dcca | 2012-05-29 15:07:08 -0700 | [diff] [blame] | 118 | unsigned long mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list); |
Hugh Dickins | fa9add6 | 2012-05-29 15:07:09 -0700 | [diff] [blame] | 119 | void mem_cgroup_update_lru_size(struct lruvec *, enum lru_list, int); |
Balbir Singh | e222432 | 2009-04-02 16:57:39 -0700 | [diff] [blame] | 120 | extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, |
| 121 | struct task_struct *p); |
KAMEZAWA Hiroyuki | ab936cb | 2012-01-12 17:17:44 -0800 | [diff] [blame] | 122 | extern void mem_cgroup_replace_page_cache(struct page *oldpage, |
| 123 | struct page *newpage); |
KAMEZAWA Hiroyuki | 58ae83d | 2008-02-07 00:14:32 -0800 | [diff] [blame] | 124 | |
Andrew Morton | c255a45 | 2012-07-31 16:43:02 -0700 | [diff] [blame] | 125 | #ifdef CONFIG_MEMCG_SWAP |
KAMEZAWA Hiroyuki | c077719 | 2009-01-07 18:07:57 -0800 | [diff] [blame] | 126 | extern int do_swap_account; |
| 127 | #endif |
Hirokazu Takahashi | f8d66542 | 2009-01-07 18:08:02 -0800 | [diff] [blame] | 128 | |
| 129 | static inline bool mem_cgroup_disabled(void) |
| 130 | { |
| 131 | if (mem_cgroup_subsys.disabled) |
| 132 | return true; |
| 133 | return false; |
| 134 | } |
| 135 | |
KAMEZAWA Hiroyuki | 89c06bd | 2012-03-21 16:34:25 -0700 | [diff] [blame] | 136 | void __mem_cgroup_begin_update_page_stat(struct page *page, bool *locked, |
| 137 | unsigned long *flags); |
| 138 | |
KAMEZAWA Hiroyuki | 4331f7d | 2012-03-21 16:34:26 -0700 | [diff] [blame] | 139 | extern atomic_t memcg_moving; |
| 140 | |
KAMEZAWA Hiroyuki | 89c06bd | 2012-03-21 16:34:25 -0700 | [diff] [blame] | 141 | static inline void mem_cgroup_begin_update_page_stat(struct page *page, |
| 142 | bool *locked, unsigned long *flags) |
| 143 | { |
| 144 | if (mem_cgroup_disabled()) |
| 145 | return; |
| 146 | rcu_read_lock(); |
| 147 | *locked = false; |
KAMEZAWA Hiroyuki | 4331f7d | 2012-03-21 16:34:26 -0700 | [diff] [blame] | 148 | if (atomic_read(&memcg_moving)) |
| 149 | __mem_cgroup_begin_update_page_stat(page, locked, flags); |
KAMEZAWA Hiroyuki | 89c06bd | 2012-03-21 16:34:25 -0700 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | void __mem_cgroup_end_update_page_stat(struct page *page, |
| 153 | unsigned long *flags); |
| 154 | static inline void mem_cgroup_end_update_page_stat(struct page *page, |
| 155 | bool *locked, unsigned long *flags) |
| 156 | { |
| 157 | if (mem_cgroup_disabled()) |
| 158 | return; |
| 159 | if (*locked) |
| 160 | __mem_cgroup_end_update_page_stat(page, flags); |
| 161 | rcu_read_unlock(); |
| 162 | } |
| 163 | |
Greg Thelen | 2a7106f | 2011-01-13 15:47:37 -0800 | [diff] [blame] | 164 | void mem_cgroup_update_page_stat(struct page *page, |
| 165 | enum mem_cgroup_page_stat_item idx, |
| 166 | int val); |
| 167 | |
| 168 | static inline void mem_cgroup_inc_page_stat(struct page *page, |
| 169 | enum mem_cgroup_page_stat_item idx) |
| 170 | { |
| 171 | mem_cgroup_update_page_stat(page, idx, 1); |
| 172 | } |
| 173 | |
| 174 | static inline void mem_cgroup_dec_page_stat(struct page *page, |
| 175 | enum mem_cgroup_page_stat_item idx) |
| 176 | { |
| 177 | mem_cgroup_update_page_stat(page, idx, -1); |
| 178 | } |
| 179 | |
Balbir Singh | 4e41695 | 2009-09-23 15:56:39 -0700 | [diff] [blame] | 180 | unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, |
Ying Han | 0ae5e89 | 2011-05-26 16:25:25 -0700 | [diff] [blame] | 181 | gfp_t gfp_mask, |
| 182 | unsigned long *total_scanned); |
David Rientjes | a63d83f | 2010-08-09 17:19:46 -0700 | [diff] [blame] | 183 | |
Ying Han | 456f998 | 2011-05-26 16:25:38 -0700 | [diff] [blame] | 184 | void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx); |
KAMEZAWA Hiroyuki | ca3e021 | 2011-01-20 14:44:24 -0800 | [diff] [blame] | 185 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
KAMEZAWA Hiroyuki | e94c8a9 | 2012-01-12 17:18:20 -0800 | [diff] [blame] | 186 | void mem_cgroup_split_huge_fixup(struct page *head); |
KAMEZAWA Hiroyuki | ca3e021 | 2011-01-20 14:44:24 -0800 | [diff] [blame] | 187 | #endif |
| 188 | |
Daisuke Nishimura | f212ad7 | 2011-03-23 16:42:25 -0700 | [diff] [blame] | 189 | #ifdef CONFIG_DEBUG_VM |
| 190 | bool mem_cgroup_bad_page_check(struct page *page); |
| 191 | void mem_cgroup_print_bad_page(struct page *page); |
| 192 | #endif |
Andrew Morton | c255a45 | 2012-07-31 16:43:02 -0700 | [diff] [blame] | 193 | #else /* CONFIG_MEMCG */ |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 194 | struct mem_cgroup; |
| 195 | |
| 196 | static inline int mem_cgroup_newpage_charge(struct page *page, |
Hugh Dickins | 8289546 | 2008-03-04 14:29:08 -0800 | [diff] [blame] | 197 | struct mm_struct *mm, gfp_t gfp_mask) |
Balbir Singh | 8a9f3cc | 2008-02-07 00:13:53 -0800 | [diff] [blame] | 198 | { |
| 199 | return 0; |
| 200 | } |
| 201 | |
Hugh Dickins | 8289546 | 2008-03-04 14:29:08 -0800 | [diff] [blame] | 202 | static inline int mem_cgroup_cache_charge(struct page *page, |
| 203 | struct mm_struct *mm, gfp_t gfp_mask) |
Balbir Singh | 8a9f3cc | 2008-02-07 00:13:53 -0800 | [diff] [blame] | 204 | { |
Hugh Dickins | 8289546 | 2008-03-04 14:29:08 -0800 | [diff] [blame] | 205 | return 0; |
Balbir Singh | 8a9f3cc | 2008-02-07 00:13:53 -0800 | [diff] [blame] | 206 | } |
| 207 | |
KAMEZAWA Hiroyuki | 8c7c6e34 | 2009-01-07 18:08:00 -0800 | [diff] [blame] | 208 | static inline int mem_cgroup_try_charge_swapin(struct mm_struct *mm, |
Johannes Weiner | 72835c8 | 2012-01-12 17:18:32 -0800 | [diff] [blame] | 209 | struct page *page, gfp_t gfp_mask, struct mem_cgroup **memcgp) |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 210 | { |
| 211 | return 0; |
| 212 | } |
| 213 | |
| 214 | static inline void mem_cgroup_commit_charge_swapin(struct page *page, |
Johannes Weiner | 72835c8 | 2012-01-12 17:18:32 -0800 | [diff] [blame] | 215 | struct mem_cgroup *memcg) |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 216 | { |
| 217 | } |
| 218 | |
Johannes Weiner | 72835c8 | 2012-01-12 17:18:32 -0800 | [diff] [blame] | 219 | static inline void mem_cgroup_cancel_charge_swapin(struct mem_cgroup *memcg) |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 220 | { |
| 221 | } |
| 222 | |
KAMEZAWA Hiroyuki | 569b846 | 2009-12-15 16:47:03 -0800 | [diff] [blame] | 223 | static inline void mem_cgroup_uncharge_start(void) |
| 224 | { |
| 225 | } |
| 226 | |
| 227 | static inline void mem_cgroup_uncharge_end(void) |
| 228 | { |
| 229 | } |
| 230 | |
Balbir Singh | 8a9f3cc | 2008-02-07 00:13:53 -0800 | [diff] [blame] | 231 | static inline void mem_cgroup_uncharge_page(struct page *page) |
| 232 | { |
| 233 | } |
| 234 | |
KAMEZAWA Hiroyuki | 69029cd | 2008-07-25 01:47:14 -0700 | [diff] [blame] | 235 | static inline void mem_cgroup_uncharge_cache_page(struct page *page) |
| 236 | { |
| 237 | } |
| 238 | |
Johannes Weiner | 925b767 | 2012-01-12 17:18:15 -0800 | [diff] [blame] | 239 | static inline struct lruvec *mem_cgroup_zone_lruvec(struct zone *zone, |
| 240 | struct mem_cgroup *memcg) |
| 241 | { |
| 242 | return &zone->lruvec; |
| 243 | } |
| 244 | |
Hugh Dickins | fa9add6 | 2012-05-29 15:07:09 -0700 | [diff] [blame] | 245 | static inline struct lruvec *mem_cgroup_page_lruvec(struct page *page, |
| 246 | struct zone *zone) |
Minchan Kim | 3f58a82 | 2011-03-22 16:32:53 -0700 | [diff] [blame] | 247 | { |
Johannes Weiner | 925b767 | 2012-01-12 17:18:15 -0800 | [diff] [blame] | 248 | return &zone->lruvec; |
Balbir Singh | 66e1707 | 2008-02-07 00:13:56 -0800 | [diff] [blame] | 249 | } |
| 250 | |
Wu Fengguang | e42d9d5 | 2009-12-16 12:19:59 +0100 | [diff] [blame] | 251 | static inline struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page) |
| 252 | { |
| 253 | return NULL; |
| 254 | } |
| 255 | |
KOSAKI Motohiro | a433658 | 2011-06-15 15:08:13 -0700 | [diff] [blame] | 256 | static inline struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm) |
| 257 | { |
| 258 | return NULL; |
| 259 | } |
| 260 | |
Raghavendra K T | c0ff4b8 | 2011-11-02 13:38:15 -0700 | [diff] [blame] | 261 | static inline int mm_match_cgroup(struct mm_struct *mm, |
| 262 | struct mem_cgroup *memcg) |
Balbir Singh | bed7161 | 2008-02-07 00:14:01 -0800 | [diff] [blame] | 263 | { |
David Rientjes | 60c12b1 | 2008-02-09 00:10:15 -0800 | [diff] [blame] | 264 | return 1; |
Balbir Singh | bed7161 | 2008-02-07 00:14:01 -0800 | [diff] [blame] | 265 | } |
| 266 | |
David Rientjes | 4c4a221 | 2008-02-07 00:14:06 -0800 | [diff] [blame] | 267 | static inline int task_in_mem_cgroup(struct task_struct *task, |
Raghavendra K T | c0ff4b8 | 2011-11-02 13:38:15 -0700 | [diff] [blame] | 268 | const struct mem_cgroup *memcg) |
David Rientjes | 4c4a221 | 2008-02-07 00:14:06 -0800 | [diff] [blame] | 269 | { |
| 270 | return 1; |
| 271 | } |
| 272 | |
Raghavendra K T | c0ff4b8 | 2011-11-02 13:38:15 -0700 | [diff] [blame] | 273 | static inline struct cgroup_subsys_state |
| 274 | *mem_cgroup_css(struct mem_cgroup *memcg) |
Wu Fengguang | d324236 | 2009-12-16 12:19:59 +0100 | [diff] [blame] | 275 | { |
| 276 | return NULL; |
| 277 | } |
| 278 | |
Johannes Weiner | 0030f53 | 2012-07-31 16:45:25 -0700 | [diff] [blame] | 279 | static inline void |
akpm@linux-foundation.org | ac39cf8 | 2010-05-26 14:42:46 -0700 | [diff] [blame] | 280 | mem_cgroup_prepare_migration(struct page *page, struct page *newpage, |
Johannes Weiner | 0030f53 | 2012-07-31 16:45:25 -0700 | [diff] [blame] | 281 | struct mem_cgroup **memcgp) |
KAMEZAWA Hiroyuki | ae41be3 | 2008-02-07 00:14:10 -0800 | [diff] [blame] | 282 | { |
KAMEZAWA Hiroyuki | ae41be3 | 2008-02-07 00:14:10 -0800 | [diff] [blame] | 283 | } |
| 284 | |
Raghavendra K T | c0ff4b8 | 2011-11-02 13:38:15 -0700 | [diff] [blame] | 285 | static inline void mem_cgroup_end_migration(struct mem_cgroup *memcg, |
Daisuke Nishimura | 50de1dd | 2011-01-13 15:47:43 -0800 | [diff] [blame] | 286 | struct page *oldpage, struct page *newpage, bool migration_ok) |
KAMEZAWA Hiroyuki | ae41be3 | 2008-02-07 00:14:10 -0800 | [diff] [blame] | 287 | { |
| 288 | } |
| 289 | |
Johannes Weiner | 5660048 | 2012-01-12 17:17:59 -0800 | [diff] [blame] | 290 | static inline struct mem_cgroup * |
| 291 | mem_cgroup_iter(struct mem_cgroup *root, |
| 292 | struct mem_cgroup *prev, |
| 293 | struct mem_cgroup_reclaim_cookie *reclaim) |
| 294 | { |
| 295 | return NULL; |
| 296 | } |
| 297 | |
| 298 | static inline void mem_cgroup_iter_break(struct mem_cgroup *root, |
| 299 | struct mem_cgroup *prev) |
| 300 | { |
| 301 | } |
| 302 | |
Hirokazu Takahashi | f8d66542 | 2009-01-07 18:08:02 -0800 | [diff] [blame] | 303 | static inline bool mem_cgroup_disabled(void) |
| 304 | { |
| 305 | return true; |
| 306 | } |
KAMEZAWA Hiroyuki | a636b32 | 2009-01-07 18:08:08 -0800 | [diff] [blame] | 307 | |
KOSAKI Motohiro | 14797e2 | 2009-01-07 18:08:18 -0800 | [diff] [blame] | 308 | static inline int |
Konstantin Khlebnikov | c56d5c7 | 2012-05-29 15:07:00 -0700 | [diff] [blame] | 309 | mem_cgroup_inactive_anon_is_low(struct lruvec *lruvec) |
KOSAKI Motohiro | 14797e2 | 2009-01-07 18:08:18 -0800 | [diff] [blame] | 310 | { |
| 311 | return 1; |
| 312 | } |
| 313 | |
Rik van Riel | 56e49d2 | 2009-06-16 15:32:28 -0700 | [diff] [blame] | 314 | static inline int |
Konstantin Khlebnikov | c56d5c7 | 2012-05-29 15:07:00 -0700 | [diff] [blame] | 315 | mem_cgroup_inactive_file_is_low(struct lruvec *lruvec) |
Rik van Riel | 56e49d2 | 2009-06-16 15:32:28 -0700 | [diff] [blame] | 316 | { |
| 317 | return 1; |
| 318 | } |
| 319 | |
KOSAKI Motohiro | a3d8e05 | 2009-01-07 18:08:19 -0800 | [diff] [blame] | 320 | static inline unsigned long |
Hugh Dickins | 4d7dcca | 2012-05-29 15:07:08 -0700 | [diff] [blame] | 321 | mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru) |
KOSAKI Motohiro | a3d8e05 | 2009-01-07 18:08:19 -0800 | [diff] [blame] | 322 | { |
| 323 | return 0; |
| 324 | } |
| 325 | |
Hugh Dickins | fa9add6 | 2012-05-29 15:07:09 -0700 | [diff] [blame] | 326 | static inline void |
| 327 | mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru, |
| 328 | int increment) |
KOSAKI Motohiro | 3e2f41f | 2009-01-07 18:08:20 -0800 | [diff] [blame] | 329 | { |
KOSAKI Motohiro | 3e2f41f | 2009-01-07 18:08:20 -0800 | [diff] [blame] | 330 | } |
| 331 | |
Balbir Singh | e222432 | 2009-04-02 16:57:39 -0700 | [diff] [blame] | 332 | static inline void |
| 333 | mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p) |
| 334 | { |
| 335 | } |
| 336 | |
KAMEZAWA Hiroyuki | 89c06bd | 2012-03-21 16:34:25 -0700 | [diff] [blame] | 337 | static inline void mem_cgroup_begin_update_page_stat(struct page *page, |
| 338 | bool *locked, unsigned long *flags) |
| 339 | { |
| 340 | } |
| 341 | |
| 342 | static inline void mem_cgroup_end_update_page_stat(struct page *page, |
| 343 | bool *locked, unsigned long *flags) |
| 344 | { |
| 345 | } |
| 346 | |
Greg Thelen | 2a7106f | 2011-01-13 15:47:37 -0800 | [diff] [blame] | 347 | static inline void mem_cgroup_inc_page_stat(struct page *page, |
| 348 | enum mem_cgroup_page_stat_item idx) |
| 349 | { |
| 350 | } |
| 351 | |
| 352 | static inline void mem_cgroup_dec_page_stat(struct page *page, |
| 353 | enum mem_cgroup_page_stat_item idx) |
Balbir Singh | d69b042 | 2009-06-17 16:26:34 -0700 | [diff] [blame] | 354 | { |
| 355 | } |
| 356 | |
Balbir Singh | 4e41695 | 2009-09-23 15:56:39 -0700 | [diff] [blame] | 357 | static inline |
| 358 | unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, |
Ying Han | 0ae5e89 | 2011-05-26 16:25:25 -0700 | [diff] [blame] | 359 | gfp_t gfp_mask, |
| 360 | unsigned long *total_scanned) |
Balbir Singh | 4e41695 | 2009-09-23 15:56:39 -0700 | [diff] [blame] | 361 | { |
| 362 | return 0; |
| 363 | } |
| 364 | |
KAMEZAWA Hiroyuki | e94c8a9 | 2012-01-12 17:18:20 -0800 | [diff] [blame] | 365 | static inline void mem_cgroup_split_huge_fixup(struct page *head) |
KAMEZAWA Hiroyuki | ca3e021 | 2011-01-20 14:44:24 -0800 | [diff] [blame] | 366 | { |
| 367 | } |
| 368 | |
Ying Han | 456f998 | 2011-05-26 16:25:38 -0700 | [diff] [blame] | 369 | static inline |
| 370 | void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx) |
| 371 | { |
| 372 | } |
KAMEZAWA Hiroyuki | ab936cb | 2012-01-12 17:17:44 -0800 | [diff] [blame] | 373 | static inline void mem_cgroup_replace_page_cache(struct page *oldpage, |
| 374 | struct page *newpage) |
| 375 | { |
| 376 | } |
Andrew Morton | c255a45 | 2012-07-31 16:43:02 -0700 | [diff] [blame] | 377 | #endif /* CONFIG_MEMCG */ |
Pavel Emelianov | 78fb746 | 2008-02-07 00:13:51 -0800 | [diff] [blame] | 378 | |
Andrew Morton | c255a45 | 2012-07-31 16:43:02 -0700 | [diff] [blame] | 379 | #if !defined(CONFIG_MEMCG) || !defined(CONFIG_DEBUG_VM) |
Daisuke Nishimura | f212ad7 | 2011-03-23 16:42:25 -0700 | [diff] [blame] | 380 | static inline bool |
| 381 | mem_cgroup_bad_page_check(struct page *page) |
| 382 | { |
| 383 | return false; |
| 384 | } |
| 385 | |
| 386 | static inline void |
| 387 | mem_cgroup_print_bad_page(struct page *page) |
| 388 | { |
| 389 | } |
| 390 | #endif |
| 391 | |
Glauber Costa | e1aab16 | 2011-12-11 21:47:03 +0000 | [diff] [blame] | 392 | enum { |
| 393 | UNDER_LIMIT, |
| 394 | SOFT_LIMIT, |
| 395 | OVER_LIMIT, |
| 396 | }; |
| 397 | |
| 398 | struct sock; |
Andrew Morton | c255a45 | 2012-07-31 16:43:02 -0700 | [diff] [blame] | 399 | #ifdef CONFIG_MEMCG_KMEM |
Glauber Costa | e1aab16 | 2011-12-11 21:47:03 +0000 | [diff] [blame] | 400 | void sock_update_memcg(struct sock *sk); |
| 401 | void sock_release_memcg(struct sock *sk); |
| 402 | #else |
| 403 | static inline void sock_update_memcg(struct sock *sk) |
| 404 | { |
| 405 | } |
| 406 | static inline void sock_release_memcg(struct sock *sk) |
| 407 | { |
| 408 | } |
Andrew Morton | c255a45 | 2012-07-31 16:43:02 -0700 | [diff] [blame] | 409 | #endif /* CONFIG_MEMCG_KMEM */ |
Balbir Singh | 8cdea7c | 2008-02-07 00:13:50 -0800 | [diff] [blame] | 410 | #endif /* _LINUX_MEMCONTROL_H */ |
| 411 | |