From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gu Zheng Subject: Re: [PATCH 2/3] f2fs: add sysfs entries to select the gc policy Date: Mon, 05 Aug 2013 10:00:13 +0800 Message-ID: <51FF072D.80806@cn.fujitsu.com> References: <1375625415-2835-1-git-send-email-linkinjeon@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1V6A9h-0000fo-Pa for linux-f2fs-devel@lists.sourceforge.net; Mon, 05 Aug 2013 02:04:17 +0000 Received: from [222.73.24.84] (helo=song.cn.fujitsu.com) by sog-mx-4.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1V6A9f-0003M4-H2 for linux-f2fs-devel@lists.sourceforge.net; Mon, 05 Aug 2013 02:04:17 +0000 In-Reply-To: <1375625415-2835-1-git-send-email-linkinjeon@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: Namjae Jeon Cc: Namjae Jeon , Pankaj Kumar , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net On 08/04/2013 10:10 PM, Namjae Jeon wrote: > From: Namjae Jeon > > Add sysfs entry gc_idle to control the gc policy. Where > gc_idle = 1 corresponds to selecting a cost benefit approach, > while gc_idle = 2 corresponds to selecting a greedy approach > to garbage collection. The selection is mutually exclusive one > approach will work at any point. If gc_idle = 0, then this > option is disabled. > > Cc: Gu Zheng > Signed-off-by: Namjae Jeon > Signed-off-by: Pankaj Kumar Reviewed-by: Gu Zheng > --- > Documentation/ABI/testing/sysfs-fs-f2fs | 6 +++++- > Documentation/filesystems/f2fs.txt | 6 ++++++ > fs/f2fs/gc.c | 24 +++++++++++++++++++++--- > fs/f2fs/gc.h | 3 +++ > fs/f2fs/super.c | 2 ++ > 5 files changed, 37 insertions(+), 4 deletions(-) > > diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs > index 5f44095..31942ef 100644 > --- a/Documentation/ABI/testing/sysfs-fs-f2fs > +++ b/Documentation/ABI/testing/sysfs-fs-f2fs > @@ -19,4 +19,8 @@ Description: > Controls the default sleep time for gc_thread. Time > is in milliseconds. > > - > +What: /sys/fs/f2fs//gc_idle > +Date: July 2013 > +Contact: "Namjae Jeon" > +Description: > + Controls the victim selection policy for garbage collection. > diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt > index 5daf3bb..3cd27be 100644 > --- a/Documentation/filesystems/f2fs.txt > +++ b/Documentation/filesystems/f2fs.txt > @@ -158,6 +158,12 @@ Files in /sys/fs/f2fs/ > time for the garbage collection thread. Time is > in milliseconds. > > + gc_idle This parameter controls the selection of victim > + policy for garbage collection. Setting gc_idle = 0 > + (default) will disable this option. Setting > + gc_idle = 1 will select the Cost Benefit approach > + & setting gc_idle = 2 will select the greedy aproach. > + > ================================================================================ > USAGE > ================================================================================ > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c > index 60d4f67..2c0c8ad 100644 > --- a/fs/f2fs/gc.c > +++ b/fs/f2fs/gc.c > @@ -106,6 +106,8 @@ int start_gc_thread(struct f2fs_sb_info *sbi) > gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME; > gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME; > > + gc_th->gc_idle = 0; > + > sbi->gc_thread = gc_th; > init_waitqueue_head(&sbi->gc_thread->gc_wait_queue_head); > sbi->gc_thread->f2fs_gc_task = kthread_run(gc_thread_func, sbi, > @@ -130,9 +132,25 @@ void stop_gc_thread(struct f2fs_sb_info *sbi) > sbi->gc_thread = NULL; > } > > -static int select_gc_type(int gc_type) > +static int select_gc_type(struct f2fs_gc_kthread *gc_th, int gc_type) > { > - return (gc_type == BG_GC) ? GC_CB : GC_GREEDY; > + int gc_mode; > + > + if (gc_th && gc_th->gc_idle) { > + /* Cost Benefit Policy */ > + if (gc_th->gc_idle == 1) { > + gc_mode = GC_CB; > + goto out; > + } else if (gc_th->gc_idle == 2) { > + /* Greedy Policy */ > + gc_mode = GC_GREEDY; > + goto out; > + } > + } > + > + gc_mode = (gc_type == BG_GC) ? GC_CB : GC_GREEDY; > +out: > + return gc_mode; > } > > static void select_policy(struct f2fs_sb_info *sbi, int gc_type, > @@ -145,7 +163,7 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type, > p->dirty_segmap = dirty_i->dirty_segmap[type]; > p->ofs_unit = 1; > } else { > - p->gc_mode = select_gc_type(gc_type); > + p->gc_mode = select_gc_type(sbi->gc_thread, gc_type); > p->dirty_segmap = dirty_i->dirty_segmap[DIRTY]; > p->ofs_unit = sbi->segs_per_sec; > } > diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h > index f4bf44c..c22dee9 100644 > --- a/fs/f2fs/gc.h > +++ b/fs/f2fs/gc.h > @@ -30,6 +30,9 @@ struct f2fs_gc_kthread { > unsigned int min_sleep_time; > unsigned int max_sleep_time; > unsigned int no_gc_sleep_time; > + > + /* for changing gc mode */ > + unsigned int gc_idle; > }; > > struct inode_entry { > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index 0a3e88f..f9c6c0b 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -148,12 +148,14 @@ static struct f2fs_attr f2fs_attr_##_name = { \ > F2FS_RW_ATTR(gc_min_sleep_time, min_sleep_time); > F2FS_RW_ATTR(gc_max_sleep_time, max_sleep_time); > F2FS_RW_ATTR(gc_no_gc_sleep_time, no_gc_sleep_time); > +F2FS_RW_ATTR(gc_idle, gc_idle); > > #define ATTR_LIST(name) (&f2fs_attr_##name.attr) > static struct attribute *f2fs_attrs[] = { > ATTR_LIST(gc_min_sleep_time), > ATTR_LIST(gc_max_sleep_time), > ATTR_LIST(gc_no_gc_sleep_time), > + ATTR_LIST(gc_idle), > NULL, > }; > ------------------------------------------------------------------------------ Get your SQL database under version control now! Version control is standard for application code, but databases havent caught up. So what steps can you take to put your SQL databases under version control? Why should you start doing it? Read more to find out. http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754244Ab3HECEM (ORCPT ); Sun, 4 Aug 2013 22:04:12 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:5378 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754100Ab3HECEL (ORCPT ); Sun, 4 Aug 2013 22:04:11 -0400 X-IronPort-AV: E=Sophos;i="4.89,815,1367942400"; d="scan'208";a="8117008" Message-ID: <51FF072D.80806@cn.fujitsu.com> Date: Mon, 05 Aug 2013 10:00:13 +0800 From: Gu Zheng User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1 MIME-Version: 1.0 To: Namjae Jeon CC: jaegeuk.kim@samsung.com, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Namjae Jeon , Pankaj Kumar Subject: Re: [PATCH 2/3] f2fs: add sysfs entries to select the gc policy References: <1375625415-2835-1-git-send-email-linkinjeon@gmail.com> In-Reply-To: <1375625415-2835-1-git-send-email-linkinjeon@gmail.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/08/05 10:02:48, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/08/05 10:02:49, Serialize complete at 2013/08/05 10:02:49 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/04/2013 10:10 PM, Namjae Jeon wrote: > From: Namjae Jeon > > Add sysfs entry gc_idle to control the gc policy. Where > gc_idle = 1 corresponds to selecting a cost benefit approach, > while gc_idle = 2 corresponds to selecting a greedy approach > to garbage collection. The selection is mutually exclusive one > approach will work at any point. If gc_idle = 0, then this > option is disabled. > > Cc: Gu Zheng > Signed-off-by: Namjae Jeon > Signed-off-by: Pankaj Kumar Reviewed-by: Gu Zheng > --- > Documentation/ABI/testing/sysfs-fs-f2fs | 6 +++++- > Documentation/filesystems/f2fs.txt | 6 ++++++ > fs/f2fs/gc.c | 24 +++++++++++++++++++++--- > fs/f2fs/gc.h | 3 +++ > fs/f2fs/super.c | 2 ++ > 5 files changed, 37 insertions(+), 4 deletions(-) > > diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs > index 5f44095..31942ef 100644 > --- a/Documentation/ABI/testing/sysfs-fs-f2fs > +++ b/Documentation/ABI/testing/sysfs-fs-f2fs > @@ -19,4 +19,8 @@ Description: > Controls the default sleep time for gc_thread. Time > is in milliseconds. > > - > +What: /sys/fs/f2fs//gc_idle > +Date: July 2013 > +Contact: "Namjae Jeon" > +Description: > + Controls the victim selection policy for garbage collection. > diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt > index 5daf3bb..3cd27be 100644 > --- a/Documentation/filesystems/f2fs.txt > +++ b/Documentation/filesystems/f2fs.txt > @@ -158,6 +158,12 @@ Files in /sys/fs/f2fs/ > time for the garbage collection thread. Time is > in milliseconds. > > + gc_idle This parameter controls the selection of victim > + policy for garbage collection. Setting gc_idle = 0 > + (default) will disable this option. Setting > + gc_idle = 1 will select the Cost Benefit approach > + & setting gc_idle = 2 will select the greedy aproach. > + > ================================================================================ > USAGE > ================================================================================ > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c > index 60d4f67..2c0c8ad 100644 > --- a/fs/f2fs/gc.c > +++ b/fs/f2fs/gc.c > @@ -106,6 +106,8 @@ int start_gc_thread(struct f2fs_sb_info *sbi) > gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME; > gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME; > > + gc_th->gc_idle = 0; > + > sbi->gc_thread = gc_th; > init_waitqueue_head(&sbi->gc_thread->gc_wait_queue_head); > sbi->gc_thread->f2fs_gc_task = kthread_run(gc_thread_func, sbi, > @@ -130,9 +132,25 @@ void stop_gc_thread(struct f2fs_sb_info *sbi) > sbi->gc_thread = NULL; > } > > -static int select_gc_type(int gc_type) > +static int select_gc_type(struct f2fs_gc_kthread *gc_th, int gc_type) > { > - return (gc_type == BG_GC) ? GC_CB : GC_GREEDY; > + int gc_mode; > + > + if (gc_th && gc_th->gc_idle) { > + /* Cost Benefit Policy */ > + if (gc_th->gc_idle == 1) { > + gc_mode = GC_CB; > + goto out; > + } else if (gc_th->gc_idle == 2) { > + /* Greedy Policy */ > + gc_mode = GC_GREEDY; > + goto out; > + } > + } > + > + gc_mode = (gc_type == BG_GC) ? GC_CB : GC_GREEDY; > +out: > + return gc_mode; > } > > static void select_policy(struct f2fs_sb_info *sbi, int gc_type, > @@ -145,7 +163,7 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type, > p->dirty_segmap = dirty_i->dirty_segmap[type]; > p->ofs_unit = 1; > } else { > - p->gc_mode = select_gc_type(gc_type); > + p->gc_mode = select_gc_type(sbi->gc_thread, gc_type); > p->dirty_segmap = dirty_i->dirty_segmap[DIRTY]; > p->ofs_unit = sbi->segs_per_sec; > } > diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h > index f4bf44c..c22dee9 100644 > --- a/fs/f2fs/gc.h > +++ b/fs/f2fs/gc.h > @@ -30,6 +30,9 @@ struct f2fs_gc_kthread { > unsigned int min_sleep_time; > unsigned int max_sleep_time; > unsigned int no_gc_sleep_time; > + > + /* for changing gc mode */ > + unsigned int gc_idle; > }; > > struct inode_entry { > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index 0a3e88f..f9c6c0b 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -148,12 +148,14 @@ static struct f2fs_attr f2fs_attr_##_name = { \ > F2FS_RW_ATTR(gc_min_sleep_time, min_sleep_time); > F2FS_RW_ATTR(gc_max_sleep_time, max_sleep_time); > F2FS_RW_ATTR(gc_no_gc_sleep_time, no_gc_sleep_time); > +F2FS_RW_ATTR(gc_idle, gc_idle); > > #define ATTR_LIST(name) (&f2fs_attr_##name.attr) > static struct attribute *f2fs_attrs[] = { > ATTR_LIST(gc_min_sleep_time), > ATTR_LIST(gc_max_sleep_time), > ATTR_LIST(gc_no_gc_sleep_time), > + ATTR_LIST(gc_idle), > NULL, > }; >