mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Zhiguo Niu <niuzhiguo84@gmail.com>
Cc: Chao Yu <chao@kernel.org>,
	jaegeuk@kernel.org, Xiuhong Wang <xiuhong.wang@unisoc.com>,
	Zhiguo Niu <zhiguo.niu@unisoc.com>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 2/2] f2fs: add a sysfs node to limit max read extent count per-inode
Date: Fri, 22 Nov 2024 14:17:04 +0800	[thread overview]
Message-ID: <c144fed9-89f6-48c3-9365-bb24260a661d@kernel.org> (raw)
In-Reply-To: <CAHJ8P3LhPzmzf-tgiwSh+a+W+EC7pFE9+=RqkHL1543cHMag2w@mail.gmail.com>

On 2024/11/22 13:23, Zhiguo Niu wrote:
> Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
> 于2024年11月21日周四 10:01写道:
>>
>> Quoted:
>> "at this time, there are still 1086911 extent nodes in this zombie
>> extent tree that need to be cleaned up.
>>
>> crash_arm64_sprd_v8.0.3++> extent_tree.node_cnt ffffff80896cc500
>>    node_cnt = {
>>      counter = 1086911
>>    },
>> "
>>
>> As reported by Xiuhong, there will be a huge number of extent nodes
>> in extent tree, it may potentially cause:
>> - slab memory fragments
>> - extreme long time shrink on extent tree
>> - low mapping efficiency
>>
>> Let's add a sysfs node to limit max read extent count for each inode,
>> by default, value of this threshold is 10240, it can be updated
>> according to user's requirement.
>>
>> Reported-by: Xiuhong Wang <xiuhong.wang@unisoc.com>
>> Closes: https://lore.kernel.org/linux-f2fs-devel/20241112110627.1314632-1-xiuhong.wang@unisoc.com/
>> Signed-off-by: Xiuhong Wang <xiuhong.wang@unisoc.com>
>> Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>>   Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++
>>   fs/f2fs/extent_cache.c                  | 5 ++++-
>>   fs/f2fs/f2fs.h                          | 4 ++++
>>   fs/f2fs/sysfs.c                         | 7 +++++++
>>   4 files changed, 21 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
>> index 513296bb6f29..3e1630c70d8a 100644
>> --- a/Documentation/ABI/testing/sysfs-fs-f2fs
>> +++ b/Documentation/ABI/testing/sysfs-fs-f2fs
>> @@ -822,3 +822,9 @@ Description:        It controls the valid block ratio threshold not to trigger excessiv
>>                  for zoned deivces. The initial value of it is 95(%). F2FS will stop the
>>                  background GC thread from intiating GC for sections having valid blocks
>>                  exceeding the ratio.
>> +
>> +What:          /sys/fs/f2fs/<disk>/max_read_extent_count
>> +Date:          November 2024
>> +Contact:       "Chao Yu" <chao@kernel.org>
>> +Description:   It controls max read extent count for per-inode, the value of threshold
>> +               is 10240 by default.
>> diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
>> index b7a6817b44b0..347b3b647834 100644
>> --- a/fs/f2fs/extent_cache.c
>> +++ b/fs/f2fs/extent_cache.c
>> @@ -717,7 +717,9 @@ static void __update_extent_tree_range(struct inode *inode,
>>                  }
>>
>>                  if (end < org_end && (type != EX_READ ||
>> -                               org_end - end >= F2FS_MIN_EXTENT_LEN)) {
>> +                       (org_end - end >= F2FS_MIN_EXTENT_LEN &&
>> +                       atomic_read(&et->node_cnt) <
>> +                                       sbi->max_read_extent_count))) {
>>                          if (parts) {
>>                                  __set_extent_info(&ei,
>>                                          end, org_end - end,
>> @@ -1212,6 +1214,7 @@ void f2fs_init_extent_cache_info(struct f2fs_sb_info *sbi)
>>          sbi->hot_data_age_threshold = DEF_HOT_DATA_AGE_THRESHOLD;
>>          sbi->warm_data_age_threshold = DEF_WARM_DATA_AGE_THRESHOLD;
>>          sbi->last_age_weight = LAST_AGE_WEIGHT;
>> +       sbi->max_read_extent_count = DEF_MAX_READ_EXTENT_COUNT;
>>   }
>>
>>   int __init f2fs_create_extent_cache(void)
>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
>> index b65b023a588a..6f2cbf4c5740 100644
>> --- a/fs/f2fs/f2fs.h
>> +++ b/fs/f2fs/f2fs.h
>> @@ -635,6 +635,9 @@ enum {
>>   #define DEF_HOT_DATA_AGE_THRESHOLD     262144
>>   #define DEF_WARM_DATA_AGE_THRESHOLD    2621440
>>
>> +/* default max read extent count per inode */
>> +#define DEF_MAX_READ_EXTENT_COUNT      10240
>> +
>>   /* extent cache type */
>>   enum extent_type {
>>          EX_READ,
>> @@ -1619,6 +1622,7 @@ struct f2fs_sb_info {
>>          /* for extent tree cache */
>>          struct extent_tree_info extent_tree[NR_EXTENT_CACHES];
>>          atomic64_t allocated_data_blocks;       /* for block age extent_cache */
>> +       unsigned int max_read_extent_count;     /* max read extent count per inode */
>>
>>          /* The threshold used for hot and warm data seperation*/
>>          unsigned int hot_data_age_threshold;
>> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
>> index bdbf24db667b..d1356c656cac 100644
>> --- a/fs/f2fs/sysfs.c
>> +++ b/fs/f2fs/sysfs.c
>> @@ -787,6 +787,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
>>                  return count;
>>          }
>>
>> +       if (!strcmp(a->attr.name, "max_read_extent_count")) {
>> +               if (t > UINT_MAX)
>> +                       return -EINVAL;
>> +               *ui = (unsigned int)t;
>> +               return count;
>> +       }
>> +
> Hi Chao,
> from Xiuhong remider, it seems miss codes of adding sysfs node
> "max_read_extent_count"?
> F2FS_SBI_GENERAL_RW_ATTR(max_read_extent_count);
> ATTR_LIST(max_read_extent_count);

Oops, let me fix this soon.

Thanks,

> thanks!
>>          if (!strcmp(a->attr.name, "ipu_policy")) {
>>                  if (t >= BIT(F2FS_IPU_MAX))
>>                          return -EINVAL;
>> --
>> 2.40.1
>>
>>
>>
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> Linux-f2fs-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


      reply	other threads:[~2024-11-22  6:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-21  1:57 [PATCH 1/2] f2fs: fix to shrink read extent node in batches Chao Yu
2024-11-21  1:57 ` [PATCH 2/2] f2fs: add a sysfs node to limit max read extent count per-inode Chao Yu
2024-11-22  5:23   ` [f2fs-dev] " Zhiguo Niu
2024-11-22  6:17     ` Chao Yu [this message]

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=c144fed9-89f6-48c3-9365-bb24260a661d@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=niuzhiguo84@gmail.com \
    --cc=xiuhong.wang@unisoc.com \
    --cc=zhiguo.niu@unisoc.com \
    /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

all inboxes | Powered by JetHome®