Whamcloud - gitweb
LU-16338 readahead: add stats for read-ahead page count 24/49224/4
authorQian Yingjin <qian@ddn.com>
Wed, 23 Nov 2022 09:42:53 +0000 (04:42 -0500)
committerOleg Drokin <green@whamcloud.com>
Fri, 27 Jan 2023 00:34:26 +0000 (00:34 +0000)
This patch adds the stats for read-ahead page count:

lctl get_param llite.*.read_ahead_stats
llite.lustre-ffff938b7849d000.read_ahead_stats=
snapshot_time             4011.320890492 secs.nsecs
start_time                0.000000000 secs.nsecs
elapsed_time              4011.320890492 secs.nsecs
hits                      4 samples [pages]
misses                    1 samples [pages]
zero_size_window          4 samples [pages]
failed_to_reach_end       1 samples [pages]
failed_to_fast_read       1 samples [pages]
readahead_pages           1 samples [pages] 255 255 255

Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: Iada06eb7d78ab28cfcc7167e49d25da252da4009
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49224
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Patrick Farrell <farr0186@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/llite_internal.h
lustre/llite/lproc_llite.c
lustre/llite/rw.c
lustre/tests/sanity.sh

index bdbfbb0..87de8fd 100644 (file)
@@ -593,6 +593,7 @@ enum ra_stat {
        RA_STAT_ASYNC,
        RA_STAT_FAILED_FAST_READ,
        RA_STAT_MMAP_RANGE_READ,
+       RA_STAT_READAHEAD_PAGES,
        _NR_RA_STAT,
 };
 
index 7776381..b729bc6 100644 (file)
@@ -1898,6 +1898,7 @@ static const char *const ra_stat_string[] = {
        [RA_STAT_ASYNC]                 = "async_readahead",
        [RA_STAT_FAILED_FAST_READ]      = "failed_to_fast_read",
        [RA_STAT_MMAP_RANGE_READ]       = "mmap_range_read",
+       [RA_STAT_READAHEAD_PAGES]       = "readahead_pages"
 };
 
 int ll_debugfs_register_super(struct super_block *sb, const char *name)
@@ -1949,9 +1950,17 @@ int ll_debugfs_register_super(struct super_block *sb, const char *name)
        if (sbi->ll_ra_stats == NULL)
                GOTO(out_stats, err = -ENOMEM);
 
-       for (id = 0; id < ARRAY_SIZE(ra_stat_string); id++)
-               lprocfs_counter_init(sbi->ll_ra_stats, id, LPROCFS_TYPE_PAGES,
-                                    ra_stat_string[id]);
+       for (id = 0; id < ARRAY_SIZE(ra_stat_string); id++) {
+               if (id == RA_STAT_READAHEAD_PAGES)
+                       lprocfs_counter_init(sbi->ll_ra_stats, id,
+                                            LPROCFS_TYPE_PAGES |
+                                            LPROCFS_CNTR_AVGMINMAX,
+                                            ra_stat_string[id]);
+               else
+                       lprocfs_counter_init(sbi->ll_ra_stats, id,
+                                            LPROCFS_TYPE_PAGES,
+                                            ra_stat_string[id]);
+       }
 
        debugfs_create_file("read_ahead_stats", 0644, sbi->ll_debugfs_entry,
                            sbi->ll_ra_stats, &ldebugfs_stats_seq_fops);
index 66496e6..49f174f 100644 (file)
@@ -148,9 +148,18 @@ static inline bool ll_readahead_enabled(struct ll_sb_info *sbi)
 void ll_ra_stats_inc(struct inode *inode, enum ra_stat which)
 {
        struct ll_sb_info *sbi = ll_i2sbi(inode);
+
        ll_ra_stats_inc_sbi(sbi, which);
 }
 
+void ll_ra_stats_add(struct inode *inode, enum ra_stat which, long count)
+{
+       struct ll_sb_info *sbi = ll_i2sbi(inode);
+
+       LASSERTF(which < _NR_RA_STAT, "which: %u\n", which);
+       lprocfs_counter_add(sbi->ll_ra_stats, which, count);
+}
+
 #define RAS_CDEBUG(ras) \
        CDEBUG(D_READA,                                                      \
               "lre %llu cr %lu cb %llu wsi %lu wp %lu nra %lu rpc %lu "     \
@@ -524,6 +533,10 @@ ll_read_ahead_pages(const struct lu_env *env, struct cl_io *io,
 
        cl_read_ahead_release(env, &ra);
 
+       if (count)
+               ll_ra_stats_add(vvp_object_inode(io->ci_obj),
+                               RA_STAT_READAHEAD_PAGES, count);
+
        return count;
 }
 
index 44c02a3..d94511a 100755 (executable)
@@ -11152,6 +11152,20 @@ test_101j() {
 }
 run_test 101j "A complete read block should be submitted when no RA"
 
+test_101k()
+{
+       local file=$DIR/$tfile
+
+       check_set_fallocate_or_skip
+
+       $LCTL set_param -n llite.*.read_ahead_stats=0
+       fallocate -l 16K $file || error "failed to fallocate $file"
+       cancel_lru_locks osc
+       $MULTIOP $file or1048576c
+       $LCTL get_param llite.*.read_ahead_stats
+}
+run_test 101k "read ahead for small file"
+
 setup_test102() {
        test_mkdir $DIR/$tdir
        chown $RUNAS_ID $DIR/$tdir