[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2AD939572F25A448A3AE3CAEA61328C2374832C1@BC-MAIL-M28.internal.baidu.com>
Date: Fri, 23 Mar 2018 02:58:36 +0000
From: "Li,Rongqing" <lirongqing@...du.com>
To: "Li,Rongqing" <lirongqing@...du.com>,
Michal Hocko <mhocko@...nel.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"cgroups@...r.kernel.org" <cgroups@...r.kernel.org>,
"hannes@...xchg.org" <hannes@...xchg.org>,
"Andrey Ryabinin" <aryabinin@...tuozzo.com>
Subject: 答复: 答复: [PATCH] mm/memcontrol.c: speed up to force empty a memory cgroup
> -----邮件原件-----
> 发件人: linux-kernel-owner@...r.kernel.org
> [mailto:linux-kernel-owner@...r.kernel.org] 代表 Li,Rongqing
> 发送时间: 2018年3月19日 18:52
> 收件人: Michal Hocko <mhocko@...nel.org>
> 抄送: linux-kernel@...r.kernel.org; linux-mm@...ck.org;
> cgroups@...r.kernel.org; hannes@...xchg.org; Andrey Ryabinin
> <aryabinin@...tuozzo.com>
> 主题: 答复: 答复: [PATCH] mm/memcontrol.c: speed up to force empty a
> memory cgroup
>
>
>
> > -----邮件原件-----
> > 发件人: Michal Hocko [mailto:mhocko@...nel.org]
> > 发送时间: 2018年3月19日 18:38
> > 收件人: Li,Rongqing <lirongqing@...du.com>
> > 抄送: linux-kernel@...r.kernel.org; linux-mm@...ck.org;
> > cgroups@...r.kernel.org; hannes@...xchg.org; Andrey Ryabinin
> > <aryabinin@...tuozzo.com>
> > 主题: Re: 答复: [PATCH] mm/memcontrol.c: speed up to force empty a
> memory
> > cgroup
> >
> > On Mon 19-03-18 10:00:41, Li,Rongqing wrote:
> > >
> > >
> > > > -----邮件原件-----
> > > > 发件人: Michal Hocko [mailto:mhocko@...nel.org]
> > > > 发送时间: 2018年3月19日 16:54
> > > > 收件人: Li,Rongqing <lirongqing@...du.com>
> > > > 抄送: linux-kernel@...r.kernel.org; linux-mm@...ck.org;
> > > > cgroups@...r.kernel.org; hannes@...xchg.org; Andrey Ryabinin
> > > > <aryabinin@...tuozzo.com>
> > > > 主题: Re: [PATCH] mm/memcontrol.c: speed up to force empty a
> > memory
> > > > cgroup
> > > >
> > > > On Mon 19-03-18 16:29:30, Li RongQing wrote:
> > > > > mem_cgroup_force_empty() tries to free only 32
> > (SWAP_CLUSTER_MAX)
> > > > > pages on each iteration, if a memory cgroup has lots of page
> > > > > cache, it will take many iterations to empty all page cache, so
> > > > > increase the reclaimed number per iteration to speed it up. same
> > > > > as in
> > > > > mem_cgroup_resize_limit()
> > > > >
> > > > > a simple test show:
> > > > >
> > > > > $dd if=aaa of=bbb bs=1k count=3886080
> > > > > $rm -f bbb
> > > > > $time echo
> > 100000000 >/cgroup/memory/test/memory.limit_in_bytes
> > > > >
> > > > > Before: 0m0.252s ===> after: 0m0.178s
> > > >
> > > > Andrey was proposing something similar [1]. My main objection was
> > > > that his approach might lead to over-reclaim. Your approach is
> > > > more conservative because it just increases the batch size. The
> > > > size is still rather arbitrary. Same as SWAP_CLUSTER_MAX but that
> > > > one is a commonly used unit of reclaim in the MM code.
> > > >
> > > > I would be really curious about more detailed explanation why
> > > > having a larger batch yields to a better performance because we
> > > > are doingg SWAP_CLUSTER_MAX batches at the lower reclaim level
> anyway.
> > > >
> > >
> > > Although SWAP_CLUSTER_MAX is used at the lower level, but the call
> > > stack of try_to_free_mem_cgroup_pages is too long, increase the
> > > nr_to_reclaim can reduce times of calling
> > > function[do_try_to_free_pages, shrink_zones, hrink_node ]
> > >
> > > mem_cgroup_resize_limit
> > > --->try_to_free_mem_cgroup_pages: .nr_to_reclaim = max(1024,
> > > --->SWAP_CLUSTER_MAX),
> > > ---> do_try_to_free_pages
> > > ---> shrink_zones
> > > --->shrink_node
> > > ---> shrink_node_memcg
> > > ---> shrink_list <-------loop will happen in this place
> > [times=1024/32]
> > > ---> shrink_page_list
> >
> > Can you actually measure this to be the culprit. Because we should
> > rethink our call path if it is too complicated/deep to perform well.
> > Adding arbitrary batch sizes doesn't sound like a good way to go to me.
>
> Ok, I will try
>
http://pasted.co/4edbcfff
This is result from ftrace graph, it maybe prove that the deep call path leads to low performance.
And when increase reclaiming page in try_to_free_mem_cgroup_pages, it can reduce calling of shrink_slab, which save times, in my cases, page caches occupy most memory, slab is little, but shrink_slab will be called everytime
Mutex_lock 1 us
try_to_free_mem_cgroup_pages
do_try_to_free_pages ! 185.020 us
shrink_node ! 116.529 us
shrink_node_memcg 39.203
shrink_inactive_list 33.960
shrink_slab 72.955
shrink_node 61.502 us
shrink_node_memcg 3.955
shrink_slab 54.296 us
-RongQing
> -RongQing
> > --
> > Michal Hocko
> > SUSE Labs
Powered by blists - more mailing lists