aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c28
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
171static inline int page_cgroup_nid(struct page_cgroup *pc) 171static 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
176static inline enum zone_type page_cgroup_zid(struct page_cgroup *pc) 176static 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
202static inline struct mem_cgroup_per_zone * 202static struct mem_cgroup_per_zone *
203mem_cgroup_zoneinfo(struct mem_cgroup *mem, int nid, int zid) 203mem_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
209static inline struct mem_cgroup_per_zone * 208static struct mem_cgroup_per_zone *
210page_cgroup_zoneinfo(struct page_cgroup *pc) 209page_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
234static inline 233static struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont)
235struct 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
242static inline 240static struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p)
243struct 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
279static void __always_inline lock_page_cgroup(struct page *page) 276static 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
285static void __always_inline unlock_page_cgroup(struct page *page) 281static 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)
741void mem_cgroup_page_migration(struct page *page, struct page *newpage) 737void 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
748retry: 743retry:
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 */
825int mem_cgroup_force_empty(struct mem_cgroup *mem) 819static 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
855int mem_cgroup_write_strategy(char *buf, unsigned long long *tmp) 849static 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')