* [PATCH][V2] mm: memcontrol: fix the margin computation in mem_cgroup_margin
@ 2016-05-24 5:37 roy.qing.li
2016-05-25 15:51 ` Michal Hocko
0 siblings, 1 reply; 3+ messages in thread
From: roy.qing.li @ 2016-05-24 5:37 UTC (permalink / raw)
To: cgroups, linux-mm; +Cc: hannes, mhocko, vdavydov
From: Li RongQing <roy.qing.li@gmail.com>
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.
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Acked-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Cc: Michal Hocko <mhocko@suse.com>
---
mm/memcontrol.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 00981d2..12aaadd 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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;
--
2.1.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][V2] mm: memcontrol: fix the margin computation in mem_cgroup_margin
2016-05-24 5:37 [PATCH][V2] mm: memcontrol: fix the margin computation in mem_cgroup_margin roy.qing.li
@ 2016-05-25 15:51 ` Michal Hocko
2016-05-26 1:28 ` Li RongQing
0 siblings, 1 reply; 3+ messages in thread
From: Michal Hocko @ 2016-05-25 15:51 UTC (permalink / raw)
To: roy.qing.li; +Cc: cgroups, linux-mm, hannes, vdavydov
On Tue 24-05-16 13:37:46, roy.qing.li@gmail.com wrote:
> From: Li RongQing <roy.qing.li@gmail.com>
>
> 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.
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).
"
>
> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
> Acked-by: Vladimir Davydov <vdavydov@virtuozzo.com>
> Cc: Michal Hocko <mhocko@suse.com>
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/memcontrol.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 00981d2..12aaadd 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -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;
> --
> 2.1.4
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][V2] mm: memcontrol: fix the margin computation in mem_cgroup_margin
2016-05-25 15:51 ` Michal Hocko
@ 2016-05-26 1:28 ` Li RongQing
0 siblings, 0 replies; 3+ messages in thread
From: Li RongQing @ 2016-05-26 1:28 UTC (permalink / raw)
To: Michal Hocko; +Cc: cgroups, linux-mm, Johannes Weiner, Vladimir Davydov
On Wed, May 25, 2016 at 11:51 PM, Michal Hocko <mhocko@kernel.org> wrote:
> 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).
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 majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-05-26 1:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-24 5:37 [PATCH][V2] mm: memcontrol: fix the margin computation in mem_cgroup_margin roy.qing.li
2016-05-25 15:51 ` Michal Hocko
2016-05-26 1:28 ` Li RongQing
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).