public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH v2] f2fs: do not issue small discard commands during checkpoint
Date: Tue, 11 Jul 2023 16:00:25 +0800	[thread overview]
Message-ID: <94b767a3-e768-54d6-3653-90aeaf8edd4a@kernel.org> (raw)
In-Reply-To: <cadfb8d7-f5d0-a3ec-cafb-a0c06ad7d290@kernel.org>

On 2023/7/6 8:46, Chao Yu wrote:
> On 2023/7/6 1:30, Jaegeuk Kim wrote:
>> On 07/04, Chao Yu wrote:
>>> On 2023/7/4 18:53, Jaegeuk Kim wrote:
>>>> On 07/03, Chao Yu wrote:
>>>>> On 2023/6/15 0:10, Jaegeuk Kim wrote:
>>>>>> If there're huge # of small discards, this will increase checkpoint latency
>>>>>> insanely. Let's issue small discards only by trim.
>>>>>>
>>>>>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
>>>>>> ---
>>>>>>
>>>>>>     Change log from v1:
>>>>>>      - move the skip logic to avoid dangling objects
>>>>>>
>>>>>>     fs/f2fs/segment.c | 2 +-
>>>>>>     1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>>>>>> index 8c7af8b4fc47..0457d620011f 100644
>>>>>> --- a/fs/f2fs/segment.c
>>>>>> +++ b/fs/f2fs/segment.c
>>>>>> @@ -2193,7 +2193,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi,
>>>>>>                 len = next_pos - cur_pos;
>>>>>>                 if (f2fs_sb_has_blkzoned(sbi) ||
>>>>>> -                (force && len < cpc->trim_minlen))
>>>>>> +                    !force || len < cpc->trim_minlen)
>>>>>>                     goto skip;
>>>>>
>>>>> Sorry for late reply.
>>>>>
>>>>> We have a configuration for such case, what do you think of setting
>>>>> max_small_discards to zero? otherwise, w/ above change, max_small_discards
>>>>> logic may be broken?
>>>>>
>>>>> What:           /sys/fs/f2fs/<disk>/max_small_discards
>>>>> Date:           November 2013
>>>>> Contact:        "Jaegeuk Kim" <jaegeuk.kim@samsung.com>
>>>>> Description:    Controls the issue rate of discard commands that consist of small
>>>>>                   blocks less than 2MB. The candidates to be discarded are cached until
>>>>>                   checkpoint is triggered, and issued during the checkpoint.
>>>>>                   By default, it is disabled with 0.
>>>>>
>>>>> Or, if we prefer to disable small_discards by default, what about below change:
>>>>
>>>> I think small_discards is fine, but need to avoid long checkpoint latency only.
>>>
>>> I didn't get you, do you mean we can still issue small discard by
>>> fstrim, so small_discards functionality is fine?
>>
>> You got the point.
> 
> Well, actually, what I mean is max_small_discards sysfs entry's functionality
> is broken. Now, the entry can not be used to control number of small discards
> committed by checkpoint.
> 
> I think there is another way to achieve "avoid long checkpoint latency caused
> by committing huge # of small discards", the way is we can set max_small_discards
> to small value or zero, w/ such configuration, it will take checkpoint much less
> time or no time to committing small discard due to below control logic:

Jaegeuk, any comments?

Thanks,

> 
> f2fs_flush_sit_entries()
> {
> ...
>              if (!(cpc->reason & CP_DISCARD)) {
>                  cpc->trim_start = segno;
>                  add_discard_addrs(sbi, cpc, false);
>              }
> ...
> }
> 
> add_discard_addrs()
> {
> ...
>      while (force || SM_I(sbi)->dcc_info->nr_discards <=
>                  SM_I(sbi)->dcc_info->max_discards) {
> 
> It will break the loop once nr_discards is larger than max_discards, if
> max_discards is set to zero, checkpoint won't take time to handle small discards.
> 
> ...
>          if (!de) {
>              de = f2fs_kmem_cache_alloc(discard_entry_slab,
>                          GFP_F2FS_ZERO, true, NULL);
>              de->start_blkaddr = START_BLOCK(sbi, cpc->trim_start);
>              list_add_tail(&de->list, head);
>          }
> ...
>      }
> ...
> 
> Thanks,
> 
>>
>>>
>>> Thanks,
>>>
>>>>
>>>>>
>>>>>   From eb89d9b56e817e3046d7fa17165b12416f09d456 Mon Sep 17 00:00:00 2001
>>>>> From: Chao Yu <chao@kernel.org>
>>>>> Date: Mon, 3 Jul 2023 09:06:53 +0800
>>>>> Subject: [PATCH] Revert "f2fs: enable small discard by default"
>>>>>
>>>>> This reverts commit d618ebaf0aa83d175658aea5291e0c459d471d39 in order
>>>>> to disable small discard by default, so that if there're huge number of
>>>>> small discards, it will decrease checkpoint's latency obviously.
>>>>>
>>>>> Also, this patch reverts 9ac00e7cef10 ("f2fs: do not issue small discard
>>>>> commands during checkpoint"), due to it breaks small discard feature which
>>>>> may be configured via sysfs entry max_small_discards.
>>>>>
>>>>> Fixes: 9ac00e7cef10 ("f2fs: do not issue small discard commands during checkpoint")
>>>>> Signed-off-by: Chao Yu <chao@kernel.org>
>>>>> ---
>>>>>    fs/f2fs/segment.c | 4 ++--
>>>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>>>>> index 14c822e5c9c9..0a313368f18b 100644
>>>>> --- a/fs/f2fs/segment.c
>>>>> +++ b/fs/f2fs/segment.c
>>>>> @@ -2193,7 +2193,7 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi,
>>>>>                len = next_pos - cur_pos;
>>>>>
>>>>>                if (f2fs_sb_has_blkzoned(sbi) ||
>>>>> -                    !force || len < cpc->trim_minlen)
>>>>> +                (force && len < cpc->trim_minlen))
>>>>>                    goto skip;
>>>>>
>>>>>                f2fs_issue_discard(sbi, entry->start_blkaddr + cur_pos,
>>>>> @@ -2269,7 +2269,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
>>>>>        atomic_set(&dcc->queued_discard, 0);
>>>>>        atomic_set(&dcc->discard_cmd_cnt, 0);
>>>>>        dcc->nr_discards = 0;
>>>>> -    dcc->max_discards = MAIN_SEGS(sbi) << sbi->log_blocks_per_seg;
>>>>> +    dcc->max_discards = 0;
>>>>>        dcc->max_discard_request = DEF_MAX_DISCARD_REQUEST;
>>>>>        dcc->min_discard_issue_time = DEF_MIN_DISCARD_ISSUE_TIME;
>>>>>        dcc->mid_discard_issue_time = DEF_MID_DISCARD_ISSUE_TIME;
>>>>> -- 
>>>>> 2.40.1
>>>>>
>>>>>
>>>>>
>>>>>>                 f2fs_issue_discard(sbi, entry->start_blkaddr + cur_pos,
> 
> 
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2023-07-11  8:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230613204109epcas2p158ecc100d3fe2db1ab2b7ee8335d01e7@epcms2p4>
2023-06-13 20:39 ` [PATCH] f2fs: do not issue small discard commands during checkpoint Jaegeuk Kim
2023-06-14  6:07   ` [f2fs-dev] " Daejun Park
2023-06-14 16:12     ` Jaegeuk Kim
2023-06-14 16:10   ` [PATCH v2] " Jaegeuk Kim
2023-07-03  1:27     ` [f2fs-dev] " Chao Yu
2023-07-04 10:53       ` Jaegeuk Kim
2023-07-04 14:58         ` Chao Yu
2023-07-05 17:30           ` Jaegeuk Kim
2023-07-06  0:46             ` Chao Yu
2023-07-11  8:00               ` Chao Yu [this message]
2023-07-11 16:37               ` Jaegeuk Kim
2023-07-12  1:33                 ` Chao Yu
2023-07-12 15:55                   ` Jaegeuk Kim
2023-07-13  1:31                     ` Chao Yu
2023-07-18  3:57                       ` Chao Yu
2023-07-21 20:23                       ` Jaegeuk Kim
2023-07-25 13:18                         ` Chao Yu
2023-08-04 20:52                           ` Jaegeuk Kim
2023-08-07  2:21                             ` Chao Yu
2023-08-07 19:55                               ` Jaegeuk Kim
2023-08-08  0:50                                 ` Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=94b767a3-e768-54d6-3653-90aeaf8edd4a@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox