diff mbox series

[f2fs-dev] f2fs: including waf data in f2fs status information

Message ID 20230531082038epcms2p256f9db0d7ac377d404694354db1c3ebc@epcms2p2 (mailing list archive)
State Superseded
Headers show
Series [f2fs-dev] f2fs: including waf data in f2fs status information | expand

Commit Message

beomsu kim May 31, 2023, 8:20 a.m. UTC
When evaluating in f2fs, it takes much time to obtain waf data.
This patch helps to obtain waf data without calcluation.

Signed-off-by: Beomsu Kim <beomsu7.kim@samsung.com>
---
 fs/f2fs/iostat.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

kernel test robot June 1, 2023, 6:29 a.m. UTC | #1
Hi beomsu,

kernel test robot noticed the following build errors:

[auto build test ERROR on v6.4-rc4]
[also build test ERROR on linus/master next-20230601]
[cannot apply to jaegeuk-f2fs/dev-test jaegeuk-f2fs/dev]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/beomsu-kim/f2fs-including-waf-data-in-f2fs-status-information/20230531-162208
base:   7877cb91f1081754a1487c144d85dc0d2e2e7fc4
patch link:    https://lore.kernel.org/r/20230531082038epcms2p256f9db0d7ac377d404694354db1c3ebc%40epcms2p2
patch subject: [PATCH] f2fs: including waf data in f2fs status information
config: x86_64-randconfig-x065-20230531 (https://download.01.org/0day-ci/archive/20230601/202306011410.W02TPFn1-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        mkdir -p ~/bin
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/3a2228fdedf76cc8448b358d07b77eb26d1299a4
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review beomsu-kim/f2fs-including-waf-data-in-f2fs-status-information/20230531-162208
        git checkout 3a2228fdedf76cc8448b358d07b77eb26d1299a4
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash fs/f2fs/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306011410.W02TPFn1-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

>> fs/f2fs/iostat.c:37:30: error: implicit declaration of function 'F2FS_STAT' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           struct f2fs_stat_info *si = F2FS_STAT(sbi);
                                       ^
>> fs/f2fs/iostat.c:37:25: warning: incompatible integer to pointer conversion initializing 'struct f2fs_stat_info *' with an expression of type 'int' [-Wint-conversion]
           struct f2fs_stat_info *si = F2FS_STAT(sbi);
                                  ^    ~~~~~~~~~~~~~~
>> fs/f2fs/iostat.c:46:32: error: incomplete definition of type 'struct f2fs_stat_info'
                   data_written_to_storage += si->sbi->iostat_bytes[j];
                                              ~~^
   fs/f2fs/iostat.c:37:9: note: forward declaration of 'struct f2fs_stat_info'
           struct f2fs_stat_info *si = F2FS_STAT(sbi);
                  ^
   fs/f2fs/iostat.c:48:29: error: incomplete definition of type 'struct f2fs_stat_info'
                   data_written_by_user += si->sbi->iostat_bytes[j];
                                           ~~^
   fs/f2fs/iostat.c:37:9: note: forward declaration of 'struct f2fs_stat_info'
           struct f2fs_stat_info *si = F2FS_STAT(sbi);
                  ^
   1 warning and 3 errors generated.


vim +/F2FS_STAT +37 fs/f2fs/iostat.c

    26	
    27	#define IOSTAT_INFO_SHOW(name, type)					\
    28		seq_printf(seq, "%-23s %-16llu %-16llu %-16llu\n",		\
    29				name":", sbi->iostat_bytes[type],		\
    30				sbi->iostat_count[type],			\
    31				iostat_get_avg_bytes(sbi, type))
    32	
    33	int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset)
    34	{
    35		struct super_block *sb = seq->private;
    36		struct f2fs_sb_info *sbi = F2FS_SB(sb);
  > 37		struct f2fs_stat_info *si = F2FS_STAT(sbi);
    38		int j;
    39		unsigned long long waf = 0;
    40		unsigned long long data_written_to_storage = 0, data_written_by_user = 0;
    41	
    42		if (!sbi->iostat_enable)
    43			return 0;
    44	
    45		for (j = FS_DATA_IO; j <= FS_CP_META_IO; j++)
  > 46			data_written_to_storage += si->sbi->iostat_bytes[j];
    47		for (j = FS_DATA_IO; j <= FS_CDATA_IO; j++)
    48			data_written_by_user += si->sbi->iostat_bytes[j];
    49	
    50		if (data_written_by_user > 0)
    51			waf = data_written_to_storage * 100 / data_written_by_user;
    52	
    53		seq_printf(seq, "time:		%-16llu\n", ktime_get_real_seconds());
    54		seq_printf(seq, "\t\t\t%-16s %-16s %-16s\n",
    55					"io_bytes", "count", "avg_bytes");
    56	
    57		/* print app write IOs */
    58		seq_puts(seq, "[WRITE]\n");
    59		IOSTAT_INFO_SHOW("app buffered data", APP_BUFFERED_IO);
    60		IOSTAT_INFO_SHOW("app direct data", APP_DIRECT_IO);
    61		IOSTAT_INFO_SHOW("app mapped data", APP_MAPPED_IO);
    62		IOSTAT_INFO_SHOW("app buffered cdata", APP_BUFFERED_CDATA_IO);
    63		IOSTAT_INFO_SHOW("app mapped cdata", APP_MAPPED_CDATA_IO);
    64	
    65		/* print fs write IOs */
    66		IOSTAT_INFO_SHOW("fs data", FS_DATA_IO);
    67		IOSTAT_INFO_SHOW("fs cdata", FS_CDATA_IO);
    68		IOSTAT_INFO_SHOW("fs node", FS_NODE_IO);
    69		IOSTAT_INFO_SHOW("fs meta", FS_META_IO);
    70		IOSTAT_INFO_SHOW("fs gc data", FS_GC_DATA_IO);
    71		IOSTAT_INFO_SHOW("fs gc node", FS_GC_NODE_IO);
    72		IOSTAT_INFO_SHOW("fs cp data", FS_CP_DATA_IO);
    73		IOSTAT_INFO_SHOW("fs cp node", FS_CP_NODE_IO);
    74		IOSTAT_INFO_SHOW("fs cp meta", FS_CP_META_IO);
    75	
    76		/* print app read IOs */
    77		seq_puts(seq, "[READ]\n");
    78		IOSTAT_INFO_SHOW("app buffered data", APP_BUFFERED_READ_IO);
    79		IOSTAT_INFO_SHOW("app direct data", APP_DIRECT_READ_IO);
    80		IOSTAT_INFO_SHOW("app mapped data", APP_MAPPED_READ_IO);
    81		IOSTAT_INFO_SHOW("app buffered cdata", APP_BUFFERED_CDATA_READ_IO);
    82		IOSTAT_INFO_SHOW("app mapped cdata", APP_MAPPED_CDATA_READ_IO);
    83	
    84		/* print fs read IOs */
    85		IOSTAT_INFO_SHOW("fs data", FS_DATA_READ_IO);
    86		IOSTAT_INFO_SHOW("fs gc data", FS_GDATA_READ_IO);
    87		IOSTAT_INFO_SHOW("fs cdata", FS_CDATA_READ_IO);
    88		IOSTAT_INFO_SHOW("fs node", FS_NODE_READ_IO);
    89		IOSTAT_INFO_SHOW("fs meta", FS_META_READ_IO);
    90	
    91		/* print other IOs */
    92		seq_puts(seq, "[OTHER]\n");
    93		IOSTAT_INFO_SHOW("fs discard", FS_DISCARD_IO);
    94		IOSTAT_INFO_SHOW("fs flush", FS_FLUSH_IO);
    95	
    96		/* print waf */
    97		seq_puts(seq, "[WAF]\n");
    98		seq_printf(seq, "fs waf:		%llu.%02llu\n", waf / 100, waf % 100);
    99	
   100		return 0;
   101	}
   102
kernel test robot June 1, 2023, 2:18 p.m. UTC | #2
Hi beomsu,

kernel test robot noticed the following build errors:

[auto build test ERROR on v6.4-rc4]
[also build test ERROR on linus/master next-20230601]
[cannot apply to jaegeuk-f2fs/dev-test jaegeuk-f2fs/dev]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/beomsu-kim/f2fs-including-waf-data-in-f2fs-status-information/20230531-162208
base:   7877cb91f1081754a1487c144d85dc0d2e2e7fc4
patch link:    https://lore.kernel.org/r/20230531082038epcms2p256f9db0d7ac377d404694354db1c3ebc%40epcms2p2
patch subject: [PATCH] f2fs: including waf data in f2fs status information
config: x86_64-randconfig-a005-20230531 (https://download.01.org/0day-ci/archive/20230601/202306011750.kDn4yxlq-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/3a2228fdedf76cc8448b358d07b77eb26d1299a4
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review beomsu-kim/f2fs-including-waf-data-in-f2fs-status-information/20230531-162208
        git checkout 3a2228fdedf76cc8448b358d07b77eb26d1299a4
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 olddefconfig
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash fs/f2fs/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306011750.kDn4yxlq-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   fs/f2fs/iostat.c: In function 'iostat_info_seq_show':
>> fs/f2fs/iostat.c:37:37: error: implicit declaration of function 'F2FS_STAT'; did you mean 'F2FS_CKPT'? [-Werror=implicit-function-declaration]
      37 |         struct f2fs_stat_info *si = F2FS_STAT(sbi);
         |                                     ^~~~~~~~~
         |                                     F2FS_CKPT
>> fs/f2fs/iostat.c:37:37: warning: initialization of 'struct f2fs_stat_info *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
>> fs/f2fs/iostat.c:46:46: error: invalid use of undefined type 'struct f2fs_stat_info'
      46 |                 data_written_to_storage += si->sbi->iostat_bytes[j];
         |                                              ^~
   fs/f2fs/iostat.c:48:43: error: invalid use of undefined type 'struct f2fs_stat_info'
      48 |                 data_written_by_user += si->sbi->iostat_bytes[j];
         |                                           ^~
   cc1: some warnings being treated as errors


vim +37 fs/f2fs/iostat.c

    26	
    27	#define IOSTAT_INFO_SHOW(name, type)					\
    28		seq_printf(seq, "%-23s %-16llu %-16llu %-16llu\n",		\
    29				name":", sbi->iostat_bytes[type],		\
    30				sbi->iostat_count[type],			\
    31				iostat_get_avg_bytes(sbi, type))
    32	
    33	int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset)
    34	{
    35		struct super_block *sb = seq->private;
    36		struct f2fs_sb_info *sbi = F2FS_SB(sb);
  > 37		struct f2fs_stat_info *si = F2FS_STAT(sbi);
    38		int j;
    39		unsigned long long waf = 0;
    40		unsigned long long data_written_to_storage = 0, data_written_by_user = 0;
    41	
    42		if (!sbi->iostat_enable)
    43			return 0;
    44	
    45		for (j = FS_DATA_IO; j <= FS_CP_META_IO; j++)
  > 46			data_written_to_storage += si->sbi->iostat_bytes[j];
    47		for (j = FS_DATA_IO; j <= FS_CDATA_IO; j++)
    48			data_written_by_user += si->sbi->iostat_bytes[j];
    49	
    50		if (data_written_by_user > 0)
    51			waf = data_written_to_storage * 100 / data_written_by_user;
    52	
    53		seq_printf(seq, "time:		%-16llu\n", ktime_get_real_seconds());
    54		seq_printf(seq, "\t\t\t%-16s %-16s %-16s\n",
    55					"io_bytes", "count", "avg_bytes");
    56	
    57		/* print app write IOs */
    58		seq_puts(seq, "[WRITE]\n");
    59		IOSTAT_INFO_SHOW("app buffered data", APP_BUFFERED_IO);
    60		IOSTAT_INFO_SHOW("app direct data", APP_DIRECT_IO);
    61		IOSTAT_INFO_SHOW("app mapped data", APP_MAPPED_IO);
    62		IOSTAT_INFO_SHOW("app buffered cdata", APP_BUFFERED_CDATA_IO);
    63		IOSTAT_INFO_SHOW("app mapped cdata", APP_MAPPED_CDATA_IO);
    64	
    65		/* print fs write IOs */
    66		IOSTAT_INFO_SHOW("fs data", FS_DATA_IO);
    67		IOSTAT_INFO_SHOW("fs cdata", FS_CDATA_IO);
    68		IOSTAT_INFO_SHOW("fs node", FS_NODE_IO);
    69		IOSTAT_INFO_SHOW("fs meta", FS_META_IO);
    70		IOSTAT_INFO_SHOW("fs gc data", FS_GC_DATA_IO);
    71		IOSTAT_INFO_SHOW("fs gc node", FS_GC_NODE_IO);
    72		IOSTAT_INFO_SHOW("fs cp data", FS_CP_DATA_IO);
    73		IOSTAT_INFO_SHOW("fs cp node", FS_CP_NODE_IO);
    74		IOSTAT_INFO_SHOW("fs cp meta", FS_CP_META_IO);
    75	
    76		/* print app read IOs */
    77		seq_puts(seq, "[READ]\n");
    78		IOSTAT_INFO_SHOW("app buffered data", APP_BUFFERED_READ_IO);
    79		IOSTAT_INFO_SHOW("app direct data", APP_DIRECT_READ_IO);
    80		IOSTAT_INFO_SHOW("app mapped data", APP_MAPPED_READ_IO);
    81		IOSTAT_INFO_SHOW("app buffered cdata", APP_BUFFERED_CDATA_READ_IO);
    82		IOSTAT_INFO_SHOW("app mapped cdata", APP_MAPPED_CDATA_READ_IO);
    83	
    84		/* print fs read IOs */
    85		IOSTAT_INFO_SHOW("fs data", FS_DATA_READ_IO);
    86		IOSTAT_INFO_SHOW("fs gc data", FS_GDATA_READ_IO);
    87		IOSTAT_INFO_SHOW("fs cdata", FS_CDATA_READ_IO);
    88		IOSTAT_INFO_SHOW("fs node", FS_NODE_READ_IO);
    89		IOSTAT_INFO_SHOW("fs meta", FS_META_READ_IO);
    90	
    91		/* print other IOs */
    92		seq_puts(seq, "[OTHER]\n");
    93		IOSTAT_INFO_SHOW("fs discard", FS_DISCARD_IO);
    94		IOSTAT_INFO_SHOW("fs flush", FS_FLUSH_IO);
    95	
    96		/* print waf */
    97		seq_puts(seq, "[WAF]\n");
    98		seq_printf(seq, "fs waf:		%llu.%02llu\n", waf / 100, waf % 100);
    99	
   100		return 0;
   101	}
   102
diff mbox series

Patch

diff --git a/fs/f2fs/iostat.c b/fs/f2fs/iostat.c
index 3d5bfb1ad585..6ae9659d69e7 100644
--- a/fs/f2fs/iostat.c
+++ b/fs/f2fs/iostat.c
@@ -34,10 +34,22 @@  int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset)
 {
 	struct super_block *sb = seq->private;
 	struct f2fs_sb_info *sbi = F2FS_SB(sb);
+	struct f2fs_stat_info *si = F2FS_STAT(sbi);
+	int j;
+	unsigned long long waf = 0;
+	unsigned long long data_written_to_storage = 0, data_written_by_user = 0;
 
 	if (!sbi->iostat_enable)
 		return 0;
 
+	for (j = FS_DATA_IO; j <= FS_CP_META_IO; j++)
+		data_written_to_storage += si->sbi->iostat_bytes[j];
+	for (j = FS_DATA_IO; j <= FS_CDATA_IO; j++)
+		data_written_by_user += si->sbi->iostat_bytes[j];
+
+	if (data_written_by_user > 0)
+		waf = data_written_to_storage * 100 / data_written_by_user;
+
 	seq_printf(seq, "time:		%-16llu\n", ktime_get_real_seconds());
 	seq_printf(seq, "\t\t\t%-16s %-16s %-16s\n",
 				"io_bytes", "count", "avg_bytes");
@@ -81,6 +93,10 @@  int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset)
 	IOSTAT_INFO_SHOW("fs discard", FS_DISCARD_IO);
 	IOSTAT_INFO_SHOW("fs flush", FS_FLUSH_IO);
 
+	/* print waf */
+	seq_puts(seq, "[WAF]\n");
+	seq_printf(seq, "fs waf:		%llu.%02llu\n", waf / 100, waf % 100);
+
 	return 0;
 }