mm: memcontrol: fix the margin computation in mem_cgroup_margin
Subsystems (3)
PATCH v2 1/1 mm: memcontrol: fix the margin computation in mem_cgroup_margin
From: Li RongQing <[email protected]>
The margin may be set to the difference value between memory limit and memory count firstly. which maybe returned wrongly if memsw.count excess memsw.limit, because try_charge forces charging __GFP_NOFAIL allocations, which may result in memsw.limit excess. If we are below memory.limit and there's nothing to reclaim to reduce memsw.usage, might end up looping in try_charge forever.
--- mm/memcontrol.c | 2 ++ 1 file changed, 2 insertions(+)
mm/memcontrol.c +2 -0
@@ -1090,6 +1090,8 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *memcg) limit =READ_ONCE (memcg->memsw.limit);if (count <= limit) margin =min (margin, limit - count); +else + margin =0 ; }return margin;
Signature · 1 line
2.1.4
Quoted 8 lines · On Tue 24-05-16 13:37:46, [email protected]…
From: Li RongQing <[email protected]>
The margin may be set to the difference value between memory limit and memory count firstly. which maybe returned wrongly if memsw.count excess memsw.limit, because
try_chargeforces charging__GFP_NOFAILallocations, which may result in memsw.limit excess. If we are below memory.limit and there's nothing to reclaim to reduce memsw.usage, might end up looping intry_chargeforever.
This is quite hard for me to grasp. What would you say about the following:
"mem_cgroup_margin might return memory.limit - memory_count when the memsw.limit is in excess. This
doesn't happen usually because we do not allow excess on hard limits and memory.limit <= memsw.limit but __GFP_NOFAIL charges can force the charge and cause the excess when no memory is really swapable (swap is full or no anonymous memory is left).
"
Quoted 4 lines
Signed-off-by Li RongQing <[email protected]>Acked-by Vladimir Davydov <[email protected]>Cc Michal Hocko <mhocko-IBi9RG/[email protected]>
Quoted 19 lines
--- mm/memcontrol.c | 2 ++ 1 file changed, 2 insertions(+)mm/memcontrol.c +2
-0@@ -1090,6 +1090,8 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *memcg) limit =READ_ONCE (memcg->memsw.limit);if (count <= limit) margin =min (margin, limit - count); +else + margin =0 ; }return margin;Signature · 1 line
2.1.4
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 9 lines · Michal Hocko
This is quite hard for me to grasp. What would you say about the following:
"mem_cgroup_marginmight return memory.limit -memory_countwhen the memsw.limit is in excess. This
doesn't happen usually because we do not allow excess on hard limits and memory.limit <= memsw.limit but__GFP_NOFAILcharges can force the charge and cause the excess when no memory is really swapable (swap is full or no anonymous memory is left).
Sorry for my poor English, thanks for your description, hope it can be into the log
-Roy
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>