diff options
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 878808c4fcbe..488b644e0e8e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -283,6 +283,11 @@ mem_cgroup_zoneinfo(struct mem_cgroup *mem, int nid, int zid) | |||
283 | return &mem->info.nodeinfo[nid]->zoneinfo[zid]; | 283 | return &mem->info.nodeinfo[nid]->zoneinfo[zid]; |
284 | } | 284 | } |
285 | 285 | ||
286 | struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *mem) | ||
287 | { | ||
288 | return &mem->css; | ||
289 | } | ||
290 | |||
286 | static struct mem_cgroup_per_zone * | 291 | static struct mem_cgroup_per_zone * |
287 | page_cgroup_zoneinfo(struct page_cgroup *pc) | 292 | page_cgroup_zoneinfo(struct page_cgroup *pc) |
288 | { | 293 | { |
@@ -1536,25 +1541,22 @@ static struct mem_cgroup *mem_cgroup_lookup(unsigned short id) | |||
1536 | return container_of(css, struct mem_cgroup, css); | 1541 | return container_of(css, struct mem_cgroup, css); |
1537 | } | 1542 | } |
1538 | 1543 | ||
1539 | static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page) | 1544 | struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page) |
1540 | { | 1545 | { |
1541 | struct mem_cgroup *mem; | 1546 | struct mem_cgroup *mem = NULL; |
1542 | struct page_cgroup *pc; | 1547 | struct page_cgroup *pc; |
1543 | unsigned short id; | 1548 | unsigned short id; |
1544 | swp_entry_t ent; | 1549 | swp_entry_t ent; |
1545 | 1550 | ||
1546 | VM_BUG_ON(!PageLocked(page)); | 1551 | VM_BUG_ON(!PageLocked(page)); |
1547 | 1552 | ||
1548 | if (!PageSwapCache(page)) | ||
1549 | return NULL; | ||
1550 | |||
1551 | pc = lookup_page_cgroup(page); | 1553 | pc = lookup_page_cgroup(page); |
1552 | lock_page_cgroup(pc); | 1554 | lock_page_cgroup(pc); |
1553 | if (PageCgroupUsed(pc)) { | 1555 | if (PageCgroupUsed(pc)) { |
1554 | mem = pc->mem_cgroup; | 1556 | mem = pc->mem_cgroup; |
1555 | if (mem && !css_tryget(&mem->css)) | 1557 | if (mem && !css_tryget(&mem->css)) |
1556 | mem = NULL; | 1558 | mem = NULL; |
1557 | } else { | 1559 | } else if (PageSwapCache(page)) { |
1558 | ent.val = page_private(page); | 1560 | ent.val = page_private(page); |
1559 | id = lookup_swap_cgroup(ent); | 1561 | id = lookup_swap_cgroup(ent); |
1560 | rcu_read_lock(); | 1562 | rcu_read_lock(); |
@@ -1874,7 +1876,7 @@ int mem_cgroup_try_charge_swapin(struct mm_struct *mm, | |||
1874 | */ | 1876 | */ |
1875 | if (!PageSwapCache(page)) | 1877 | if (!PageSwapCache(page)) |
1876 | goto charge_cur_mm; | 1878 | goto charge_cur_mm; |
1877 | mem = try_get_mem_cgroup_from_swapcache(page); | 1879 | mem = try_get_mem_cgroup_from_page(page); |
1878 | if (!mem) | 1880 | if (!mem) |
1879 | goto charge_cur_mm; | 1881 | goto charge_cur_mm; |
1880 | *ptr = mem; | 1882 | *ptr = mem; |