* [PATCH] mm: memcontrol: fix the return in mem_cgroup_margin
@ 2016-05-18 7:24 roy.qing.li-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1463556255-31892-1-git-send-email-roy.qing.li-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 8+ messages in thread
From: roy.qing.li-Re5JQEeQqe8AvxtiuMwx3w @ 2016-05-18 7:24 UTC (permalink / raw)
To: cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg
Cc: hannes-druUgvl0LCNAfugRpC6u6w, mhocko-DgEjT+Ai2ygdnm+yROfE0A,
vdavydov-5HdwGun5lf+gSpxsJD1C4w
From: Li RongQing <roy.qing.li-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
when memory+swap is over limit, return 0
Signed-off-by: Li RongQing <roy.qing.li-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
mm/memcontrol.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index fe787f5..e9211c2 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
^ permalink raw reply related [flat|nested] 8+ messages in thread[parent not found: <1463556255-31892-1-git-send-email-roy.qing.li-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] mm: memcontrol: fix the return in mem_cgroup_margin [not found] ` <1463556255-31892-1-git-send-email-roy.qing.li-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2016-05-18 7:32 ` Michal Hocko [not found] ` <20160518073253.GC21654-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org> 0 siblings, 1 reply; 8+ messages in thread From: Michal Hocko @ 2016-05-18 7:32 UTC (permalink / raw) To: roy.qing.li-Re5JQEeQqe8AvxtiuMwx3w Cc: cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg, hannes-druUgvl0LCNAfugRpC6u6w, vdavydov-5HdwGun5lf+gSpxsJD1C4w On Wed 18-05-16 15:24:15, roy.qing.li-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > From: Li RongQing <roy.qing.li-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > when memory+swap is over limit, return 0 > > Signed-off-by: Li RongQing <roy.qing.li-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > mm/memcontrol.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index fe787f5..e9211c2 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; count should always be smaller than memsw.limit (this is a hard limit). Even if we have some temporary breach then the code should work as expected because margin is initialized to 0 and memsw.limit >= limit. Or have you seen any real problem with this code path? -- Michal Hocko SUSE Labs ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <20160518073253.GC21654-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>]
* Re: [PATCH] mm: memcontrol: fix the return in mem_cgroup_margin [not found] ` <20160518073253.GC21654-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org> @ 2016-05-18 7:39 ` Li RongQing 2016-05-19 1:44 ` Li RongQing 1 sibling, 0 replies; 8+ messages in thread From: Li RongQing @ 2016-05-18 7:39 UTC (permalink / raw) To: Michal Hocko Cc: cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg, hannes-druUgvl0LCNAfugRpC6u6w, vdavydov-5HdwGun5lf+gSpxsJD1C4w On Wed, May 18, 2016 at 3:32 PM, Michal Hocko <mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote: > Or have you seen any real problem with this code path? not; I read the codes, think it is more reasonable to set margin to 0 here -Roy ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: memcontrol: fix the return in mem_cgroup_margin [not found] ` <20160518073253.GC21654-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org> 2016-05-18 7:39 ` Li RongQing @ 2016-05-19 1:44 ` Li RongQing 2016-05-23 10:37 ` Vladimir Davydov 1 sibling, 1 reply; 8+ messages in thread From: Li RongQing @ 2016-05-19 1:44 UTC (permalink / raw) To: Michal Hocko Cc: cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg, Johannes Weiner, vdavydov-5HdwGun5lf+gSpxsJD1C4w On Wed, May 18, 2016 at 3:32 PM, Michal Hocko <mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote: > count should always be smaller than memsw.limit (this is a hard limit). > Even if we have some temporary breach then the code should work as > expected because margin is initialized to 0 and memsw.limit >= limit. is it possible for this case? for example memory count is 500, memory limit is 600; the margin is set to 100 firstly, then check memory+swap limit, its count(1100) is bigger than its limit(1000), then the margin 100 is returned wrongly. -Roy ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: memcontrol: fix the return in mem_cgroup_margin 2016-05-19 1:44 ` Li RongQing @ 2016-05-23 10:37 ` Vladimir Davydov 2016-05-23 12:06 ` Michal Hocko 0 siblings, 1 reply; 8+ messages in thread From: Vladimir Davydov @ 2016-05-23 10:37 UTC (permalink / raw) To: Li RongQing; +Cc: Michal Hocko, cgroups, linux-mm, Johannes Weiner On Thu, May 19, 2016 at 09:44:53AM +0800, Li RongQing wrote: > On Wed, May 18, 2016 at 3:32 PM, Michal Hocko <mhocko@kernel.org> wrote: > > count should always be smaller than memsw.limit (this is a hard limit). > > Even if we have some temporary breach then the code should work as > > expected because margin is initialized to 0 and memsw.limit >= limit. > > is it possible for this case? for example > > memory count is 500, memory limit is 600; the margin is set to 100 firstly, > then check memory+swap limit, its count(1100) is bigger than its limit(1000), > then the margin 100 is returned wrongly. I guess it is possible, 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, we might end up looping in try_charge forever. I've never seen that happen in practice, but I still think the patch is worth applying. Acked-by: Vladimir Davydov <vdavydov@virtuozzo.com> -- 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] 8+ messages in thread
* Re: [PATCH] mm: memcontrol: fix the return in mem_cgroup_margin 2016-05-23 10:37 ` Vladimir Davydov @ 2016-05-23 12:06 ` Michal Hocko 2016-05-23 12:08 ` Michal Hocko [not found] ` <20160523120620.GP2278-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org> 0 siblings, 2 replies; 8+ messages in thread From: Michal Hocko @ 2016-05-23 12:06 UTC (permalink / raw) To: Li RongQing; +Cc: Vladimir Davydov, cgroups, linux-mm, Johannes Weiner On Mon 23-05-16 13:37:58, Vladimir Davydov wrote: > On Thu, May 19, 2016 at 09:44:53AM +0800, Li RongQing wrote: > > On Wed, May 18, 2016 at 3:32 PM, Michal Hocko <mhocko@kernel.org> wrote: > > > count should always be smaller than memsw.limit (this is a hard limit). > > > Even if we have some temporary breach then the code should work as > > > expected because margin is initialized to 0 and memsw.limit >= limit. > > > > is it possible for this case? for example > > > > memory count is 500, memory limit is 600; the margin is set to 100 firstly, > > then check memory+swap limit, its count(1100) is bigger than its limit(1000), > > then the margin 100 is returned wrongly. > > I guess it is possible, 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, we > might end up looping in try_charge forever. I've never seen that happen > in practice, but I still think the patch is worth applying. You are right. I have completely missed a potential interaction with __GFP_NOFAIL. We even do not seem to trigger the memcg OOM killer for these requests to sort the situation out. Can we have updated patch with all this useful information in the changelog, please? Thanks Vladimir! -- 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] 8+ messages in thread
* Re: [PATCH] mm: memcontrol: fix the return in mem_cgroup_margin 2016-05-23 12:06 ` Michal Hocko @ 2016-05-23 12:08 ` Michal Hocko [not found] ` <20160523120620.GP2278-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org> 1 sibling, 0 replies; 8+ messages in thread From: Michal Hocko @ 2016-05-23 12:08 UTC (permalink / raw) To: Li RongQing; +Cc: Vladimir Davydov, cgroups, linux-mm, Johannes Weiner On Mon 23-05-16 14:06:20, Michal Hocko wrote: [...] > I have completely missed a potential interaction with > __GFP_NOFAIL. We even do not seem to trigger the memcg OOM killer for > these requests to sort the situation out. Which is intentional. a0d8b00a3381 ("mm: memcg: do not declare OOM from __GFP_NOFAIL allocations") -- 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] 8+ messages in thread
[parent not found: <20160523120620.GP2278-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>]
* Re: [PATCH] mm: memcontrol: fix the return in mem_cgroup_margin [not found] ` <20160523120620.GP2278-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org> @ 2016-05-24 3:07 ` Li RongQing 0 siblings, 0 replies; 8+ messages in thread From: Li RongQing @ 2016-05-24 3:07 UTC (permalink / raw) To: Michal Hocko Cc: Vladimir Davydov, cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg, Johannes Weiner On Mon, May 23, 2016 at 8:06 PM, Michal Hocko <mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote: > > Can we have updated patch with all this useful information in the > changelog, please? Ok, I will update this patch -Roy ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-05-24 3:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-18 7:24 [PATCH] mm: memcontrol: fix the return in mem_cgroup_margin roy.qing.li-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1463556255-31892-1-git-send-email-roy.qing.li-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-05-18 7:32 ` Michal Hocko
[not found] ` <20160518073253.GC21654-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2016-05-18 7:39 ` Li RongQing
2016-05-19 1:44 ` Li RongQing
2016-05-23 10:37 ` Vladimir Davydov
2016-05-23 12:06 ` Michal Hocko
2016-05-23 12:08 ` Michal Hocko
[not found] ` <20160523120620.GP2278-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2016-05-24 3:07 ` Li RongQing
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox