diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memcontrol.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c47dffdcb246..5177c6d4a2dd 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1077,9 +1077,18 @@ static struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm) | |||
1077 | 1077 | ||
1078 | rcu_read_lock(); | 1078 | rcu_read_lock(); |
1079 | do { | 1079 | do { |
1080 | memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); | 1080 | /* |
1081 | if (unlikely(!memcg)) | 1081 | * Page cache insertions can happen withou an |
1082 | * actual mm context, e.g. during disk probing | ||
1083 | * on boot, loopback IO, acct() writes etc. | ||
1084 | */ | ||
1085 | if (unlikely(!mm)) | ||
1082 | memcg = root_mem_cgroup; | 1086 | memcg = root_mem_cgroup; |
1087 | else { | ||
1088 | memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); | ||
1089 | if (unlikely(!memcg)) | ||
1090 | memcg = root_mem_cgroup; | ||
1091 | } | ||
1083 | } while (!css_tryget(&memcg->css)); | 1092 | } while (!css_tryget(&memcg->css)); |
1084 | rcu_read_unlock(); | 1093 | rcu_read_unlock(); |
1085 | return memcg; | 1094 | return memcg; |
@@ -3958,17 +3967,9 @@ int mem_cgroup_charge_file(struct page *page, struct mm_struct *mm, | |||
3958 | return 0; | 3967 | return 0; |
3959 | } | 3968 | } |
3960 | 3969 | ||
3961 | /* | 3970 | memcg = mem_cgroup_try_charge_mm(mm, gfp_mask, 1, true); |
3962 | * Page cache insertions can happen without an actual mm | 3971 | if (!memcg) |
3963 | * context, e.g. during disk probing on boot. | 3972 | return -ENOMEM; |
3964 | */ | ||
3965 | if (unlikely(!mm)) | ||
3966 | memcg = root_mem_cgroup; | ||
3967 | else { | ||
3968 | memcg = mem_cgroup_try_charge_mm(mm, gfp_mask, 1, true); | ||
3969 | if (!memcg) | ||
3970 | return -ENOMEM; | ||
3971 | } | ||
3972 | __mem_cgroup_commit_charge(memcg, page, 1, type, false); | 3973 | __mem_cgroup_commit_charge(memcg, page, 1, type, false); |
3973 | return 0; | 3974 | return 0; |
3974 | } | 3975 | } |