All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: axboe@kernel.dk, viro@zeniv.linux.org.uk, rostedt@goodmis.org,
	mingo@redhat.com, chaitanya.kulkarni@wdc.com,
	johannes.thumshirn@wdc.com, damien.lemoal@wdc.com,
	bvanassche@acm.org, dongli.zhang@oracle.com,
	aravind.ramesh@wdc.com, joshi.k@samsung.com,
	niklas.cassel@wdc.com, hch@lst.de, osandov@fb.com,
	martin.petersen@oracle.com
Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [RFC PATCH 28/39] blktrace: add blk_log_xxx helpers()
Date: Wed, 24 Feb 2021 23:02:20 -0800	[thread overview]
Message-ID: <20210225070231.21136-29-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20210225070231.21136-1-chaitanya.kulkarni@wdc.com>

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 kernel/trace/blktrace.c | 175 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 175 insertions(+)

diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 2241c7304749..425756a62457 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1905,6 +1905,23 @@ static void blk_log_action_classic(struct trace_iterator *iter, const char *act,
 			 secs, nsec_rem, iter->ent->pid, act, rwbs);
 }
 
+static void blk_log_action_classic_ext(struct trace_iterator *iter, const char *act,
+	bool has_cg)
+{
+	char rwbs[RWBS_LEN];
+	unsigned long long ts  = iter->ts;
+	unsigned long nsec_rem = do_div(ts, NSEC_PER_SEC);
+	unsigned secs	       = (unsigned long)ts;
+	const struct blk_io_trace_ext *t = te_blk_io_trace_ext(iter->ent);
+
+	fill_rwbs_ext(rwbs, t);
+
+	trace_seq_printf(&iter->seq,
+			 "%3d,%-3d %2d %5d.%09lu %5u %2s %3s ",
+			 MAJOR(t->device), MINOR(t->device), iter->cpu,
+			 secs, nsec_rem, iter->ent->pid, act, rwbs);
+}
+
 static void blk_log_action(struct trace_iterator *iter, const char *act,
 	bool has_cg)
 {
@@ -1947,6 +1964,35 @@ static void blk_log_action(struct trace_iterator *iter, const char *act,
 				 MAJOR(t->device), MINOR(t->device), act, rwbs);
 }
 
+static void blk_log_action_ext(struct trace_iterator *iter, const char *act,
+	bool has_cg)
+{
+	char rwbs[RWBS_LEN];
+	const struct blk_io_trace_ext *t = te_blk_io_trace_ext(iter->ent);
+
+	fill_rwbs_ext(rwbs, t);
+	if (has_cg) {
+		u64 id = t_cgid(iter->ent);
+
+		if (blk_tracer_flags.val & TRACE_BLK_OPT_CGNAME) {
+			char blkcg_name_buf[NAME_MAX + 1] = "<...>";
+
+			cgroup_path_from_kernfs_id(id, blkcg_name_buf,
+				sizeof(blkcg_name_buf));
+			trace_seq_printf(&iter->seq, "%3d,%-3d %s %2s %3s ",
+				 MAJOR(t->device), MINOR(t->device),
+				 blkcg_name_buf, act, rwbs);
+		} else
+			trace_seq_printf(&iter->seq,
+				 "%3d,%-3d %llx,%-llx %2s %3s ",
+				 MAJOR(t->device), MINOR(t->device),
+				 id & U32_MAX, id >> 32, act, rwbs);
+	} else
+		trace_seq_printf(&iter->seq, "%3d,%-3d %2s %3s ",
+				 MAJOR(t->device), MINOR(t->device), act, rwbs);
+}
+
+
 static void blk_log_dump_pdu(struct trace_seq *s,
 	const struct trace_entry *ent, bool has_cg)
 {
@@ -1986,6 +2032,45 @@ static void blk_log_dump_pdu(struct trace_seq *s,
 	trace_seq_puts(s, ") ");
 }
 
+static void blk_log_dump_pdu_ext(struct trace_seq *s,
+	const struct trace_entry *ent, bool has_cg)
+{
+	const unsigned char *pdu_buf;
+	int pdu_len;
+	int i, end;
+
+	pdu_buf = pdu_start_ext(ent, has_cg);
+	pdu_len = pdu_real_len_ext(ent, has_cg);
+
+	if (!pdu_len)
+		return;
+
+	/* find the last zero that needs to be printed */
+	for (end = pdu_len - 1; end >= 0; end--)
+		if (pdu_buf[end])
+			break;
+	end++;
+
+	trace_seq_putc(s, '(');
+
+	for (i = 0; i < pdu_len; i++) {
+
+		trace_seq_printf(s, "%s%02x",
+				 i == 0 ? "" : " ", pdu_buf[i]);
+
+		/*
+		 * stop when the rest is just zeroes and indicate so
+		 * with a ".." appended
+		 */
+		if (i == end && end != pdu_len - 1) {
+			trace_seq_puts(s, " ..) ");
+			return;
+		}
+	}
+
+	trace_seq_puts(s, ") ");
+}
+
 static void blk_log_generic(struct trace_seq *s, const struct trace_entry *ent, bool has_cg)
 {
 	char cmd[TASK_COMM_LEN];
@@ -2005,6 +2090,28 @@ static void blk_log_generic(struct trace_seq *s, const struct trace_entry *ent,
 	}
 }
 
+static void blk_log_generic_ext(struct trace_seq *s,
+				const struct trace_entry *ent,
+				bool has_cg)
+{
+	char cmd[TASK_COMM_LEN];
+
+	trace_find_cmdline(ent->pid, cmd);
+
+	if (t_action(ent) & BLK_TC_ACT_EXT(BLK_TC_PC)) {
+		trace_seq_printf(s, "%u ", t_bytes_ext(ent));
+		blk_log_dump_pdu_ext(s, ent, has_cg);
+		trace_seq_printf(s, "[%s]\n", cmd);
+	} else {
+		if (t_sec_ext(ent))
+			trace_seq_printf(s, "%llu + %u [%s]\n",
+						t_sector_ext(ent),
+						t_sec_ext(ent), cmd);
+		else
+			trace_seq_printf(s, "[%s]\n", cmd);
+	}
+}
+
 static void blk_log_with_error(struct trace_seq *s,
 			      const struct trace_entry *ent, bool has_cg)
 {
@@ -2022,6 +2129,23 @@ static void blk_log_with_error(struct trace_seq *s,
 	}
 }
 
+static void blk_log_with_error_ext(struct trace_seq *s,
+			      const struct trace_entry *ent, bool has_cg)
+{
+	if (t_action_ext(ent) & BLK_TC_ACT_EXT(BLK_TC_PC)) {
+		blk_log_dump_pdu_ext(s, ent, has_cg);
+		trace_seq_printf(s, "[%d]\n", t_error_ext(ent));
+	} else {
+		if (t_sec_ext(ent))
+			trace_seq_printf(s, "%llu + %u [%d]\n",
+					 t_sector_ext(ent),
+					 t_sec_ext(ent), t_error_ext(ent));
+		else
+			trace_seq_printf(s, "%llu [%d]\n",
+					 t_sector_ext(ent), t_error_ext(ent));
+	}
+}
+
 static void blk_log_remap(struct trace_seq *s, const struct trace_entry *ent, bool has_cg)
 {
 	const struct blk_io_trace_remap *__r = pdu_start(ent, has_cg);
@@ -2033,6 +2157,18 @@ static void blk_log_remap(struct trace_seq *s, const struct trace_entry *ent, bo
 			 be64_to_cpu(__r->sector_from));
 }
 
+static void blk_log_remap_ext(struct trace_seq *s, const struct trace_entry *ent,
+		bool has_cg)
+{
+	const struct blk_io_trace_remap *__r = pdu_start_ext(ent, has_cg);
+
+	trace_seq_printf(s, "%llu + %u <- (%d,%d) %llu\n",
+			 t_sector_ext(ent), t_sec_ext(ent),
+			 MAJOR(be32_to_cpu(__r->device_from)),
+			 MINOR(be32_to_cpu(__r->device_from)),
+			 be64_to_cpu(__r->sector_from));
+}
+
 static void blk_log_plug(struct trace_seq *s, const struct trace_entry *ent, bool has_cg)
 {
 	char cmd[TASK_COMM_LEN];
@@ -2042,6 +2178,16 @@ static void blk_log_plug(struct trace_seq *s, const struct trace_entry *ent, boo
 	trace_seq_printf(s, "[%s]\n", cmd);
 }
 
+static void blk_log_plug_ext(struct trace_seq *s, const struct trace_entry *ent,
+		bool has_cg)
+{
+	char cmd[TASK_COMM_LEN];
+
+	trace_find_cmdline(ent->pid, cmd);
+
+	trace_seq_printf(s, "[%s] %llu\n", cmd, get_pdu_int_ext(ent, has_cg));
+}
+
 static void blk_log_unplug(struct trace_seq *s, const struct trace_entry *ent, bool has_cg)
 {
 	char cmd[TASK_COMM_LEN];
@@ -2051,6 +2197,16 @@ static void blk_log_unplug(struct trace_seq *s, const struct trace_entry *ent, b
 	trace_seq_printf(s, "[%s] %llu\n", cmd, get_pdu_int(ent, has_cg));
 }
 
+static void blk_log_unplug_ext(struct trace_seq *s, const struct trace_entry *ent,
+		bool has_cg)
+{
+	char cmd[TASK_COMM_LEN];
+
+	trace_find_cmdline(ent->pid, cmd);
+
+	trace_seq_printf(s, "[%s] %llu\n", cmd, get_pdu_int_ext(ent, has_cg));
+}
+
 static void blk_log_split(struct trace_seq *s, const struct trace_entry *ent, bool has_cg)
 {
 	char cmd[TASK_COMM_LEN];
@@ -2061,6 +2217,16 @@ static void blk_log_split(struct trace_seq *s, const struct trace_entry *ent, bo
 			 get_pdu_int(ent, has_cg), cmd);
 }
 
+static void blk_log_split_ext(struct trace_seq *s, const struct trace_entry *ent, bool has_cg)
+{
+	char cmd[TASK_COMM_LEN];
+
+	trace_find_cmdline(ent->pid, cmd);
+
+	trace_seq_printf(s, "%llu / %llu [%s]\n", t_sector_ext(ent),
+			 get_pdu_int_ext(ent, has_cg), cmd);
+}
+
 static void blk_log_msg(struct trace_seq *s, const struct trace_entry *ent,
 			bool has_cg)
 {
@@ -2070,6 +2236,15 @@ static void blk_log_msg(struct trace_seq *s, const struct trace_entry *ent,
 	trace_seq_putc(s, '\n');
 }
 
+static void blk_log_msg_ext(struct trace_seq *s, const struct trace_entry *ent,
+			bool has_cg)
+{
+
+	trace_seq_putmem(s, pdu_start_ext(ent, has_cg),
+		pdu_real_len_ext(ent, has_cg));
+	trace_seq_putc(s, '\n');
+}
+
 /*
  * struct tracer operations
  */
-- 
2.22.1


  parent reply	other threads:[~2021-02-25  7:10 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25  7:01 [RFC PATCH 00/39] blktrace: add block trace extension support Chaitanya Kulkarni
2021-02-25  7:01 ` [RFC PATCH 01/39] blktrace_api: add new trace definitions Chaitanya Kulkarni
2021-02-26  4:31   ` Damien Le Moal
2021-02-25  7:01 ` [RFC PATCH 02/39] blktrace_api: add new trace definition Chaitanya Kulkarni
2021-02-26  4:33   ` Damien Le Moal
2021-02-25  7:01 ` [RFC PATCH 03/39] blkdev.h: add new trace ext as a queue member Chaitanya Kulkarni
2021-02-26  4:35   ` Damien Le Moal
2021-02-25  7:01 ` [RFC PATCH 04/39] blktrace: add a new global list Chaitanya Kulkarni
2021-02-26  4:36   ` Damien Le Moal
2021-02-25  7:01 ` [RFC PATCH 05/39] blktrace: add trace note APIs Chaitanya Kulkarni
2021-02-25  9:07   ` kernel test robot
2021-02-25 12:12   ` kernel test robot
2021-02-26  4:39   ` Damien Le Moal
2021-02-25  7:01 ` [RFC PATCH 06/39] blktrace: add act and prio check helpers Chaitanya Kulkarni
2021-02-26  4:41   ` Damien Le Moal
2021-02-25  7:01 ` [RFC PATCH 07/39] blktrace: add core trace API Chaitanya Kulkarni
2021-02-26  4:44   ` Damien Le Moal
2021-02-25  7:02 ` [RFC PATCH 08/39] blktrace: update blk_add_trace_rq() Chaitanya Kulkarni
2021-02-26  4:46   ` Damien Le Moal
2021-02-25  7:02 ` [RFC PATCH 09/39] blktrace: update blk_add_trace_rq_insert() Chaitanya Kulkarni
2021-02-26  4:48   ` Damien Le Moal
2021-02-25  7:02 ` [RFC PATCH 10/39] blktrace: update blk_add_trace_rq_issue() Chaitanya Kulkarni
2021-02-25 13:14   ` kernel test robot
2021-02-26  4:48   ` Damien Le Moal
2021-02-25  7:02 ` [RFC PATCH 11/39] blktrace: update blk_add_trace_rq_requeue() Chaitanya Kulkarni
2021-02-26  4:48   ` Damien Le Moal
2021-02-25  7:02 ` [RFC PATCH 12/39] blktrace: update blk_add_trace_rq_complete() Chaitanya Kulkarni
2021-02-26  4:48   ` Damien Le Moal
2021-02-25  7:02 ` [RFC PATCH 13/39] blktrace: update blk_add_trace_bio() Chaitanya Kulkarni
2021-02-26  4:49   ` Damien Le Moal
2021-02-25  7:02 ` [RFC PATCH 14/39] blktrace: update blk_add_trace_bio_bounce() Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 15/39] blktrace: update blk_add_trace_bio_complete() Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 16/39] blktrace: update blk_add_trace_bio_backmerge() Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 17/39] blktrace: update blk_add_trace_bio_frontmerge() Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 18/39] blktrace: update blk_add_trace_bio_queue() Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 19/39] blktrace: update blk_add_trace_getrq() Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 20/39] blktrace: update blk_add_trace_plug() Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 21/39] blktrace: update blk_add_trace_unplug() Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 22/39] blktrace: update blk_add_trace_split() Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 23/39] blktrace: update blk_add_trace_bio_remap() Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 24/39] blktrace: update blk_add_trace_rq_remap() Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 25/39] blktrace: update blk_add_driver_data() Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 26/39] blktrace: add trace entry & pdu helpers Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 27/39] blktrace: add a new formatting routine Chaitanya Kulkarni
2021-02-25  7:02 ` Chaitanya Kulkarni [this message]
2021-02-25  7:02 ` [RFC PATCH 29/39] blktrace: link blk_log_xxx() to trace action Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 30/39] blktrace: add trace event print helper Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 31/39] blktrace: add trace_synthesize helper Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 32/39] blktrace: add trace print helpers Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 33/39] blktrace: add blkext tracer Chaitanya Kulkarni
2021-02-27 11:44   ` [blktrace] c055908abe: WARNING:at_kernel/trace/trace.c:#create_trace_option_files kernel test robot
2021-02-27 11:44     ` kernel test robot
2021-02-27 14:49     ` Steven Rostedt
2021-02-27 14:49       ` Steven Rostedt
2021-02-27 19:51       ` Chaitanya Kulkarni
2021-02-27 19:51       ` Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 34/39] blktrace: implement setup-start-stop ioclts Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 35/39] block: update blkdev_ioctl with new trace ioctls Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 36/39] blktrace: add integrity tracking support Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 37/39] blktrace: update blk_fill_rwbs() with new requests Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 38/39] blktrace: track zone appaend completion sector Chaitanya Kulkarni
2021-02-25  7:02 ` [RFC PATCH 39/39] blktrace: debug patch for the demo Chaitanya Kulkarni
2021-02-26  4:25 ` [RFC PATCH 00/39] blktrace: add block trace extension support Damien Le Moal

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=20210225070231.21136-29-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=aravind.ramesh@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=damien.lemoal@wdc.com \
    --cc=dongli.zhang@oracle.com \
    --cc=hch@lst.de \
    --cc=johannes.thumshirn@wdc.com \
    --cc=joshi.k@samsung.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mingo@redhat.com \
    --cc=niklas.cassel@wdc.com \
    --cc=osandov@fb.com \
    --cc=rostedt@goodmis.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.