From: Yangtao Li <frank.li@vivo.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <chao@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Cc: Yangtao Li <frank.li@vivo.com>,
linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: [PATCH v4 2/2] f2fs: add iostat latency statistics support for discard
Date: Sat, 8 Apr 2023 01:46:08 +0800 [thread overview]
Message-ID: <20230407174609.4939-2-frank.li@vivo.com> (raw)
In-Reply-To: <20230407174609.4939-1-frank.li@vivo.com>
In this patch, it adds to account discard latency. This allows us to
track the discard io latency of the system lightweightly after enabling
iostat.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
v4:
-split it to two patch
fs/f2fs/f2fs.h | 1 +
fs/f2fs/iostat.c | 6 ++++--
fs/f2fs/segment.c | 8 +++++++-
include/trace/events/f2fs.h | 12 ++++++++++--
4 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 3d883201e7a5..1779f3596176 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1112,6 +1112,7 @@ enum page_type {
META_FLUSH,
IPU, /* the below types are used by tracepoints only. */
OPU,
+ DISCARD, /* used by iostat */
};
enum temp_type {
diff --git a/fs/f2fs/iostat.c b/fs/f2fs/iostat.c
index 5d496d5b70d3..f40b8915ae1b 100644
--- a/fs/f2fs/iostat.c
+++ b/fs/f2fs/iostat.c
@@ -235,7 +235,7 @@ void iostat_update_and_unbind_ctx(struct bio *bio)
{
struct bio_iostat_ctx *iostat_ctx = bio->bi_private;
- if (op_is_write(bio_op(bio)))
+ if (op_is_write(bio_op(bio)) && !op_is_discard(bio_op(bio)))
bio->bi_private = iostat_ctx->sbi;
else
bio->bi_private = iostat_ctx->iostat_private;
@@ -251,7 +251,9 @@ void iostat_update_submit_ctx(struct bio *bio, enum page_type type)
iostat_ctx->submit_ts = jiffies;
- if (op_is_write(bio_op(bio))) {
+ if (type == DISCARD) {
+ lat_type = DISCARD_LAT;
+ } else if (op_is_write(bio_op(bio))) {
lat_type = bio->bi_opf & REQ_SYNC ?
WRITE_SYNC_DATA_LAT : WRITE_ASYNC_DATA_LAT;
lat_type = (enum iostat_lat_type)(lat_type + type);
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index fc0734e4fb92..be24e9c945a3 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1100,9 +1100,12 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi,
static void f2fs_submit_discard_endio(struct bio *bio)
{
- struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private;
+ struct discard_cmd *dc;
unsigned long flags;
+ iostat_update_and_unbind_ctx(bio);
+ dc = bio->bi_private;
+
spin_lock_irqsave(&dc->lock, flags);
if (!dc->error)
dc->error = blk_status_to_errno(bio->bi_status);
@@ -1276,6 +1279,9 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
bio->bi_private = dc;
bio->bi_end_io = f2fs_submit_discard_endio;
bio->bi_opf |= flag;
+
+ iostat_alloc_and_bind_ctx(sbi, bio, dc);
+ iostat_update_submit_ctx(bio, DISCARD);
submit_bio(bio);
atomic_inc(&dcc->issued_discard);
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 040a430e1199..385291ac9ad5 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -2078,6 +2078,9 @@ TRACE_EVENT(f2fs_iostat_latency,
__field(unsigned int, m_wr_as_peak)
__field(unsigned int, m_wr_as_avg)
__field(unsigned int, m_wr_as_cnt)
+ __field(unsigned int, discard_peak)
+ __field(unsigned int, discard_avg)
+ __field(unsigned int, discard_cnt)
),
TP_fast_assign(
@@ -2109,6 +2112,9 @@ TRACE_EVENT(f2fs_iostat_latency,
__entry->m_wr_as_peak = iostat_lat[WRITE_ASYNC_META_LAT].peak_lat;
__entry->m_wr_as_avg = iostat_lat[WRITE_ASYNC_META_LAT].avg_lat;
__entry->m_wr_as_cnt = iostat_lat[WRITE_ASYNC_META_LAT].cnt;
+ __entry->discard_peak = iostat_lat[DISCARD_LAT].peak_lat;
+ __entry->discard_avg = iostat_lat[DISCARD_LAT].avg_lat;
+ __entry->discard_cnt = iostat_lat[DISCARD_LAT].cnt;
),
TP_printk("dev = (%d,%d), "
@@ -2116,7 +2122,8 @@ TRACE_EVENT(f2fs_iostat_latency,
"rd_data [%u/%u/%u], rd_node [%u/%u/%u], rd_meta [%u/%u/%u], "
"wr_sync_data [%u/%u/%u], wr_sync_node [%u/%u/%u], "
"wr_sync_meta [%u/%u/%u], wr_async_data [%u/%u/%u], "
- "wr_async_node [%u/%u/%u], wr_async_meta [%u/%u/%u]",
+ "wr_async_node [%u/%u/%u], wr_async_meta [%u/%u/%u], "
+ "discard [%u/%u/%u]",
show_dev(__entry->dev),
__entry->d_rd_peak, __entry->d_rd_avg, __entry->d_rd_cnt,
__entry->n_rd_peak, __entry->n_rd_avg, __entry->n_rd_cnt,
@@ -2126,7 +2133,8 @@ TRACE_EVENT(f2fs_iostat_latency,
__entry->m_wr_s_peak, __entry->m_wr_s_avg, __entry->m_wr_s_cnt,
__entry->d_wr_as_peak, __entry->d_wr_as_avg, __entry->d_wr_as_cnt,
__entry->n_wr_as_peak, __entry->n_wr_as_avg, __entry->n_wr_as_cnt,
- __entry->m_wr_as_peak, __entry->m_wr_as_avg, __entry->m_wr_as_cnt)
+ __entry->m_wr_as_peak, __entry->m_wr_as_avg, __entry->m_wr_as_cnt,
+ __entry->discard_peak, __entry->discard_avg, __entry->discard_cnt)
);
#endif
--
2.35.1
next prev parent reply other threads:[~2023-04-07 17:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-07 17:46 [PATCH v4 1/2] f2fs: refactor struct iostat_lat_info Yangtao Li
2023-04-07 17:46 ` Yangtao Li [this message]
2023-04-19 20:32 ` Jaegeuk Kim
2023-04-20 3:30 ` Yangtao Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230407174609.4939-2-frank.li@vivo.com \
--to=frank.li@vivo.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®