diff options
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r-- | mm/memcontrol.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7bc30707d0c6..71bac4d720d7 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -2790,6 +2790,7 @@ int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, | |||
2790 | gfp_t gfp_mask) | 2790 | gfp_t gfp_mask) |
2791 | { | 2791 | { |
2792 | struct mem_cgroup *memcg = NULL; | 2792 | struct mem_cgroup *memcg = NULL; |
2793 | enum charge_type type = MEM_CGROUP_CHARGE_TYPE_CACHE; | ||
2793 | int ret; | 2794 | int ret; |
2794 | 2795 | ||
2795 | if (mem_cgroup_disabled()) | 2796 | if (mem_cgroup_disabled()) |
@@ -2799,31 +2800,17 @@ int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm, | |||
2799 | 2800 | ||
2800 | if (unlikely(!mm)) | 2801 | if (unlikely(!mm)) |
2801 | mm = &init_mm; | 2802 | mm = &init_mm; |
2803 | if (!page_is_file_cache(page)) | ||
2804 | type = MEM_CGROUP_CHARGE_TYPE_SHMEM; | ||
2802 | 2805 | ||
2803 | if (page_is_file_cache(page)) { | 2806 | if (!PageSwapCache(page)) { |
2804 | ret = __mem_cgroup_try_charge(mm, gfp_mask, 1, &memcg, true); | 2807 | ret = mem_cgroup_charge_common(page, mm, gfp_mask, type); |
2805 | if (ret || !memcg) | 2808 | WARN_ON_ONCE(PageLRU(page)); |
2806 | return ret; | 2809 | } else { /* page is swapcache/shmem */ |
2807 | |||
2808 | /* | ||
2809 | * FUSE reuses pages without going through the final | ||
2810 | * put that would remove them from the LRU list, make | ||
2811 | * sure that they get relinked properly. | ||
2812 | */ | ||
2813 | __mem_cgroup_commit_charge_lrucare(page, memcg, | ||
2814 | MEM_CGROUP_CHARGE_TYPE_CACHE); | ||
2815 | return ret; | ||
2816 | } | ||
2817 | /* shmem */ | ||
2818 | if (PageSwapCache(page)) { | ||
2819 | ret = mem_cgroup_try_charge_swapin(mm, page, gfp_mask, &memcg); | 2810 | ret = mem_cgroup_try_charge_swapin(mm, page, gfp_mask, &memcg); |
2820 | if (!ret) | 2811 | if (!ret) |
2821 | __mem_cgroup_commit_charge_swapin(page, memcg, | 2812 | __mem_cgroup_commit_charge_swapin(page, memcg, type); |
2822 | MEM_CGROUP_CHARGE_TYPE_SHMEM); | 2813 | } |
2823 | } else | ||
2824 | ret = mem_cgroup_charge_common(page, mm, gfp_mask, | ||
2825 | MEM_CGROUP_CHARGE_TYPE_SHMEM); | ||
2826 | |||
2827 | return ret; | 2814 | return ret; |
2828 | } | 2815 | } |
2829 | 2816 | ||