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 |
| 22 | |
Pavel Emelianov | 78fb746 | 2008-02-07 00:13:51 -0800 | [diff] [blame] | 23 | struct mem_cgroup; |
| 24 | struct page_cgroup; |
Balbir Singh | 8697d33 | 2008-02-07 00:13:59 -0800 | [diff] [blame] | 25 | struct page; |
| 26 | struct mm_struct; |
Pavel Emelianov | 78fb746 | 2008-02-07 00:13:51 -0800 | [diff] [blame] | 27 | |
Balbir Singh | 00f0b82 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 28 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR |
Pavel Emelianov | 78fb746 | 2008-02-07 00:13:51 -0800 | [diff] [blame] | 29 | |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 30 | 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] | 31 | gfp_t gfp_mask); |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 32 | /* for swap handling */ |
| 33 | extern int mem_cgroup_try_charge(struct mm_struct *mm, |
| 34 | gfp_t gfp_mask, struct mem_cgroup **ptr); |
KAMEZAWA Hiroyuki | 8c7c6e34 | 2009-01-07 18:08:00 -0800 | [diff] [blame^] | 35 | extern int mem_cgroup_try_charge_swapin(struct mm_struct *mm, |
| 36 | struct page *page, gfp_t mask, struct mem_cgroup **ptr); |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 37 | extern void mem_cgroup_commit_charge_swapin(struct page *page, |
| 38 | struct mem_cgroup *ptr); |
| 39 | extern void mem_cgroup_cancel_charge_swapin(struct mem_cgroup *ptr); |
| 40 | |
Hugh Dickins | 8289546 | 2008-03-04 14:29:08 -0800 | [diff] [blame] | 41 | extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, |
| 42 | gfp_t gfp_mask); |
Lee Schermerhorn | 894bc31 | 2008-10-18 20:26:39 -0700 | [diff] [blame] | 43 | extern void mem_cgroup_move_lists(struct page *page, enum lru_list lru); |
Balbir Singh | 3c541e1 | 2008-02-07 00:14:41 -0800 | [diff] [blame] | 44 | extern void mem_cgroup_uncharge_page(struct page *page); |
KAMEZAWA Hiroyuki | 69029cd | 2008-07-25 01:47:14 -0700 | [diff] [blame] | 45 | extern void mem_cgroup_uncharge_cache_page(struct page *page); |
KAMEZAWA Hiroyuki | c9b0ed5 | 2008-07-25 01:47:15 -0700 | [diff] [blame] | 46 | extern int mem_cgroup_shrink_usage(struct mm_struct *mm, gfp_t gfp_mask); |
| 47 | |
Balbir Singh | 66e1707 | 2008-02-07 00:13:56 -0800 | [diff] [blame] | 48 | extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan, |
| 49 | struct list_head *dst, |
| 50 | unsigned long *scanned, int order, |
| 51 | int mode, struct zone *z, |
| 52 | struct mem_cgroup *mem_cont, |
Rik van Riel | 4f98a2f | 2008-10-18 20:26:32 -0700 | [diff] [blame] | 53 | int active, int file); |
Pavel Emelianov | c7ba5c9 | 2008-02-07 00:13:58 -0800 | [diff] [blame] | 54 | extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask); |
David Rientjes | 4c4a221 | 2008-02-07 00:14:06 -0800 | [diff] [blame] | 55 | int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem); |
David Rientjes | 3062fc6 | 2008-02-07 00:14:03 -0800 | [diff] [blame] | 56 | |
Balbir Singh | cf475ad | 2008-04-29 01:00:16 -0700 | [diff] [blame] | 57 | extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); |
| 58 | |
Hugh Dickins | bd845e3 | 2008-03-04 14:29:01 -0800 | [diff] [blame] | 59 | #define mm_match_cgroup(mm, cgroup) \ |
Balbir Singh | cf475ad | 2008-04-29 01:00:16 -0700 | [diff] [blame] | 60 | ((cgroup) == mem_cgroup_from_task((mm)->owner)) |
Balbir Singh | 8a9f3cc | 2008-02-07 00:13:53 -0800 | [diff] [blame] | 61 | |
KAMEZAWA Hiroyuki | e8589cc | 2008-07-25 01:47:10 -0700 | [diff] [blame] | 62 | extern int |
KAMEZAWA Hiroyuki | 01b1ae6 | 2009-01-07 18:07:50 -0800 | [diff] [blame] | 63 | mem_cgroup_prepare_migration(struct page *page, struct mem_cgroup **ptr); |
| 64 | extern void mem_cgroup_end_migration(struct mem_cgroup *mem, |
| 65 | struct page *oldpage, struct page *newpage); |
KAMEZAWA Hiroyuki | ae41be3 | 2008-02-07 00:14:10 -0800 | [diff] [blame] | 66 | |
KAMEZAWA Hiroyuki | 58ae83d | 2008-02-07 00:14:32 -0800 | [diff] [blame] | 67 | /* |
| 68 | * For memory reclaim. |
| 69 | */ |
| 70 | extern int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem); |
KAMEZAWA Hiroyuki | 5932f36 | 2008-02-07 00:14:33 -0800 | [diff] [blame] | 71 | extern long mem_cgroup_reclaim_imbalance(struct mem_cgroup *mem); |
| 72 | |
KAMEZAWA Hiroyuki | 6c48a1d | 2008-02-07 00:14:34 -0800 | [diff] [blame] | 73 | extern int mem_cgroup_get_reclaim_priority(struct mem_cgroup *mem); |
| 74 | extern void mem_cgroup_note_reclaim_priority(struct mem_cgroup *mem, |
| 75 | int priority); |
| 76 | extern void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, |
| 77 | int priority); |
KAMEZAWA Hiroyuki | 58ae83d | 2008-02-07 00:14:32 -0800 | [diff] [blame] | 78 | |
Christoph Lameter | b69408e | 2008-10-18 20:26:14 -0700 | [diff] [blame] | 79 | extern long mem_cgroup_calc_reclaim(struct mem_cgroup *mem, struct zone *zone, |
| 80 | int priority, enum lru_list lru); |
KAMEZAWA Hiroyuki | 58ae83d | 2008-02-07 00:14:32 -0800 | [diff] [blame] | 81 | |
KAMEZAWA Hiroyuki | c077719 | 2009-01-07 18:07:57 -0800 | [diff] [blame] | 82 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP |
| 83 | extern int do_swap_account; |
| 84 | #endif |
Balbir Singh | 00f0b82 | 2008-03-04 14:28:39 -0800 | [diff] [blame] | 85 | #else /* CONFIG_CGROUP_MEM_RES_CTLR */ |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 86 | struct mem_cgroup; |
| 87 | |
| 88 | static inline int mem_cgroup_newpage_charge(struct page *page, |
Hugh Dickins | 8289546 | 2008-03-04 14:29:08 -0800 | [diff] [blame] | 89 | struct mm_struct *mm, gfp_t gfp_mask) |
Balbir Singh | 8a9f3cc | 2008-02-07 00:13:53 -0800 | [diff] [blame] | 90 | { |
| 91 | return 0; |
| 92 | } |
| 93 | |
Hugh Dickins | 8289546 | 2008-03-04 14:29:08 -0800 | [diff] [blame] | 94 | static inline int mem_cgroup_cache_charge(struct page *page, |
| 95 | struct mm_struct *mm, gfp_t gfp_mask) |
Balbir Singh | 8a9f3cc | 2008-02-07 00:13:53 -0800 | [diff] [blame] | 96 | { |
Hugh Dickins | 8289546 | 2008-03-04 14:29:08 -0800 | [diff] [blame] | 97 | return 0; |
Balbir Singh | 8a9f3cc | 2008-02-07 00:13:53 -0800 | [diff] [blame] | 98 | } |
| 99 | |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 100 | static inline int mem_cgroup_try_charge(struct mm_struct *mm, |
KAMEZAWA Hiroyuki | 8c7c6e34 | 2009-01-07 18:08:00 -0800 | [diff] [blame^] | 101 | gfp_t gfp_mask, struct mem_cgroup **ptr) |
| 102 | { |
| 103 | return 0; |
| 104 | } |
| 105 | |
| 106 | static inline int mem_cgroup_try_charge_swapin(struct mm_struct *mm, |
| 107 | struct page *page, gfp_t gfp_mask, struct mem_cgroup **ptr) |
KAMEZAWA Hiroyuki | 7a81b88 | 2009-01-07 18:07:48 -0800 | [diff] [blame] | 108 | { |
| 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | static inline void mem_cgroup_commit_charge_swapin(struct page *page, |
| 113 | struct mem_cgroup *ptr) |
| 114 | { |
| 115 | } |
| 116 | |
| 117 | static inline void mem_cgroup_cancel_charge_swapin(struct mem_cgroup *ptr) |
| 118 | { |
| 119 | } |
| 120 | |
Balbir Singh | 8a9f3cc | 2008-02-07 00:13:53 -0800 | [diff] [blame] | 121 | static inline void mem_cgroup_uncharge_page(struct page *page) |
| 122 | { |
| 123 | } |
| 124 | |
KAMEZAWA Hiroyuki | 69029cd | 2008-07-25 01:47:14 -0700 | [diff] [blame] | 125 | static inline void mem_cgroup_uncharge_cache_page(struct page *page) |
| 126 | { |
| 127 | } |
| 128 | |
KAMEZAWA Hiroyuki | c9b0ed5 | 2008-07-25 01:47:15 -0700 | [diff] [blame] | 129 | static inline int mem_cgroup_shrink_usage(struct mm_struct *mm, gfp_t gfp_mask) |
| 130 | { |
| 131 | return 0; |
| 132 | } |
| 133 | |
Hugh Dickins | 427d541 | 2008-03-04 14:29:03 -0800 | [diff] [blame] | 134 | static inline void mem_cgroup_move_lists(struct page *page, bool active) |
Balbir Singh | 66e1707 | 2008-02-07 00:13:56 -0800 | [diff] [blame] | 135 | { |
| 136 | } |
| 137 | |
Hugh Dickins | bd845e3 | 2008-03-04 14:29:01 -0800 | [diff] [blame] | 138 | static inline int mm_match_cgroup(struct mm_struct *mm, struct mem_cgroup *mem) |
Balbir Singh | bed7161 | 2008-02-07 00:14:01 -0800 | [diff] [blame] | 139 | { |
David Rientjes | 60c12b1 | 2008-02-09 00:10:15 -0800 | [diff] [blame] | 140 | return 1; |
Balbir Singh | bed7161 | 2008-02-07 00:14:01 -0800 | [diff] [blame] | 141 | } |
| 142 | |
David Rientjes | 4c4a221 | 2008-02-07 00:14:06 -0800 | [diff] [blame] | 143 | static inline int task_in_mem_cgroup(struct task_struct *task, |
| 144 | const struct mem_cgroup *mem) |
| 145 | { |
| 146 | return 1; |
| 147 | } |
| 148 | |
KAMEZAWA Hiroyuki | e8589cc | 2008-07-25 01:47:10 -0700 | [diff] [blame] | 149 | static inline int |
KAMEZAWA Hiroyuki | 01b1ae6 | 2009-01-07 18:07:50 -0800 | [diff] [blame] | 150 | mem_cgroup_prepare_migration(struct page *page, struct mem_cgroup **ptr) |
KAMEZAWA Hiroyuki | ae41be3 | 2008-02-07 00:14:10 -0800 | [diff] [blame] | 151 | { |
| 152 | return 0; |
| 153 | } |
| 154 | |
KAMEZAWA Hiroyuki | 01b1ae6 | 2009-01-07 18:07:50 -0800 | [diff] [blame] | 155 | static inline void mem_cgroup_end_migration(struct mem_cgroup *mem, |
| 156 | struct page *oldpage, |
| 157 | struct page *newpage) |
KAMEZAWA Hiroyuki | ae41be3 | 2008-02-07 00:14:10 -0800 | [diff] [blame] | 158 | { |
| 159 | } |
| 160 | |
KAMEZAWA Hiroyuki | 58ae83d | 2008-02-07 00:14:32 -0800 | [diff] [blame] | 161 | static inline int mem_cgroup_calc_mapped_ratio(struct mem_cgroup *mem) |
| 162 | { |
| 163 | return 0; |
| 164 | } |
KAMEZAWA Hiroyuki | 5932f36 | 2008-02-07 00:14:33 -0800 | [diff] [blame] | 165 | |
| 166 | static inline int mem_cgroup_reclaim_imbalance(struct mem_cgroup *mem) |
| 167 | { |
| 168 | return 0; |
| 169 | } |
| 170 | |
KAMEZAWA Hiroyuki | 6c48a1d | 2008-02-07 00:14:34 -0800 | [diff] [blame] | 171 | static inline int mem_cgroup_get_reclaim_priority(struct mem_cgroup *mem) |
| 172 | { |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | static inline void mem_cgroup_note_reclaim_priority(struct mem_cgroup *mem, |
| 177 | int priority) |
| 178 | { |
| 179 | } |
| 180 | |
| 181 | static inline void mem_cgroup_record_reclaim_priority(struct mem_cgroup *mem, |
| 182 | int priority) |
| 183 | { |
| 184 | } |
| 185 | |
Christoph Lameter | b69408e | 2008-10-18 20:26:14 -0700 | [diff] [blame] | 186 | static inline long mem_cgroup_calc_reclaim(struct mem_cgroup *mem, |
| 187 | struct zone *zone, int priority, |
| 188 | enum lru_list lru) |
KAMEZAWA Hiroyuki | cc38108 | 2008-02-07 00:14:35 -0800 | [diff] [blame] | 189 | { |
| 190 | return 0; |
| 191 | } |
Pavel Emelianov | 78fb746 | 2008-02-07 00:13:51 -0800 | [diff] [blame] | 192 | #endif /* CONFIG_CGROUP_MEM_CONT */ |
| 193 | |
Balbir Singh | 8cdea7c | 2008-02-07 00:13:50 -0800 | [diff] [blame] | 194 | #endif /* _LINUX_MEMCONTROL_H */ |
| 195 | |