From: Daniel Walter <dwalter@sigma-star.at>
To: linux-mtd@lists.infradead.org
Subject: [RFC] [PATCH] mtd: add tracepoints for mtd_read and mtd_write
Date: Tue, 17 Nov 2015 20:18:01 +0100 [thread overview]
Message-ID: <20151117191801.GA864@dw-nb.local> (raw)
In-Reply-To: <20151117191448.GA5367@dw-nb.local>
Add tracepoints to mtd subsystem for read and write
operations. This should allow us to identify applications
which are generating too much reads/writes on a flash-device.
Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
---
drivers/mtd/mtdcore.c | 6 +++++-
include/trace/events/mtd.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 1 deletion(-)
create mode 100644 include/trace/events/mtd.h
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 8bbbb75..8f85bfb 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -43,6 +43,9 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
+#define CREATE_TRACE_POINTS
+#include <trace/events/mtd.h>
+
#include "mtdcore.h"
static struct backing_dev_info mtd_bdi = {
@@ -882,7 +885,7 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
return -EINVAL;
if (!len)
return 0;
-
+ trace_mtd_read(current, len);
/*
* In the absence of an error, drivers return a non-negative integer
* representing the maximum number of bitflips that were corrected on
@@ -907,6 +910,7 @@ int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
return -EROFS;
if (!len)
return 0;
+ trace_mtd_write(current, len);
return mtd->_write(mtd, to, len, retlen, buf);
}
EXPORT_SYMBOL_GPL(mtd_write);
diff --git a/include/trace/events/mtd.h b/include/trace/events/mtd.h
new file mode 100644
index 0000000..7191b72
--- /dev/null
+++ b/include/trace/events/mtd.h
@@ -0,0 +1,45 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM mtd
+
+#if !defined(_TRACE_MTD_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_MTD_H
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(mtd_read,
+ TP_PROTO(struct task_struct *task, size_t rlen),
+ TP_ARGS(task, rlen),
+ TP_STRUCT__entry(
+ __field(pid_t, pid)
+ __array(char, comm, TASK_COMM_LEN)
+ __field(size_t, rlen)
+ ),
+ TP_fast_assign(
+ __entry->pid = task->pid;
+ memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
+ __entry->rlen = rlen;
+ ),
+ TP_printk("pid=%d comm=%s rlen=%zu",
+ __entry->pid, __entry->comm, __entry->rlen)
+);
+
+TRACE_EVENT(mtd_write,
+ TP_PROTO(struct task_struct *task, size_t wlen),
+ TP_ARGS(task, wlen),
+ TP_STRUCT__entry(
+ __field(pid_t, pid)
+ __array(char, comm, TASK_COMM_LEN)
+ __field(size_t, wlen)
+ ),
+ TP_fast_assign(
+ __entry->pid = task->pid;
+ memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
+ __entry->wlen = wlen;
+ ),
+ TP_printk("pid=%d comm=%s wlen=%zu",
+ __entry->pid, __entry->comm, __entry->wlen)
+);
+#endif /* _TRACE_MTD_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
--
2.6.2
next prev parent reply other threads:[~2015-11-17 19:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-17 19:14 [RFC] Trace-events for mtd Daniel Walter
2015-11-17 19:18 ` Daniel Walter [this message]
2016-01-08 9:33 ` [RFC] [PATCH] mtd: add tracepoints for mtd_read and mtd_write Richard Weinberger
2016-01-08 17:57 ` Brian Norris
2016-01-14 1:12 ` Daniel Walter
2016-01-08 18:00 ` [RFC] Trace-events for mtd Brian Norris
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=20151117191801.GA864@dw-nb.local \
--to=dwalter@sigma-star.at \
--cc=linux-mtd@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).