diff options
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 575203ae2109..01c2d8f14685 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1617,37 +1617,28 @@ void mem_cgroup_end_migration(struct mem_cgroup *mem, | |||
1617 | } | 1617 | } |
1618 | 1618 | ||
1619 | /* | 1619 | /* |
1620 | * A call to try to shrink memory usage under specified resource controller. | 1620 | * A call to try to shrink memory usage on charge failure at shmem's swapin. |
1621 | * This is typically used for page reclaiming for shmem for reducing side | 1621 | * Calling hierarchical_reclaim is not enough because we should update |
1622 | * effect of page allocation from shmem, which is used by some mem_cgroup. | 1622 | * last_oom_jiffies to prevent pagefault_out_of_memory from invoking global OOM. |
1623 | * Moreover considering hierarchy, we should reclaim from the mem_over_limit, | ||
1624 | * not from the memcg which this page would be charged to. | ||
1625 | * try_charge_swapin does all of these works properly. | ||
1623 | */ | 1626 | */ |
1624 | int mem_cgroup_shrink_usage(struct page *page, | 1627 | int mem_cgroup_shmem_charge_fallback(struct page *page, |
1625 | struct mm_struct *mm, | 1628 | struct mm_struct *mm, |
1626 | gfp_t gfp_mask) | 1629 | gfp_t gfp_mask) |
1627 | { | 1630 | { |
1628 | struct mem_cgroup *mem = NULL; | 1631 | struct mem_cgroup *mem = NULL; |
1629 | int progress = 0; | 1632 | int ret; |
1630 | int retry = MEM_CGROUP_RECLAIM_RETRIES; | ||
1631 | 1633 | ||
1632 | if (mem_cgroup_disabled()) | 1634 | if (mem_cgroup_disabled()) |
1633 | return 0; | 1635 | return 0; |
1634 | if (page) | ||
1635 | mem = try_get_mem_cgroup_from_swapcache(page); | ||
1636 | if (!mem && mm) | ||
1637 | mem = try_get_mem_cgroup_from_mm(mm); | ||
1638 | if (unlikely(!mem)) | ||
1639 | return 0; | ||
1640 | 1636 | ||
1641 | do { | 1637 | ret = mem_cgroup_try_charge_swapin(mm, page, gfp_mask, &mem); |
1642 | progress = mem_cgroup_hierarchical_reclaim(mem, | 1638 | if (!ret) |
1643 | gfp_mask, true, false); | 1639 | mem_cgroup_cancel_charge_swapin(mem); /* it does !mem check */ |
1644 | progress += mem_cgroup_check_under_limit(mem); | ||
1645 | } while (!progress && --retry); | ||
1646 | 1640 | ||
1647 | css_put(&mem->css); | 1641 | return ret; |
1648 | if (!retry) | ||
1649 | return -ENOMEM; | ||
1650 | return 0; | ||
1651 | } | 1642 | } |
1652 | 1643 | ||
1653 | static DEFINE_MUTEX(set_limit_mutex); | 1644 | static DEFINE_MUTEX(set_limit_mutex); |