linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] f2fs: add proc entry to show discard_plist info
@ 2022-10-25 13:26 Yangtao Li
  2022-10-29  3:38 ` [f2fs-dev] " Chao Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Yangtao Li @ 2022-10-25 13:26 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Yangtao Li

This patch adds a new proc entry to show discard_plist
information in more detail, which is very helpful to
know the discard pend list count clearly.

Such as:

Discard pend list(Show diacrd_cmd count on each entry, .:not exist):
  0       390     156      85      67      46      37      26      14
  8        17      12       9       9       6      12      11      10
  16        5       9       2       4       8       3       4       1
  24        3       2       2       5       2       4       5       4
  32        3       3       2       3       .       3       3       1
  40        .       4       1       3       2       1       2       1
  48        1       .       1       1       .       1       1       .
  56        .       1       1       1       .       2       .       1
  64        1       2       .       .       .       .       .       .
  72        .       1       .       .       .       .       .       .
  80        3       1       .       .       1       1       .       .
  88        1       .       .       .       1       .       .       1
......

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
v2:
-move to procfs entry
 fs/f2fs/sysfs.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index df27afd71ef4..0fc17375e042 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -1243,6 +1243,44 @@ static int __maybe_unused victim_bits_seq_show(struct seq_file *seq,
 	return 0;
 }
 
+static int __maybe_unused discard_plist_seq_show(struct seq_file *seq,
+						void *offset)
+{
+	struct super_block *sb = seq->private;
+	struct f2fs_sb_info *sbi = F2FS_SB(sb);
+	struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
+	int i, count;
+
+	seq_puts(seq, "Discard pend list(Show diacrd_cmd count on each entry, .:not exist):\n");
+	if (!f2fs_realtime_discard_enable(sbi))
+		return 0;
+
+	if (dcc) {
+		mutex_lock(&dcc->cmd_lock);
+		for (i = 0; i < MAX_PLIST_NUM; i++) {
+			struct list_head *pend_list;
+			struct discard_cmd *dc, *tmp;
+
+			if (i % 8 == 0)
+				seq_printf(seq, "  %-3d", i);
+			count = 0;
+			pend_list = &dcc->pend_list[i];
+			list_for_each_entry_safe(dc, tmp, pend_list, list)
+				count++;
+			if (count)
+				seq_printf(seq, " %7d", count);
+			else
+				seq_puts(seq, "       .");
+			if (i % 8 == 7)
+				seq_putc(seq, '\n');
+		}
+		seq_putc(seq, '\n');
+		mutex_unlock(&dcc->cmd_lock);
+	}
+
+	return 0;
+}
+
 int __init f2fs_init_sysfs(void)
 {
 	int ret;
@@ -1313,6 +1351,8 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
 #endif
 		proc_create_single_data("victim_bits", 0444, sbi->s_proc,
 				victim_bits_seq_show, sb);
+		proc_create_single_data("discard_plist_info", 0444, sbi->s_proc,
+				discard_plist_seq_show, sb);
 	}
 	return 0;
 put_feature_list_kobj:
@@ -1336,6 +1376,7 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
 		remove_proc_entry("segment_info", sbi->s_proc);
 		remove_proc_entry("segment_bits", sbi->s_proc);
 		remove_proc_entry("victim_bits", sbi->s_proc);
+		remove_proc_entry("discard_plist_info", sbi->s_proc);
 		remove_proc_entry(sbi->sb->s_id, f2fs_proc_root);
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: add proc entry to show discard_plist info
  2022-10-25 13:26 [PATCH v2] f2fs: add proc entry to show discard_plist info Yangtao Li
@ 2022-10-29  3:38 ` Chao Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2022-10-29  3:38 UTC (permalink / raw)
  To: Yangtao Li, jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

On 2022/10/25 21:26, Yangtao Li via Linux-f2fs-devel wrote:
> This patch adds a new proc entry to show discard_plist
> information in more detail, which is very helpful to
> know the discard pend list count clearly.
> 
> Such as:
> 
> Discard pend list(Show diacrd_cmd count on each entry, .:not exist):

Discard pending list

>    0       390     156      85      67      46      37      26      14
>    8        17      12       9       9       6      12      11      10
>    16        5       9       2       4       8       3       4       1
>    24        3       2       2       5       2       4       5       4
>    32        3       3       2       3       .       3       3       1
>    40        .       4       1       3       2       1       2       1
>    48        1       .       1       1       .       1       1       .
>    56        .       1       1       1       .       2       .       1
>    64        1       2       .       .       .       .       .       .
>    72        .       1       .       .       .       .       .       .
>    80        3       1       .       .       1       1       .       .
>    88        1       .       .       .       1       .       .       1
> ......
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
> v2:
> -move to procfs entry
>   fs/f2fs/sysfs.c | 41 +++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 41 insertions(+)
> 
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index df27afd71ef4..0fc17375e042 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -1243,6 +1243,44 @@ static int __maybe_unused victim_bits_seq_show(struct seq_file *seq,
>   	return 0;
>   }
>   
> +static int __maybe_unused discard_plist_seq_show(struct seq_file *seq,
> +						void *offset)
> +{
> +	struct super_block *sb = seq->private;
> +	struct f2fs_sb_info *sbi = F2FS_SB(sb);
> +	struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
> +	int i, count;
> +
> +	seq_puts(seq, "Discard pend list(Show diacrd_cmd count on each entry, .:not exist):\n");
> +	if (!f2fs_realtime_discard_enable(sbi))
> +		return 0;
> +
> +	if (dcc) {

IIUC, dcc should always be valid.

> +		mutex_lock(&dcc->cmd_lock);
> +		for (i = 0; i < MAX_PLIST_NUM; i++) {
> +			struct list_head *pend_list;
> +			struct discard_cmd *dc, *tmp;

unsigned int count = 0;

> +
> +			if (i % 8 == 0)
> +				seq_printf(seq, "  %-3d", i);

seq_printf(seq, "%-10d", i);

> +			count = 0;
> +			pend_list = &dcc->pend_list[i];
> +			list_for_each_entry_safe(dc, tmp, pend_list, list)
> +				count++;
> +			if (count)
> +				seq_printf(seq, " %7d", count);

On 16TB size device, there will be about 2 billion discard entry at
maximum, so %10d will be more safe?

How about introducing an array to record discard numbers, if there is
millions of discard, lookuping this proc entry may hang f2fs due to
holding cmd_lock for long time.

> +			else
> +				seq_puts(seq, "       .");

It's fine to show '0' here.

> +			if (i % 8 == 7)
> +				seq_putc(seq, '\n');

else
	seq_putc(seq, ' ');

> +		}
> +		seq_putc(seq, '\n');
> +		mutex_unlock(&dcc->cmd_lock);
> +	}
> +
> +	return 0;
> +}
> +
>   int __init f2fs_init_sysfs(void)
>   {
>   	int ret;
> @@ -1313,6 +1351,8 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
>   #endif
>   		proc_create_single_data("victim_bits", 0444, sbi->s_proc,
>   				victim_bits_seq_show, sb);
> +		proc_create_single_data("discard_plist_info", 0444, sbi->s_proc,

Well, discard_plist?

Thanks,

> +				discard_plist_seq_show, sb);
>   	}
>   	return 0;
>   put_feature_list_kobj:
> @@ -1336,6 +1376,7 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
>   		remove_proc_entry("segment_info", sbi->s_proc);
>   		remove_proc_entry("segment_bits", sbi->s_proc);
>   		remove_proc_entry("victim_bits", sbi->s_proc);
> +		remove_proc_entry("discard_plist_info", sbi->s_proc);
>   		remove_proc_entry(sbi->sb->s_id, f2fs_proc_root);
>   	}
>   

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-29  3:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25 13:26 [PATCH v2] f2fs: add proc entry to show discard_plist info Yangtao Li
2022-10-29  3:38 ` [f2fs-dev] " Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).