diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memcontrol.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 31ab2c014fa1..a59f946c9338 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -168,12 +168,12 @@ struct page_cgroup { | |||
168 | #define PAGE_CGROUP_FLAG_CACHE (0x1) /* charged as cache */ | 168 | #define PAGE_CGROUP_FLAG_CACHE (0x1) /* charged as cache */ |
169 | #define PAGE_CGROUP_FLAG_ACTIVE (0x2) /* page is active in this cgroup */ | 169 | #define PAGE_CGROUP_FLAG_ACTIVE (0x2) /* page is active in this cgroup */ |
170 | 170 | ||
171 | static inline int page_cgroup_nid(struct page_cgroup *pc) | 171 | static int page_cgroup_nid(struct page_cgroup *pc) |
172 | { | 172 | { |
173 | return page_to_nid(pc->page); | 173 | return page_to_nid(pc->page); |
174 | } | 174 | } |
175 | 175 | ||
176 | static inline enum zone_type page_cgroup_zid(struct page_cgroup *pc) | 176 | static enum zone_type page_cgroup_zid(struct page_cgroup *pc) |
177 | { | 177 | { |
178 | return page_zonenum(pc->page); | 178 | return page_zonenum(pc->page); |
179 | } | 179 | } |
@@ -199,14 +199,13 @@ static void mem_cgroup_charge_statistics(struct mem_cgroup *mem, int flags, | |||
199 | __mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_RSS, val); | 199 | __mem_cgroup_stat_add_safe(stat, MEM_CGROUP_STAT_RSS, val); |
200 | } | 200 | } |
201 | 201 | ||
202 | static inline struct mem_cgroup_per_zone * | 202 | static struct mem_cgroup_per_zone * |
203 | mem_cgroup_zoneinfo(struct mem_cgroup *mem, int nid, int zid) | 203 | mem_cgroup_zoneinfo(struct mem_cgroup *mem, int nid, int zid) |
204 | { | 204 | { |
205 | BUG_ON(!mem->info.nodeinfo[nid]); | ||
206 | return &mem->info.nodeinfo[nid]->zoneinfo[zid]; | 205 | return &mem->info.nodeinfo[nid]->zoneinfo[zid]; |
207 | } | 206 | } |
208 | 207 | ||
209 | static inline struct mem_cgroup_per_zone * | 208 | static struct mem_cgroup_per_zone * |
210 | page_cgroup_zoneinfo(struct page_cgroup *pc) | 209 | page_cgroup_zoneinfo(struct page_cgroup *pc) |
211 | { | 210 | { |
212 | struct mem_cgroup *mem = pc->mem_cgroup; | 211 | struct mem_cgroup *mem = pc->mem_cgroup; |
@@ -231,16 +230,14 @@ static unsigned long mem_cgroup_get_all_zonestat(struct mem_cgroup *mem, | |||
231 | return total; | 230 | return total; |
232 | } | 231 | } |
233 | 232 | ||
234 | static inline | 233 | static struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont) |
235 | struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont) | ||
236 | { | 234 | { |
237 | return container_of(cgroup_subsys_state(cont, | 235 | return container_of(cgroup_subsys_state(cont, |
238 | mem_cgroup_subsys_id), struct mem_cgroup, | 236 | mem_cgroup_subsys_id), struct mem_cgroup, |
239 | css); | 237 | css); |
240 | } | 238 | } |
241 | 239 | ||
242 | static inline | 240 | static struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p) |
243 | struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p) | ||
244 | { | 241 | { |
245 | return container_of(task_subsys_state(p, mem_cgroup_subsys_id), | 242 | return container_of(task_subsys_state(p, mem_cgroup_subsys_id), |
246 | struct mem_cgroup, css); | 243 | struct mem_cgroup, css); |
@@ -276,13 +273,12 @@ struct page_cgroup *page_get_page_cgroup(struct page *page) | |||
276 | return (struct page_cgroup *) (page->page_cgroup & ~PAGE_CGROUP_LOCK); | 273 | return (struct page_cgroup *) (page->page_cgroup & ~PAGE_CGROUP_LOCK); |
277 | } | 274 | } |
278 | 275 | ||
279 | static void __always_inline lock_page_cgroup(struct page *page) | 276 | static void lock_page_cgroup(struct page *page) |
280 | { | 277 | { |
281 | bit_spin_lock(PAGE_CGROUP_LOCK_BIT, &page->page_cgroup); | 278 | bit_spin_lock(PAGE_CGROUP_LOCK_BIT, &page->page_cgroup); |
282 | VM_BUG_ON(!page_cgroup_locked(page)); | ||
283 | } | 279 | } |
284 | 280 | ||
285 | static void __always_inline unlock_page_cgroup(struct page *page) | 281 | static void unlock_page_cgroup(struct page *page) |
286 | { | 282 | { |
287 | bit_spin_unlock(PAGE_CGROUP_LOCK_BIT, &page->page_cgroup); | 283 | bit_spin_unlock(PAGE_CGROUP_LOCK_BIT, &page->page_cgroup); |
288 | } | 284 | } |
@@ -741,16 +737,14 @@ void mem_cgroup_end_migration(struct page *page) | |||
741 | void mem_cgroup_page_migration(struct page *page, struct page *newpage) | 737 | void mem_cgroup_page_migration(struct page *page, struct page *newpage) |
742 | { | 738 | { |
743 | struct page_cgroup *pc; | 739 | struct page_cgroup *pc; |
744 | struct mem_cgroup *mem; | ||
745 | unsigned long flags; | ||
746 | struct mem_cgroup_per_zone *mz; | 740 | struct mem_cgroup_per_zone *mz; |
741 | unsigned long flags; | ||
747 | 742 | ||
748 | retry: | 743 | retry: |
749 | pc = page_get_page_cgroup(page); | 744 | pc = page_get_page_cgroup(page); |
750 | if (!pc) | 745 | if (!pc) |
751 | return; | 746 | return; |
752 | 747 | ||
753 | mem = pc->mem_cgroup; | ||
754 | mz = page_cgroup_zoneinfo(pc); | 748 | mz = page_cgroup_zoneinfo(pc); |
755 | if (clear_page_cgroup(page, pc) != pc) | 749 | if (clear_page_cgroup(page, pc) != pc) |
756 | goto retry; | 750 | goto retry; |
@@ -822,7 +816,7 @@ retry: | |||
822 | * make mem_cgroup's charge to be 0 if there is no task. | 816 | * make mem_cgroup's charge to be 0 if there is no task. |
823 | * This enables deleting this mem_cgroup. | 817 | * This enables deleting this mem_cgroup. |
824 | */ | 818 | */ |
825 | int mem_cgroup_force_empty(struct mem_cgroup *mem) | 819 | static int mem_cgroup_force_empty(struct mem_cgroup *mem) |
826 | { | 820 | { |
827 | int ret = -EBUSY; | 821 | int ret = -EBUSY; |
828 | int node, zid; | 822 | int node, zid; |
@@ -852,7 +846,7 @@ out: | |||
852 | return ret; | 846 | return ret; |
853 | } | 847 | } |
854 | 848 | ||
855 | int mem_cgroup_write_strategy(char *buf, unsigned long long *tmp) | 849 | static int mem_cgroup_write_strategy(char *buf, unsigned long long *tmp) |
856 | { | 850 | { |
857 | *tmp = memparse(buf, &buf); | 851 | *tmp = memparse(buf, &buf); |
858 | if (*buf != '\0') | 852 | if (*buf != '\0') |