]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
f2fs: sysfs: introduce max_lock_elapsed_time
authorChao Yu <chao@kernel.org>
Sun, 4 Jan 2026 02:07:17 +0000 (10:07 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 7 Jan 2026 03:17:06 +0000 (03:17 +0000)
This patch add a new sysfs node in /sys/fs/f2fs/<device>/max_lock_elapsed_time.

This is a threshold, once a thread enters critical region that lock covers,
total elapsed time exceeds this threshold, f2fs will print tracepoint to dump
information of related context. This sysfs entry can be used to control the
value of threshold, by default, the value is 500 ms.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Documentation/ABI/testing/sysfs-fs-f2fs
fs/f2fs/checkpoint.c
fs/f2fs/f2fs.h
fs/f2fs/super.c
fs/f2fs/sysfs.c

index c39a85e84b6b36a7ee47f1d08eaf1831e1e27681..648ddd0d59f6f64e49937e3324a9dca840d4cb16 100644 (file)
@@ -939,3 +939,11 @@ Description:       Controls write priority in multi-devices setups. A value of 0 means
                allocate_section_policy = 1  Prioritize writing to section before allocate_section_hint
                allocate_section_policy = 2  Prioritize writing to section after allocate_section_hint
                ===========================  ==========================================================
+
+What:          /sys/fs/f2fs/<disk>/max_lock_elapsed_time
+Date:          December 2025
+Contact:       "Chao Yu" <chao@kernel.org>
+Description:   This is a threshold, once a thread enters critical region that lock covers, total
+               elapsed time exceeds this threshold, f2fs will print tracepoint to dump information
+               of related context. This sysfs entry can be used to control the value of threshold,
+               by default, the value is 500 ms.
index bc6058a3122b1d4ede5b974659b1af9a46a3932d..61bcf227d8ca915f780422bab1eef52da92cafda 100644 (file)
@@ -66,7 +66,7 @@ static inline void trace_lock_elapsed_time_end(struct f2fs_rwsem *sem,
        get_lock_elapsed_time(&tts);
 
        total_time = div_u64(tts.total_time - lc->ts.total_time, npm);
-       if (total_time <= MAX_LOCK_ELAPSED_TIME)
+       if (total_time <= sem->sbi->max_lock_elapsed_time)
                return;
 
 #ifdef CONFIG_64BIT
index fc3f532972edc629f6c09926ed769aa97ddf738e..7f2675ed7f8609179c3b72b51d65506f79773b3b 100644 (file)
@@ -1951,6 +1951,9 @@ struct f2fs_sb_info {
        /* carve out reserved_blocks from total blocks */
        bool carve_out;
 
+       /* max elapsed time threshold in critical region that lock covered */
+       unsigned long long max_lock_elapsed_time;
+
 #ifdef CONFIG_F2FS_FS_COMPRESSION
        struct kmem_cache *page_array_slab;     /* page array entry */
        unsigned int page_array_slab_size;      /* default page array slab size */
index 036ba9cc799c05ed87d131d1e3f14c022b068f84..8fe1ac8a609cdcd147c4879900d254c058b668a1 100644 (file)
@@ -4295,6 +4295,7 @@ static void init_sb_info(struct f2fs_sb_info *sbi)
        sbi->max_fragment_hole = DEF_FRAGMENT_SIZE;
        spin_lock_init(&sbi->gc_remaining_trials_lock);
        atomic64_set(&sbi->current_atomic_write, 0);
+       sbi->max_lock_elapsed_time = MAX_LOCK_ELAPSED_TIME;
 
        sbi->dir_level = DEF_DIR_LEVEL;
        sbi->interval_time[CP_TIME] = DEF_CP_INTERVAL;
index c42f4f979d13f3f7580f124910a71879d930e13f..e03cba5a9d7031b0f16b68eb473a261d52e9bd05 100644 (file)
@@ -1219,6 +1219,7 @@ F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
 F2FS_SBI_GENERAL_RW_ATTR(carve_out);
 F2FS_SBI_GENERAL_RW_ATTR(reserved_pin_section);
 F2FS_SBI_GENERAL_RW_ATTR(bggc_io_aware);
+F2FS_SBI_GENERAL_RW_ATTR(max_lock_elapsed_time);
 
 /* STAT_INFO ATTR */
 #ifdef CONFIG_F2FS_STAT_FS
@@ -1422,6 +1423,7 @@ static struct attribute *f2fs_attrs[] = {
        ATTR_LIST(reserved_pin_section),
        ATTR_LIST(allocate_section_hint),
        ATTR_LIST(allocate_section_policy),
+       ATTR_LIST(max_lock_elapsed_time),
        NULL,
 };
 ATTRIBUTE_GROUPS(f2fs);