From: Hengqi Chen <hengqi.chen@gmail.com>
To: linux-block@vger.kernel.org
Cc: axboe@kernel.dk, rostedt@goodmis.org, mhiramat@kernel.org,
bpf@vger.kernel.org, yhs@meta.com, hengqi.chen@gmail.com,
Francis Laniel <flaniel@linux.microsoft.com>
Subject: [PATCH] block: introduce block_io_start/block_io_done tracepoints
Date: Sat, 20 May 2023 08:40:57 +0000 [thread overview]
Message-ID: <20230520084057.1467003-1-hengqi.chen@gmail.com> (raw)
Currently, several BCC ([0]) tools (biosnoop/biostacks/biotop) use
kprobes to blk_account_io_start/blk_account_io_done to implement
their functionalities. This is fragile because the target kernel
functions may be renamed ([1]) or inlined ([2]). So introduces two
new tracepoints for such use cases.
[0]: https://github.com/iovisor/bcc
[1]: https://github.com/iovisor/bcc/issues/3954
[2]: https://github.com/iovisor/bcc/issues/4261
Tested-by: Francis Laniel <flaniel@linux.microsoft.com>
Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
---
block/blk-mq.c | 4 ++++
include/trace/events/block.h | 26 ++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index f6dad0886a2f..faa1c7992876 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -957,6 +957,8 @@ EXPORT_SYMBOL_GPL(blk_update_request);
static inline void blk_account_io_done(struct request *req, u64 now)
{
+ trace_block_io_done(req);
+
/*
* Account IO completion. flush_rq isn't accounted as a
* normal IO on queueing nor completion. Accounting the
@@ -976,6 +978,8 @@ static inline void blk_account_io_done(struct request *req, u64 now)
static inline void blk_account_io_start(struct request *req)
{
+ trace_block_io_start(req);
+
if (blk_do_io_stat(req)) {
/*
* All non-passthrough requests are created from a bio with one
diff --git a/include/trace/events/block.h b/include/trace/events/block.h
index 7f4dfbdf12a6..40e60c33cc6f 100644
--- a/include/trace/events/block.h
+++ b/include/trace/events/block.h
@@ -245,6 +245,32 @@ DEFINE_EVENT(block_rq, block_rq_merge,
TP_ARGS(rq)
);
+/**
+ * block_io_start - insert a request for execution
+ * @rq: block IO operation request
+ *
+ * Called when block operation request @rq is queued for execution
+ */
+DEFINE_EVENT(block_rq, block_io_start,
+
+ TP_PROTO(struct request *rq),
+
+ TP_ARGS(rq)
+);
+
+/**
+ * block_io_done - block IO operation request completed
+ * @rq: block IO operation request
+ *
+ * Called when block operation request @rq is completed
+ */
+DEFINE_EVENT(block_rq, block_io_done,
+
+ TP_PROTO(struct request *rq),
+
+ TP_ARGS(rq)
+);
+
/**
* block_bio_complete - completed all work on the block operation
* @q: queue holding the block operation
--
2.34.1
next reply other threads:[~2023-05-20 8:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-20 8:40 Hengqi Chen [this message]
2023-05-21 3:51 ` [PATCH] block: introduce block_io_start/block_io_done tracepoints Yonghong Song
2023-05-24 14:16 ` Jens Axboe
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=20230520084057.1467003-1-hengqi.chen@gmail.com \
--to=hengqi.chen@gmail.com \
--cc=axboe@kernel.dk \
--cc=bpf@vger.kernel.org \
--cc=flaniel@linux.microsoft.com \
--cc=linux-block@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=yhs@meta.com \
/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