> -----邮件原件----- > 发件人: linux-kernel-owner@xxxxxxxxxxxxxxx > [mailto:linux-kernel-owner@xxxxxxxxxxxxxxx] 代表 Michal Hocko > 发送时间: 2018年3月23日 20:29 > 收件人: Li,Rongqing <lirongqing@xxxxxxxxx> > 抄送: linux-kernel@xxxxxxxxxxxxxxx; linux-mm@xxxxxxxxx; > cgroups@xxxxxxxxxxxxxxx; hannes@xxxxxxxxxxx; Andrey Ryabinin > <aryabinin@xxxxxxxxxxxxx> > 主题: Re: 答复: 答复: 答复: [PATCH] mm/memcontrol.c: speed up to force > empty a memory cgroup > > On Fri 23-03-18 12:04:16, Li,Rongqing wrote: > [...] > > shrink_slab does not reclaim any memory, but take lots of time to > > count lru > > > > maybe we can use the returning of shrink_slab to control if next > > shrink_slab should be called? > > How? Different memcgs might have different amount of shrinkable memory. > maybe there is not a easy way to implement it in this case, shrink_slab call many times list_lru_count_one, which is calling list_lru_count_one, which use spinlock, maybe replace spinlock with RCU, to optimize -RongQing > > Or define a slight list_lru_empty to check if sb->s_dentry_lru is > > empty before calling list_lru_shrink_count, like below > > Does it really help to improve numbers? > > > diff --git a/fs/super.c b/fs/super.c > > index 672538ca9831..954c22338833 100644 > > --- a/fs/super.c > > +++ b/fs/super.c > > @@ -130,8 +130,10 @@ static unsigned long super_cache_count(struct > shrinker *shrink, > > if (sb->s_op && sb->s_op->nr_cached_objects) > > total_objects = sb->s_op->nr_cached_objects(sb, sc); > > > > - total_objects += list_lru_shrink_count(&sb->s_dentry_lru, sc); > > - total_objects += list_lru_shrink_count(&sb->s_inode_lru, sc); > > + if (!list_lru_empty(sb->s_dentry_lru)) > > + total_objects += > list_lru_shrink_count(&sb->s_dentry_lru, sc); > > + if (!list_lru_empty(sb->s_inode_lru)) > > + total_objects += > > + list_lru_shrink_count(&sb->s_inode_lru, sc); > > > > total_objects = vfs_pressure_ratio(total_objects); > > return total_objects; > > -- > Michal Hocko > SUSE Labs