Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4625434imm; Tue, 11 Sep 2018 15:10:34 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdat8x/HQPo9mHqas24eDgfbjdEcKNmSFKJx6gLkLGooqBo6H1let/+9jXInBBXuFQkrxnQU X-Received: by 2002:a63:9e0a:: with SMTP id s10-v6mr30938883pgd.326.1536703833995; Tue, 11 Sep 2018 15:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536703833; cv=none; d=google.com; s=arc-20160816; b=qXUXlkDU2kXmPUFd6fn/vp0ZqIMT5Y/DgbYZLgCzRKWgEAIAE15gDY2tqKsuc3KPum q6OjCelEihQYcruyota+iBgnzJs4byN2YFxsU8zHsTJU5LM08Lwy05VuWEQUPsQssbk4 XAx0zaUd6HJGR4WAmGq0hXpRtQjlnXj4/j6YkfDuXjpU9mo2PKGMR+QZmIVoL8g1FkMO wh8CDqJYuKquSW40B4fjeFGLbnB3vBp1cDevN4BNBnRiHL64Y6d678pt7Khl82GDZq75 EGp4IoGA4CJ4YAeFVUlExz2T9zeZZ4tiIBot/7jNbsyEMWDDaEIrAUu7H9s6bmUiZgtp fw7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=8XgiR3ABsS7LAMGQ0NVLNQDIlFKDC781F9Nyj+/hiYY=; b=YoJ/w6sqSgewqCpbLO6udlswBU9Dv2b2wXn3Eo24GmuZYz4NI5hUEX4J/rbTCPKXmQ Mb696MKuwmUb3TgpEUcC/POCADUdD1XcwKpWq8A6iZxLPUzQ5qp03kTtnU8pGinVYu/A l8+nVpv5uSMQilcHeOsA+BbnksRh18QoO8diAVYzYhjzx0h13Qad+aZKY6I7JmpWcYe+ fA4VapOVB+WyHiLwH5Y+TMSurLIYvyv+sNXsbCEeyEDqE5WxXSF2xSZ/GK7jGYdwA5A3 3TZVFJdX1EQTuf3tXMuFxdd6r94vwdfJJJ/QpvihaK7qD3jEZ9BcReRo4y3MslzFNAq6 kr+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=120kHR6Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22-v6si21289492pgi.111.2018.09.11.15.10.18; Tue, 11 Sep 2018 15:10:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=120kHR6Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728244AbeILDLV (ORCPT + 99 others); Tue, 11 Sep 2018 23:11:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:46852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727796AbeILDLV (ORCPT ); Tue, 11 Sep 2018 23:11:21 -0400 Received: from localhost (unknown [104.132.1.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 455C220866; Tue, 11 Sep 2018 22:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536703799; bh=J60I/VCINHhiZISwfIte2VHfUr50qLSGOrPTOewuQfU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=120kHR6Qkiv8SbEEomSjkB9dEvivP1dBxUq3K0yEf03RdURR8CphoE4sMHIfplKLe jd5Nh6j0OyUgbq1mMr/T8lun/88nbj9KJO+KhuagMHdZ6bhtIHJMHZTUoHRQZkfNZ0 dN72U++C8gG4fze6hyfJon4csJnDmzM/2m9KZXXg= Date: Tue, 11 Sep 2018 15:09:58 -0700 From: Jaegeuk Kim To: Chao Yu Cc: Sahitya Tummala , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [f2fs-dev] [PATCH v2] f2fs: add new idle interval timing for discard and gc paths Message-ID: <20180911220958.GC55456@jaegeuk-macbookpro.roam.corp.google.com> References: <1536551252-24256-1-git-send-email-stummala@codeaurora.org> <5d74d46b-8141-f048-9c0a-459c82b2c449@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5d74d46b-8141-f048-9c0a-459c82b2c449@kernel.org> User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/11, Chao Yu wrote: > On 2018/9/10 11:47, Sahitya Tummala wrote: > > This helps to control the frequency of submission of discard and > > GC requests independently, based on the need. The sleep timing of > > GC thread is now aligned with this idle time when the dev is busy, > > to avoid unnecessary periodic wakeups. > > > > Suggested-by: Chao Yu > > Signed-off-by: Sahitya Tummala > > --- > > v2: > > -fix __issue_discard_cmd_orderly() path > > > > Documentation/ABI/testing/sysfs-fs-f2fs | 17 ++++++++++++++++- > > fs/f2fs/f2fs.h | 31 +++++++++++++++++++++++++++---- > > fs/f2fs/gc.c | 6 ++++-- > > fs/f2fs/segment.c | 16 ++++++---------- > > fs/f2fs/super.c | 2 ++ > > fs/f2fs/sysfs.c | 5 +++++ > > 6 files changed, 60 insertions(+), 17 deletions(-) > > > > diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs > > index 94a24ae..3ac4177 100644 > > --- a/Documentation/ABI/testing/sysfs-fs-f2fs > > +++ b/Documentation/ABI/testing/sysfs-fs-f2fs > > @@ -121,7 +121,22 @@ What: /sys/fs/f2fs//idle_interval > > Date: January 2016 > > Contact: "Jaegeuk Kim" > > Description: > > - Controls the idle timing. > > + Controls the idle timing for all paths other than > > + discard and gc path. > > + > > +What: /sys/fs/f2fs//discard_idle_interval > > +Date: September 2018 > > +Contact: "Chao Yu" > > +Contact: "Sahitya Tummala" > > +Description: > > + Controls the idle timing for discard path. > > + > > +What: /sys/fs/f2fs//gc_idle_interval > > +Date: September 2018 > > +Contact: "Chao Yu" > > +Contact: "Sahitya Tummala" > > +Description: > > + Controls the idle timing for gc path. > > > > What: /sys/fs/f2fs//iostat_enable > > Date: August 2017 > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > > index abf9256..6070681 100644 > > --- a/fs/f2fs/f2fs.h > > +++ b/fs/f2fs/f2fs.h > > @@ -1093,6 +1093,8 @@ enum { > > enum { > > CP_TIME, > > REQ_TIME, > > + DISCARD_TIME, > > + GC_TIME, > > MAX_TIME, > > }; > > > > @@ -1347,14 +1349,35 @@ static inline void f2fs_update_time(struct f2fs_sb_info *sbi, int type) > > sbi->last_time[type] = jiffies; > > } > > > > -static inline bool f2fs_time_over(struct f2fs_sb_info *sbi, int type) > > +static inline bool f2fs_time_over_cp(struct f2fs_sb_info *sbi) I don't see why we need this separately. > > +{ > > + unsigned long interval = sbi->interval_time[CP_TIME] * HZ; > > + > > + return time_after(jiffies, sbi->last_time[CP_TIME] + interval); > > +} > > + > > +static inline bool f2fs_time_over_req(struct f2fs_sb_info *sbi, int type) > > +{ > > + unsigned long interval = sbi->interval_time[type] * HZ; > > + > > + return time_after(jiffies, sbi->last_time[REQ_TIME] + interval); > > +} > > + > > +static inline unsigned int f2fs_get_wait_time(struct f2fs_sb_info *sbi, > > + int type) f2fs_time_to_wait()? > > { > > unsigned long interval = sbi->interval_time[type] * HZ; > > + unsigned int wait_ms = 0; > > + long delta; > > + > > + delta = (sbi->last_time[REQ_TIME] + interval) - jiffies; > > + if (delta > 0) > > + wait_ms = jiffies_to_msecs(delta); > > > > - return time_after(jiffies, sbi->last_time[type] + interval); > > + return wait_ms; > > } > > > > -static inline bool is_idle(struct f2fs_sb_info *sbi) > > +static inline bool is_idle(struct f2fs_sb_info *sbi, int type) > > { > > struct block_device *bdev = sbi->sb->s_bdev; > > struct request_queue *q = bdev_get_queue(bdev); > > @@ -1363,7 +1386,7 @@ static inline bool is_idle(struct f2fs_sb_info *sbi) > > if (rl->count[BLK_RW_SYNC] || rl->count[BLK_RW_ASYNC]) > > return false; > > > > - return f2fs_time_over(sbi, REQ_TIME); > > + return f2fs_time_over_req(sbi, type); > > } > > > > /* > > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c > > index 5c8d004..c0bafea 100644 > > --- a/fs/f2fs/gc.c > > +++ b/fs/f2fs/gc.c > > @@ -83,8 +83,10 @@ static int gc_thread_func(void *data) > > if (!mutex_trylock(&sbi->gc_mutex)) > > goto next; > > > > - if (!is_idle(sbi)) { > > - increase_sleep_time(gc_th, &wait_ms); > > + if (!is_idle(sbi, GC_TIME)) { > > + wait_ms = f2fs_get_wait_time(sbi, GC_TIME); > > It seems this patch changes the method of increasing wait_ms here, if device is > busy, we may wake up GC thread earlier than before, not sure we should do this. > > To Jaegeuk, how do you think of this? Yes, please let us discuss this in another patch. > > Thanks, > > > + if (!wait_ms) > > + increase_sleep_time(gc_th, &wait_ms); > > mutex_unlock(&sbi->gc_mutex); > > goto next; > > } > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > > index c5024f8..2d15733 100644 > > --- a/fs/f2fs/segment.c > > +++ b/fs/f2fs/segment.c > > @@ -511,7 +511,7 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi) > > else > > f2fs_build_free_nids(sbi, false, false); > > > > - if (!is_idle(sbi) && > > + if (!is_idle(sbi, REQ_TIME) && > > (!excess_dirty_nats(sbi) && !excess_dirty_nodes(sbi))) > > return; > > > > @@ -521,7 +521,7 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi) > > excess_prefree_segs(sbi) || > > excess_dirty_nats(sbi) || > > excess_dirty_nodes(sbi) || > > - f2fs_time_over(sbi, CP_TIME)) { > > + f2fs_time_over_cp(sbi)) { > > if (test_opt(sbi, DATA_FLUSH)) { > > struct blk_plug plug; > > > > @@ -1311,7 +1311,7 @@ static unsigned int __issue_discard_cmd_orderly(struct f2fs_sb_info *sbi, > > if (dc->state != D_PREP) > > goto next; > > > > - if (dpolicy->io_aware && !is_idle(sbi)) { > > + if (dpolicy->io_aware && !is_idle(sbi, DISCARD_TIME)) { > > io_interrupted = true; > > break; > > } > > @@ -1371,7 +1371,7 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, > > f2fs_bug_on(sbi, dc->state != D_PREP); > > > > if (dpolicy->io_aware && i < dpolicy->io_aware_gran && > > - !is_idle(sbi)) { > > + !is_idle(sbi, DISCARD_TIME)) { > > io_interrupted = true; > > break; > > } > > @@ -1564,8 +1564,6 @@ static int issue_discard_thread(void *data) > > struct discard_policy dpolicy; > > unsigned int wait_ms = DEF_MIN_DISCARD_ISSUE_TIME; > > int issued; > > - unsigned long interval = sbi->interval_time[REQ_TIME] * HZ; > > - long delta; > > > > set_freezable(); > > > > @@ -1602,10 +1600,8 @@ static int issue_discard_thread(void *data) > > __wait_all_discard_cmd(sbi, &dpolicy); > > wait_ms = dpolicy.min_interval; > > } else if (issued == -1){ > > - delta = (sbi->last_time[REQ_TIME] + interval) - jiffies; > > - if (delta > 0) > > - wait_ms = jiffies_to_msecs(delta); > > - else > > + wait_ms = f2fs_get_wait_time(sbi, DISCARD_TIME); > > + if (!wait_ms) > > wait_ms = dpolicy.mid_interval; > > } else { > > wait_ms = dpolicy.max_interval; > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > > index 896b885..1706f45 100644 > > --- a/fs/f2fs/super.c > > +++ b/fs/f2fs/super.c > > @@ -2423,6 +2423,8 @@ static void init_sb_info(struct f2fs_sb_info *sbi) > > sbi->dir_level = DEF_DIR_LEVEL; > > sbi->interval_time[CP_TIME] = DEF_CP_INTERVAL; > > sbi->interval_time[REQ_TIME] = DEF_IDLE_INTERVAL; > > + sbi->interval_time[DISCARD_TIME] = DEF_IDLE_INTERVAL; > > + sbi->interval_time[GC_TIME] = DEF_IDLE_INTERVAL; > > clear_sbi_flag(sbi, SBI_NEED_FSCK); > > > > for (i = 0; i < NR_COUNT_TYPE; i++) > > diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c > > index 81c0e53..0afe99c 100644 > > --- a/fs/f2fs/sysfs.c > > +++ b/fs/f2fs/sysfs.c > > @@ -407,6 +407,9 @@ static ssize_t f2fs_feature_show(struct f2fs_attr *a, > > F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level); > > F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, cp_interval, interval_time[CP_TIME]); > > F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, idle_interval, interval_time[REQ_TIME]); > > +F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, discard_idle_interval, > > + interval_time[DISCARD_TIME]); > > +F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_idle_interval, interval_time[GC_TIME]); > > F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, iostat_enable, iostat_enable); > > F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, readdir_ra, readdir_ra); > > F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_pin_file_thresh, gc_pin_file_threshold); > > @@ -460,6 +463,8 @@ static ssize_t f2fs_feature_show(struct f2fs_attr *a, > > ATTR_LIST(dirty_nats_ratio), > > ATTR_LIST(cp_interval), > > ATTR_LIST(idle_interval), > > + ATTR_LIST(discard_idle_interval), > > + ATTR_LIST(gc_idle_interval), > > ATTR_LIST(iostat_enable), > > ATTR_LIST(readdir_ra), > > ATTR_LIST(gc_pin_file_thresh), > >