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. > 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