linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] f2fs: add sysfs nodes to get discard information
@ 2021-08-14 17:58 Yangtao Li
  2021-08-14 17:58 ` [PATCH 2/2] f2fs: fix description about main_blkaddr node Yangtao Li
  2021-08-16  2:35 ` [PATCH 1/2] f2fs: add sysfs nodes to get discard information Chao Yu
  0 siblings, 2 replies; 9+ messages in thread
From: Yangtao Li @ 2021-08-14 17:58 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Yangtao Li

I've added new sysfs nodes to show discard stat since mount, which
will help us analyze whether the performance problem is related to
discard.

issued_discard  - Shows the number of issued discard
queued_discard  - Shows the number of cached discard cmd count
discard_cmd_cnt - Shows the number of cached discard cmd count
undiscard_blks  - Shows the number of undiscard blocks

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 Documentation/ABI/testing/sysfs-fs-f2fs | 20 +++++++++++
 fs/f2fs/sysfs.c                         | 44 +++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index ef4b9218ae1e..32df6d16d74f 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -493,3 +493,23 @@ Contact:	"Chao Yu" <yuchao0@huawei.com>
 Description:	When ATGC is on, it controls age threshold to bypass GCing young
 		candidates whose age is not beyond the threshold, by default it was
 		initialized as 604800 seconds (equals to 7 days).
+
+What:		/sys/fs/f2fs/<disk>/issued_discard
+Date:		August 2021
+Contact:	"Yangtao Li" <frank.li@vivo.com>
+Description:	Shows the number of issued discard.
+
+What:		/sys/fs/f2fs/<disk>/queued_discard
+Date:		August 2021
+Contact:	"Yangtao Li" <frank.li@vivo.com>
+Description:	Shows the number of queued discard.
+
+What:		/sys/fs/f2fs/<disk>/discard_cmd_cnt
+Date:		August 2021
+Contact:	"Yangtao Li" <frank.li@vivo.com>
+Description:	Shows the number of cached discard cmd count.
+
+What:		/sys/fs/f2fs/<disk>/undiscard_blks
+Date:		August 2021
+Contact:	"Yangtao Li" <frank.li@vivo.com>
+Description:	Shows the number of undiscard blocks.
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index 6642246206bd..b7d6c1adc7f8 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -248,6 +248,42 @@ static ssize_t main_blkaddr_show(struct f2fs_attr *a,
 			(unsigned long long)MAIN_BLKADDR(sbi));
 }
 
+static ssize_t issued_discard_show(struct f2fs_attr *a,
+				struct f2fs_sb_info *sbi, char *buf)
+{
+	struct discard_cmd_control *dcc_info = SM_I(sbi)->dcc_info;
+
+	return snprintf(buf, PAGE_SIZE, "%llu\n",
+			(unsigned long long)atomic_read(&dcc_info->issued_discard));
+}
+
+static ssize_t queued_discard_show(struct f2fs_attr *a,
+				struct f2fs_sb_info *sbi, char *buf)
+{
+	struct discard_cmd_control *dcc_info = SM_I(sbi)->dcc_info;
+
+	return snprintf(buf, PAGE_SIZE, "%llu\n",
+			(unsigned long long)atomic_read(&dcc_info->queued_discard));
+}
+
+static ssize_t discard_cmd_cnt_show(struct f2fs_attr *a,
+				struct f2fs_sb_info *sbi, char *buf)
+{
+	struct discard_cmd_control *dcc_info = SM_I(sbi)->dcc_info;
+
+	return snprintf(buf, PAGE_SIZE, "%llu\n",
+			(unsigned long long)atomic_read(&dcc_info->discard_cmd_cnt));
+}
+
+static ssize_t undiscard_blks_show(struct f2fs_attr *a,
+				struct f2fs_sb_info *sbi, char *buf)
+{
+	struct discard_cmd_control *dcc_info = SM_I(sbi)->dcc_info;
+
+	return snprintf(buf, PAGE_SIZE, "%llu\n",
+			(unsigned long long)dcc_info->undiscard_blks);
+}
+
 static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
 			struct f2fs_sb_info *sbi, char *buf)
 {
@@ -690,6 +726,10 @@ F2FS_GENERAL_RO_ATTR(unusable);
 F2FS_GENERAL_RO_ATTR(encoding);
 F2FS_GENERAL_RO_ATTR(mounted_time_sec);
 F2FS_GENERAL_RO_ATTR(main_blkaddr);
+F2FS_GENERAL_RO_ATTR(issued_discard);
+F2FS_GENERAL_RO_ATTR(queued_discard);
+F2FS_GENERAL_RO_ATTR(discard_cmd_cnt);
+F2FS_GENERAL_RO_ATTR(undiscard_blks);
 #ifdef CONFIG_F2FS_STAT_FS
 F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_foreground_calls, cp_count);
 F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_background_calls, bg_cp_count);
@@ -750,6 +790,10 @@ static struct attribute *f2fs_attrs[] = {
 	ATTR_LIST(gc_urgent),
 	ATTR_LIST(reclaim_segments),
 	ATTR_LIST(main_blkaddr),
+	ATTR_LIST(issued_discard),
+	ATTR_LIST(queued_discard),
+	ATTR_LIST(discard_cmd_cnt),
+	ATTR_LIST(undiscard_blks),
 	ATTR_LIST(max_small_discards),
 	ATTR_LIST(discard_granularity),
 	ATTR_LIST(batched_trim_sections),
-- 
2.32.0


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

* [PATCH 2/2] f2fs: fix description about main_blkaddr node
  2021-08-14 17:58 [PATCH 1/2] f2fs: add sysfs nodes to get discard information Yangtao Li
@ 2021-08-14 17:58 ` Yangtao Li
  2021-08-16  2:37   ` Chao Yu
  2021-08-16  2:35 ` [PATCH 1/2] f2fs: add sysfs nodes to get discard information Chao Yu
  1 sibling, 1 reply; 9+ messages in thread
From: Yangtao Li @ 2021-08-14 17:58 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Yangtao Li

Don't leave a blank line, to keep the style consistent
with other node descriptions.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 Documentation/ABI/testing/sysfs-fs-f2fs | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index 32df6d16d74f..ff5a8fdadbfc 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -41,8 +41,7 @@ Description:	This parameter controls the number of prefree segments to be
 What:		/sys/fs/f2fs/<disk>/main_blkaddr
 Date:		November 2019
 Contact:	"Ramon Pantin" <pantin@google.com>
-Description:
-		 Shows first block address of MAIN area.
+Description:	Shows first block address of MAIN area.
 
 What:		/sys/fs/f2fs/<disk>/ipu_policy
 Date:		November 2013
-- 
2.32.0


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

* Re: [PATCH 1/2] f2fs: add sysfs nodes to get discard information
  2021-08-14 17:58 [PATCH 1/2] f2fs: add sysfs nodes to get discard information Yangtao Li
  2021-08-14 17:58 ` [PATCH 2/2] f2fs: fix description about main_blkaddr node Yangtao Li
@ 2021-08-16  2:35 ` Chao Yu
  2021-08-16  2:42   ` 李扬韬
  1 sibling, 1 reply; 9+ messages in thread
From: Chao Yu @ 2021-08-16  2:35 UTC (permalink / raw)
  To: Yangtao Li, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel

On 2021/8/15 1:58, Yangtao Li wrote:
> I've added new sysfs nodes to show discard stat since mount, which
> will help us analyze whether the performance problem is related to
> discard.
> 
> issued_discard  - Shows the number of issued discard
> queued_discard  - Shows the number of cached discard cmd count
> discard_cmd_cnt - Shows the number of cached discard cmd count
> undiscard_blks  - Shows the number of undiscard blocks

We have exported them in debugfs, can you use that?

Thanks,

> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   Documentation/ABI/testing/sysfs-fs-f2fs | 20 +++++++++++
>   fs/f2fs/sysfs.c                         | 44 +++++++++++++++++++++++++
>   2 files changed, 64 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
> index ef4b9218ae1e..32df6d16d74f 100644
> --- a/Documentation/ABI/testing/sysfs-fs-f2fs
> +++ b/Documentation/ABI/testing/sysfs-fs-f2fs
> @@ -493,3 +493,23 @@ Contact:	"Chao Yu" <yuchao0@huawei.com>
>   Description:	When ATGC is on, it controls age threshold to bypass GCing young
>   		candidates whose age is not beyond the threshold, by default it was
>   		initialized as 604800 seconds (equals to 7 days).
> +
> +What:		/sys/fs/f2fs/<disk>/issued_discard
> +Date:		August 2021
> +Contact:	"Yangtao Li" <frank.li@vivo.com>
> +Description:	Shows the number of issued discard.
> +
> +What:		/sys/fs/f2fs/<disk>/queued_discard
> +Date:		August 2021
> +Contact:	"Yangtao Li" <frank.li@vivo.com>
> +Description:	Shows the number of queued discard.
> +
> +What:		/sys/fs/f2fs/<disk>/discard_cmd_cnt
> +Date:		August 2021
> +Contact:	"Yangtao Li" <frank.li@vivo.com>
> +Description:	Shows the number of cached discard cmd count.
> +
> +What:		/sys/fs/f2fs/<disk>/undiscard_blks
> +Date:		August 2021
> +Contact:	"Yangtao Li" <frank.li@vivo.com>
> +Description:	Shows the number of undiscard blocks.
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index 6642246206bd..b7d6c1adc7f8 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -248,6 +248,42 @@ static ssize_t main_blkaddr_show(struct f2fs_attr *a,
>   			(unsigned long long)MAIN_BLKADDR(sbi));
>   }
>   
> +static ssize_t issued_discard_show(struct f2fs_attr *a,
> +				struct f2fs_sb_info *sbi, char *buf)
> +{
> +	struct discard_cmd_control *dcc_info = SM_I(sbi)->dcc_info;
> +
> +	return snprintf(buf, PAGE_SIZE, "%llu\n",
> +			(unsigned long long)atomic_read(&dcc_info->issued_discard));
> +}
> +
> +static ssize_t queued_discard_show(struct f2fs_attr *a,
> +				struct f2fs_sb_info *sbi, char *buf)
> +{
> +	struct discard_cmd_control *dcc_info = SM_I(sbi)->dcc_info;
> +
> +	return snprintf(buf, PAGE_SIZE, "%llu\n",
> +			(unsigned long long)atomic_read(&dcc_info->queued_discard));
> +}
> +
> +static ssize_t discard_cmd_cnt_show(struct f2fs_attr *a,
> +				struct f2fs_sb_info *sbi, char *buf)
> +{
> +	struct discard_cmd_control *dcc_info = SM_I(sbi)->dcc_info;
> +
> +	return snprintf(buf, PAGE_SIZE, "%llu\n",
> +			(unsigned long long)atomic_read(&dcc_info->discard_cmd_cnt));
> +}
> +
> +static ssize_t undiscard_blks_show(struct f2fs_attr *a,
> +				struct f2fs_sb_info *sbi, char *buf)
> +{
> +	struct discard_cmd_control *dcc_info = SM_I(sbi)->dcc_info;
> +
> +	return snprintf(buf, PAGE_SIZE, "%llu\n",
> +			(unsigned long long)dcc_info->undiscard_blks);
> +}
> +
>   static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
>   			struct f2fs_sb_info *sbi, char *buf)
>   {
> @@ -690,6 +726,10 @@ F2FS_GENERAL_RO_ATTR(unusable);
>   F2FS_GENERAL_RO_ATTR(encoding);
>   F2FS_GENERAL_RO_ATTR(mounted_time_sec);
>   F2FS_GENERAL_RO_ATTR(main_blkaddr);
> +F2FS_GENERAL_RO_ATTR(issued_discard);
> +F2FS_GENERAL_RO_ATTR(queued_discard);
> +F2FS_GENERAL_RO_ATTR(discard_cmd_cnt);
> +F2FS_GENERAL_RO_ATTR(undiscard_blks);
>   #ifdef CONFIG_F2FS_STAT_FS
>   F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_foreground_calls, cp_count);
>   F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_background_calls, bg_cp_count);
> @@ -750,6 +790,10 @@ static struct attribute *f2fs_attrs[] = {
>   	ATTR_LIST(gc_urgent),
>   	ATTR_LIST(reclaim_segments),
>   	ATTR_LIST(main_blkaddr),
> +	ATTR_LIST(issued_discard),
> +	ATTR_LIST(queued_discard),
> +	ATTR_LIST(discard_cmd_cnt),
> +	ATTR_LIST(undiscard_blks),
>   	ATTR_LIST(max_small_discards),
>   	ATTR_LIST(discard_granularity),
>   	ATTR_LIST(batched_trim_sections),
> 

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

* Re: [PATCH 2/2] f2fs: fix description about main_blkaddr node
  2021-08-14 17:58 ` [PATCH 2/2] f2fs: fix description about main_blkaddr node Yangtao Li
@ 2021-08-16  2:37   ` Chao Yu
  0 siblings, 0 replies; 9+ messages in thread
From: Chao Yu @ 2021-08-16  2:37 UTC (permalink / raw)
  To: Yangtao Li, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel

On 2021/8/15 1:58, Yangtao Li wrote:
> Don't leave a blank line, to keep the style consistent
> with other node descriptions.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

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

* Re:Re: [PATCH 1/2] f2fs: add sysfs nodes to get discard information
  2021-08-16  2:35 ` [PATCH 1/2] f2fs: add sysfs nodes to get discard information Chao Yu
@ 2021-08-16  2:42   ` 李扬韬
  2021-08-16  4:15     ` Chao Yu
  0 siblings, 1 reply; 9+ messages in thread
From: 李扬韬 @ 2021-08-16  2:42 UTC (permalink / raw)
  To: Chao Yu; +Cc: jaegeuk, linux-f2fs-devel, linux-kernel

>> I've added new sysfs nodes to show discard stat since mount, which
>> will help us analyze whether the performance problem is related to
>> discard.
>> 
>> issued_discard  - Shows the number of issued discard
>> queued_discard  - Shows the number of cached discard cmd count
>> discard_cmd_cnt - Shows the number of cached discard cmd count
>> undiscard_blks  - Shows the number of undiscard blocks
>
>We have exported them in debugfs, can you use that?
>
>Thanks,

But now Android is forbidden to open debugfs, and in fact we have not
opened this configuration for a long time.

Thx,
Yangtao




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

* Re: [PATCH 1/2] f2fs: add sysfs nodes to get discard information
  2021-08-16  2:42   ` 李扬韬
@ 2021-08-16  4:15     ` Chao Yu
  2021-08-16  6:13       ` 李扬韬
  0 siblings, 1 reply; 9+ messages in thread
From: Chao Yu @ 2021-08-16  4:15 UTC (permalink / raw)
  To: 李扬韬; +Cc: jaegeuk, linux-f2fs-devel, linux-kernel

On 2021/8/16 10:42, 李扬韬 wrote:
>>> I've added new sysfs nodes to show discard stat since mount, which
>>> will help us analyze whether the performance problem is related to
>>> discard.
>>>
>>> issued_discard  - Shows the number of issued discard
>>> queued_discard  - Shows the number of cached discard cmd count
>>> discard_cmd_cnt - Shows the number of cached discard cmd count
>>> undiscard_blks  - Shows the number of undiscard blocks
>>
>> We have exported them in debugfs, can you use that?
>>
>> Thanks,
> 
> But now Android is forbidden to open debugfs, and in fact we have not
> opened this configuration for a long time.

Weren't them be used for debug purpose? can you please explain more about
your use case?

Thanks,

> 
> Thx,
> Yangtao
> 
> 
> 

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

* Re:Re: [PATCH 1/2] f2fs: add sysfs nodes to get discard information
  2021-08-16  4:15     ` Chao Yu
@ 2021-08-16  6:13       ` 李扬韬
  2021-08-17  0:16         ` Jaegeuk Kim
  2021-08-19  4:49         ` Chao Yu
  0 siblings, 2 replies; 9+ messages in thread
From: 李扬韬 @ 2021-08-16  6:13 UTC (permalink / raw)
  To: Chao Yu; +Cc: jaegeuk, linux-f2fs-devel, linux-kernel

>>>> I've added new sysfs nodes to show discard stat since mount, which
>>>> will help us analyze whether the performance problem is related to
>>>> discard.
>>>>
>>>> issued_discard  - Shows the number of issued discard
>>>> queued_discard  - Shows the number of cached discard cmd count
>>>> discard_cmd_cnt - Shows the number of cached discard cmd count
>>>> undiscard_blks  - Shows the number of undiscard blocks
>>>
>>> We have exported them in debugfs, can you use that?
>>>
>>> Thanks,
>> 
>> But now Android is forbidden to open debugfs, and in fact we have not
>> opened this configuration for a long time.
>
>Weren't them be used for debug purpose? can you please explain more about
>your use case?

During long-term aging test or normal use, sometimes there will be performance
degradation problems. It may be caused by storage, or it may be caused by the
filesystem. For example, the filesystem accumulates a large number of undiscard
 blocks. Although there is some remaining space, the androidbench test will
show performance degradation. Therefore, it is necessary to export information
related to discard so that we can confirm this situation.

Thx,



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

* Re: [PATCH 1/2] f2fs: add sysfs nodes to get discard information
  2021-08-16  6:13       ` 李扬韬
@ 2021-08-17  0:16         ` Jaegeuk Kim
  2021-08-19  4:49         ` Chao Yu
  1 sibling, 0 replies; 9+ messages in thread
From: Jaegeuk Kim @ 2021-08-17  0:16 UTC (permalink / raw)
  To: 李扬韬; +Cc: Chao Yu, linux-f2fs-devel, linux-kernel

On 08/16, 李扬韬 wrote:
> >>>> I've added new sysfs nodes to show discard stat since mount, which
> >>>> will help us analyze whether the performance problem is related to
> >>>> discard.
> >>>>
> >>>> issued_discard  - Shows the number of issued discard
> >>>> queued_discard  - Shows the number of cached discard cmd count
> >>>> discard_cmd_cnt - Shows the number of cached discard cmd count
> >>>> undiscard_blks  - Shows the number of undiscard blocks
> >>>
> >>> We have exported them in debugfs, can you use that?
> >>>
> >>> Thanks,
> >> 
> >> But now Android is forbidden to open debugfs, and in fact we have not
> >> opened this configuration for a long time.
> >
> >Weren't them be used for debug purpose? can you please explain more about
> >your use case?
> 
> During long-term aging test or normal use, sometimes there will be performance
> degradation problems. It may be caused by storage, or it may be caused by the
> filesystem. For example, the filesystem accumulates a large number of undiscard
>  blocks. Although there is some remaining space, the androidbench test will
> show performance degradation. Therefore, it is necessary to export information
> related to discard so that we can confirm this situation.

I think you can mount debugfs for that case?

> 
> Thx,
> 
> 

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

* Re: [PATCH 1/2] f2fs: add sysfs nodes to get discard information
  2021-08-16  6:13       ` 李扬韬
  2021-08-17  0:16         ` Jaegeuk Kim
@ 2021-08-19  4:49         ` Chao Yu
  1 sibling, 0 replies; 9+ messages in thread
From: Chao Yu @ 2021-08-19  4:49 UTC (permalink / raw)
  To: 李扬韬; +Cc: jaegeuk, linux-f2fs-devel, linux-kernel

On 2021/8/16 14:13, 李扬韬 wrote:
>>>>> I've added new sysfs nodes to show discard stat since mount, which
>>>>> will help us analyze whether the performance problem is related to
>>>>> discard.
>>>>>
>>>>> issued_discard  - Shows the number of issued discard
>>>>> queued_discard  - Shows the number of cached discard cmd count
>>>>> discard_cmd_cnt - Shows the number of cached discard cmd count
>>>>> undiscard_blks  - Shows the number of undiscard blocks
>>>>
>>>> We have exported them in debugfs, can you use that?
>>>>
>>>> Thanks,
>>>
>>> But now Android is forbidden to open debugfs, and in fact we have not
>>> opened this configuration for a long time.
>>
>> Weren't them be used for debug purpose? can you please explain more about
>> your use case?
> 
> During long-term aging test or normal use, sometimes there will be performance
> degradation problems. It may be caused by storage, or it may be caused by the
> filesystem. For example, the filesystem accumulates a large number of undiscard
>   blocks. Although there is some remaining space, the androidbench test will
> show performance degradation. Therefore, it is necessary to export information
> related to discard so that we can confirm this situation.

I have a solution for your case, however finally, we haven't used such discard
policy by default due to the policy needs to be designed more tunable for
devices with different characters.

See more details in below patches:

https://lkml.org/lkml/2018/8/10/219
https://lkml.org/lkml/2018/8/10/220

Thanks,

> 
> Thx,
> 
> 

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

end of thread, other threads:[~2021-08-19  4:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-14 17:58 [PATCH 1/2] f2fs: add sysfs nodes to get discard information Yangtao Li
2021-08-14 17:58 ` [PATCH 2/2] f2fs: fix description about main_blkaddr node Yangtao Li
2021-08-16  2:37   ` Chao Yu
2021-08-16  2:35 ` [PATCH 1/2] f2fs: add sysfs nodes to get discard information Chao Yu
2021-08-16  2:42   ` 李扬韬
2021-08-16  4:15     ` Chao Yu
2021-08-16  6:13       ` 李扬韬
2021-08-17  0:16         ` Jaegeuk Kim
2021-08-19  4:49         ` 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).