RE: [f2fs-dev][PATCH] f2fs: fix wrong memory footprint statistics in debugfs

From: Chao Yu
Date: Sat Jan 10 2015 - 07:10:41 EST


Hi Jaegeuk,

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@xxxxxxxxxx]
> Sent: Wednesday, January 07, 2015 3:49 AM
> To: Chao Yu
> Cc: Changman Lee; linux-f2fs-devel@xxxxxxxxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [f2fs-dev][PATCH] f2fs: fix wrong memory footprint statistics in debugfs
>
> Hi Chao,
>
> On Tue, Jan 06, 2015 at 04:40:49PM +0800, Chao Yu wrote:
> > Our value of memory footprint statistics showed in debugfs is not calculated
> > correctly. Fix it in this patch.
> >
> > Signed-off-by: Chao Yu <chao2.yu@xxxxxxxxxxx>
> > ---
> > fs/f2fs/debug.c | 15 ++++++++++-----
> > 1 file changed, 10 insertions(+), 5 deletions(-)
> >
> > diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
> > index dd7835b..6aeaf46 100644
> > --- a/fs/f2fs/debug.c
> > +++ b/fs/f2fs/debug.c
> > @@ -125,7 +125,7 @@ static void update_mem_info(struct f2fs_sb_info *sbi)
> > int i;
> >
> > if (si->base_mem)
> > - goto get_cache;
> > + goto get_dynamic_cache;
> >
> > si->base_mem = sizeof(struct f2fs_sb_info) + sbi->sb->s_blocksize;
> > si->base_mem += 2 * sizeof(struct f2fs_inode_info);
> > @@ -161,13 +161,18 @@ static void update_mem_info(struct f2fs_sb_info *sbi)
> > si->base_mem += sizeof(struct f2fs_nm_info);
> > si->base_mem += __bitmap_size(sbi, NAT_BITMAP);
> >
> > +get_dynamic_cache:
> > /* build gc */
> > - si->base_mem += sizeof(struct f2fs_gc_kthread);
> > + if (sbi->gc_thread)
> > + si->base_mem += sizeof(struct f2fs_gc_kthread);
> > +
> > + /* build merge flush thread */
> > + if (SM_I(sbi)->cmd_control_info)
> > + si->base_mem += sizeof(struct flush_cmd_control);
>
> It seems base_mem increases repeatedly?

Right, my mistaken. How about counting memory of these two cache into cache_mem
as following?