linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH blktrace-tools 00/10] blktrace: add blktrace extension support
@ 2019-05-01  4:33 Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 01/10] blktrace.h: add blktrace extension to the header Chaitanya Kulkarni
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Chaitanya Kulkarni @ 2019-05-01  4:33 UTC (permalink / raw)
  To: linux-block; +Cc: Chaitanya Kulkarni

Hi,

This patch series adds support to track more request based flags and different
request field to the blktrace infrastructure.

This is patch-series focuses on the userspace tools of the blktrace
infrastructure.

For more details about kernel part please refer to the following
patchh-series :-

Chaitanya Kulkarni (18):
	blktrace: increase the size of action mask
	blktrace: add more definitions for BLK_TC_ACT
	blktrace: update trace to track more actions
	kernel/trace: add KConfig to enable blktrace_ext
	blktrace: add iopriority mask
	blktrace: add iopriority mask
	blktrace: allow user to track iopriority
	blktrace: add sysfs ioprio mask
	blktrace: add debug support for extension
	block: set ioprio for write-zeroes, discard etc 
	block: set ioprio for zone-reset
	block: set ioprio for flush bio 
	drivers: set bio iopriority field
	fs: set bio iopriority field
	power/swap: set bio iopriority field
	mm: set bio iopriority field
	null_blk: add write-zeroes flag to nullb_device
	null_blk: add module param discard/write-zeroes

Chaitanya Kulkarni (10):
  blktrace.h: add blktrace extension to the header
  blktrace_api.h: update blktrace API header
  act-mask: add blktrace extension to act_mask
  blktrace.c: add support for extensions
  blkparse.c: add support for extensions
  blkparse-fmt.c: add extension support
  iowatcher/blkparse: add extension definitions
  blkiomon: add extension support
  blkrawverify: add extension support
  blktrace-tools: add extension support

 Makefile             |  3 +-
 act_mask.c           | 60 ++++++++++++++++++++++++++++---
 blkiomon.c           | 16 +++++++++
 blkparse.c           | 85 ++++++++++++++++++++++++++++++++++++++++++--
 blkparse_fmt.c       | 76 +++++++++++++++++++++++++++++++++++++++
 blkrawverify.c       | 26 ++++++++++++--
 blktrace.c           | 85 +++++++++++++++++++++++++++++++++++++++++---
 blktrace.h           | 46 +++++++++++++++++++++++-
 blktrace_api.h       | 66 ++++++++++++++++++++++++----------
 iowatcher/blkparse.c | 70 +++++++++++++++++++++++++-----------
 10 files changed, 477 insertions(+), 56 deletions(-)

-- 
2.19.1


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

* [RFC PATCH blktrace-tools 01/10] blktrace.h: add blktrace extension to the header
  2019-05-01  4:33 [RFC PATCH blktrace-tools 00/10] blktrace: add blktrace extension support Chaitanya Kulkarni
@ 2019-05-01  4:33 ` Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 02/10] blktrace_api.h: update blktrace API header Chaitanya Kulkarni
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Chaitanya Kulkarni @ 2019-05-01  4:33 UTC (permalink / raw)
  To: linux-block; +Cc: Chaitanya Kulkarni

This patch adds blktrace extension definitions to the central header
file blktrace.h. Here we also add priority related constants which are
used in the next few patches.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 blktrace.h | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/blktrace.h b/blktrace.h
index 944fc08..17f9f8d 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -6,6 +6,7 @@
 #include <byteswap.h>
 #include <endian.h>
 #include <sys/types.h>
+#include <stdbool.h>
 
 #include "blktrace_api.h"
 #include "rbtree.h"
@@ -26,6 +27,38 @@
 #define t_kb(t)		((t)->bytes >> 10)
 #define t_b(t)		((t)->bytes & 1023)
 
+#ifdef CONFIG_BLKTRACE_EXT
+/*
+ * Gives us 8 prio classes with 13-bits of data for each class
+ */
+#define IOPRIO_CLASS_SHIFT      (13)
+#define IOPRIO_PRIO_MASK        ((1UL << IOPRIO_CLASS_SHIFT) - 1)
+
+#define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT)
+#define IOPRIO_PRIO_DATA(mask)  ((mask) & IOPRIO_PRIO_MASK)
+#define IOPRIO_PRIO_VALUE(class, data)  (((class) << IOPRIO_CLASS_SHIFT) | data)
+
+#define ioprio_valid(mask)      (IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE)
+
+/*
+ * These are the io priority groups as implemented by CFQ. RT is the realtime
+ * class, it always gets premium service. BE is the best-effort scheduling
+ * class, the default for any process. IDLE is the idle scheduling class, it
+ * is only served when no one else is using the disk.
+ */
+enum {
+	IOPRIO_CLASS_NONE,
+	IOPRIO_CLASS_RT,
+	IOPRIO_CLASS_BE,
+	IOPRIO_CLASS_IDLE,
+	IOPRIO_CLASS_LAST,
+};
+
+#define TRACE_ALL_IOPRIO ((1 << IOPRIO_CLASS_NONE) | (1 << IOPRIO_CLASS_RT) | \
+		(1 << IOPRIO_CLASS_BE) | (1 << IOPRIO_CLASS_IDLE))
+
+#endif /* CONFIG_BLKTRACE_EXT */
+
 typedef __u32 u32;
 typedef __u8 u8;
 
@@ -68,7 +101,11 @@ extern int data_is_native;
 extern struct timespec abs_start_time;
 
 #define CHECK_MAGIC(t)		(((t)->magic & 0xffffff00) == BLK_IO_TRACE_MAGIC)
+#ifdef CONFIG_BLKTRACE_EXT
+#define SUPPORTED_VERSION	(0x08)
+#else
 #define SUPPORTED_VERSION	(0x07)
+#endif
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define be16_to_cpu(x)		__bswap_16(x)
@@ -95,7 +132,7 @@ static inline int verify_trace(struct blk_io_trace *t)
 		return 1;
 	}
 	if ((t->magic & 0xff) != SUPPORTED_VERSION) {
-		fprintf(stderr, "unsupported trace version %x\n", 
+		fprintf(stderr, "unsupported trace version %x\n",
 			t->magic & 0xff);
 		return 1;
 	}
-- 
2.19.1


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

* [RFC PATCH blktrace-tools 02/10] blktrace_api.h: update blktrace API header
  2019-05-01  4:33 [RFC PATCH blktrace-tools 00/10] blktrace: add blktrace extension support Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 01/10] blktrace.h: add blktrace extension to the header Chaitanya Kulkarni
@ 2019-05-01  4:33 ` Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 03/10] act-mask: add blktrace extension to act_mask Chaitanya Kulkarni
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Chaitanya Kulkarni @ 2019-05-01  4:33 UTC (permalink / raw)
  To: linux-block; +Cc: Chaitanya Kulkarni

This patch adds blktrace extension definitions to the blktrace_api.h
file. Here we add new block operations write-zeroes and zone reset.
Also, we update the size of the block trace action and add a new field
to mask the priorities.

Mainly we change the size of the action in the blk_io_trace and
size of action mask to keep it uniform across all the headers
and the kernel which allows us to add new trace actions.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 blktrace_api.h | 66 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 47 insertions(+), 19 deletions(-)

diff --git a/blktrace_api.h b/blktrace_api.h
index b222218..ac2ea43 100644
--- a/blktrace_api.h
+++ b/blktrace_api.h
@@ -2,34 +2,47 @@
 #define BLKTRACEAPI_H
 
 #include <asm/types.h>
+#include <stdint.h>
 
 /*
  * Trace categories
  */
-enum {
-	BLK_TC_READ	= 1 << 0,	/* reads */
-	BLK_TC_WRITE	= 1 << 1,	/* writes */
-	BLK_TC_FLUSH	= 1 << 2,	/* flush */
-	BLK_TC_SYNC	= 1 << 3,	/* sync */
-	BLK_TC_QUEUE	= 1 << 4,	/* queueing/merging */
-	BLK_TC_REQUEUE	= 1 << 5,	/* requeueing */
-	BLK_TC_ISSUE	= 1 << 6,	/* issue */
-	BLK_TC_COMPLETE	= 1 << 7,	/* completions */
-	BLK_TC_FS	= 1 << 8,	/* fs requests */
-	BLK_TC_PC	= 1 << 9,	/* pc requests */
-	BLK_TC_NOTIFY	= 1 << 10,	/* special message */
-	BLK_TC_AHEAD	= 1 << 11,	/* readahead */
-	BLK_TC_META	= 1 << 12,	/* metadata */
-	BLK_TC_DISCARD	= 1 << 13,	/* discard requests */
-	BLK_TC_DRV_DATA	= 1 << 14,	/* binary driver data */
-	BLK_TC_FUA	= 1 << 15,	/* fua requests */
+enum blktrace_cat {
+	BLK_TC_READ             = 1 << 0,       /* reads */
+	BLK_TC_WRITE            = 1 << 1,       /* writes */
+	BLK_TC_FLUSH            = 1 << 2,       /* flush */
+	BLK_TC_SYNC             = 1 << 3,       /* sync IO */
+	BLK_TC_SYNCIO           = BLK_TC_SYNC,
+	BLK_TC_QUEUE            = 1 << 4,       /* queueing/merging */
+	BLK_TC_REQUEUE          = 1 << 5,       /* requeueing */
+	BLK_TC_ISSUE            = 1 << 6,       /* issue */
+	BLK_TC_COMPLETE         = 1 << 7,       /* completions */
+	BLK_TC_FS               = 1 << 8,       /* fs requests */
+	BLK_TC_PC               = 1 << 9,       /* pc requests */
+	BLK_TC_NOTIFY           = 1 << 10,      /* special message */
+	BLK_TC_AHEAD            = 1 << 11,      /* readahead */
+	BLK_TC_META             = 1 << 12,      /* metadata */
+	BLK_TC_DISCARD          = 1 << 13,      /* discard requests */
+	BLK_TC_DRV_DATA         = 1 << 14,      /* binary per-driver data */
+	BLK_TC_FUA              = 1 << 15,      /* fua requests */
+
+#ifdef CONFIG_BLKTRACE_EXT
+	BLK_TC_WRITE_ZEROES	= 1 << 16,	/* write-zeores */
+	BLK_TC_ZONE_RESET	= 1 << 17,	/* zone-reset */
 
-	BLK_TC_END	= 1 << 15,	/* we've run out of bits! */
+	BLK_TC_END		= 1 << 31,	/* we've run out of bits! */
+#else
+	BLK_TC_END		= 1 << 15,	/* we've run out of bits! */
+#endif /* CONFIG_BLKTRACE_EXT */
 };
 
+#ifdef CONFIG_BLKTRACE_EXT
+#define BLK_TC_SHIFT		(32)
+#define BLK_TC_ACT(act)		(((uint64_t)act) << BLK_TC_SHIFT)
+#else
 #define BLK_TC_SHIFT		(16)
 #define BLK_TC_ACT(act)		((act) << BLK_TC_SHIFT)
-
+#endif /* CONFIG_BLKTRACE_EXT */
 /*
  * Basic trace actions
  */
@@ -88,7 +101,12 @@ enum blktrace_notify {
 #define BLK_TN_MESSAGE		(__BLK_TN_MESSAGE | BLK_TC_ACT(BLK_TC_NOTIFY))
 
 #define BLK_IO_TRACE_MAGIC	0x65617400
+
+#ifdef CONFIG_BLKTRACE_EXT
+#define BLK_IO_TRACE_VERSION	0x08
+#else
 #define BLK_IO_TRACE_VERSION	0x07
+#endif /* CONFIG_BLKTRACE_EXT */
 
 /*
  * The trace itself
@@ -99,7 +117,12 @@ struct blk_io_trace {
 	__u64 time;		/* in nanoseconds */
 	__u64 sector;		/* disk offset */
 	__u32 bytes;		/* transfer length */
+#ifdef CONFIG_BLKTRACE_EXT
+	__u64 action;		/* what happened */
+	__u32 ioprio;		/* ioprio */
+#else
 	__u32 action;		/* what happened */
+#endif /* CONFIG_BLKTRACE_EXT */
 	__u32 pid;		/* who did it */
 	__u32 device;		/* device identifier (dev_t) */
 	__u32 cpu;		/* on what cpu did it happen */
@@ -121,7 +144,12 @@ struct blk_io_trace_remap {
  */
 struct blk_user_trace_setup {
 	char name[32];			/* output */
+#ifdef CONFIG_BLKTRACE_EXT
+	__u64 act_mask;			/* input */
+	__u32 prio_mask;		/* input */
+#else
 	__u16 act_mask;			/* input */
+#endif /* CONFIG_BLKTRACE_EXT */
 	__u32 buf_size;			/* input */
 	__u32 buf_nr;			/* input */
 	__u64 start_lba;
-- 
2.19.1


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

* [RFC PATCH blktrace-tools 03/10] act-mask: add blktrace extension to act_mask
  2019-05-01  4:33 [RFC PATCH blktrace-tools 00/10] blktrace: add blktrace extension support Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 01/10] blktrace.h: add blktrace extension to the header Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 02/10] blktrace_api.h: update blktrace API header Chaitanya Kulkarni
@ 2019-05-01  4:33 ` Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 04/10] blktrace.c: add support for extensions Chaitanya Kulkarni
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Chaitanya Kulkarni @ 2019-05-01  4:33 UTC (permalink / raw)
  To: linux-block; +Cc: Chaitanya Kulkarni

This patch adds the support for blktrace action mask to accommodate
more operations like write-zeroes and zone reset etc.

Also, we add support to use the priority mask in the existing
infrastructure. We also update the existing helpers to manage
action mask and add similar helpers for priority mask.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 act_mask.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 blktrace.h |  6 ++++++
 2 files changed, 62 insertions(+), 4 deletions(-)

diff --git a/act_mask.c b/act_mask.c
index 8f1b8d7..09bda08 100644
--- a/act_mask.c
+++ b/act_mask.c
@@ -1,7 +1,15 @@
 #include <strings.h>
+
+#ifdef CONFIG_BLKTRACE_EXT
+#include <stdint.h>
+#endif /* CONFIG_BLKTRACE_EXT */
 #include "blktrace.h"
 
 #define DECLARE_MASK_MAP(mask)          { BLK_TC_##mask, #mask, "BLK_TC_"#mask }
+#ifdef CONFIG_BLKTRACE_EXT
+#define DECLARE_PRIO_CLASS_MASK_MAP(mask) \
+	{ (1 << IOPRIO_CLASS_##mask), #mask, "IOPRIO_CLASS_"#mask }
+#endif /* CONFIG_BLKTRACE_EXT */
 #define COMPARE_MASK_MAP(mmp, str)                                      \
         (!strcasecmp((mmp)->short_form, (str)) ||                      \
          !strcasecmp((mmp)->long_form, (str)))
@@ -29,20 +37,64 @@ static struct mask_map mask_maps[] = {
 	DECLARE_MASK_MAP(DISCARD),
 	DECLARE_MASK_MAP(DRV_DATA),
 	DECLARE_MASK_MAP(FUA),
+#ifdef CONFIG_BLKTRACE_EXT
+	DECLARE_MASK_MAP(WRITE_ZEROES),
+	DECLARE_MASK_MAP(ZONE_RESET),
+#endif /* CONFIG_BLKTRACE_EXT */
 };
 
-int find_mask_map(char *string)
+#ifdef CONFIG_BLKTRACE_EXT
+
+/**
+ * I/O Priority Map mask based on ${KERNEL_SRC_DIR}/include/linux/ioprio.h.
+ */
+static struct mask_map prio_map[] = {
+	DECLARE_PRIO_CLASS_MASK_MAP(NONE),
+	DECLARE_PRIO_CLASS_MASK_MAP(RT),
+	DECLARE_PRIO_CLASS_MASK_MAP(BE),
+	DECLARE_PRIO_CLASS_MASK_MAP(IDLE),
+};
+
+/**
+ * I/O Priority Map mask search for valid ioprio string value.
+ */
+int find_prio_mask_map(char *string)
 {
 	unsigned int i;
 
-	for (i = 0; i < sizeof(mask_maps)/sizeof(mask_maps[0]); i++)
-		if (COMPARE_MASK_MAP(&mask_maps[i], string))
-			return mask_maps[i].mask;
+	for (i = 0; i < sizeof(prio_maps)/sizeof(prio_maps[0]); i++)
+		if (COMPARE_MASK_MAP(&prio_map[i], string))
+			return prio_map[i].mask;
 
 	return -1;
 }
 
+/**
+ * I/O Priority Map mask search for valid ioprio mask.
+ */
+bool valid_prio_opt(uint32_t x)
+{
+	return (x & 0xFFFFFFF0) ? false : true;
+}
+
+uint64_t valid_act_opt(uint64_t x)
+{
+	return (1 <= x) && (x < (1ULL << BLK_TC_SHIFT));
+}
+#else
 int valid_act_opt(int x)
 {
 	return (1 <= x) && (x < (1 << BLK_TC_SHIFT));
 }
+#endif /* CONFIG_BLKTRACE_EXT */
+
+int find_mask_map(char *string)
+{
+	unsigned int i;
+
+	for (i = 0; i < sizeof(mask_maps)/sizeof(mask_maps[0]); i++)
+		if (COMPARE_MASK_MAP(&mask_maps[i], string))
+			return mask_maps[i].mask;
+
+	return -1;
+}
diff --git a/blktrace.h b/blktrace.h
index 17f9f8d..c860bf9 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -181,7 +181,13 @@ extern void set_all_format_specs(char *);
 extern int add_format_spec(char *);
 extern void process_fmt(char *, struct per_cpu_info *, struct blk_io_trace *,
 			unsigned long long, int, unsigned char *);
+#ifdef CONFIG_BLKTRACE_EXT
+extern uint64_t valid_act_opt(uint64_t); /* adjusted act mask for extension */
+extern bool valid_prio_opt(uint32_t x);  /* validate priority mask */
+int find_prio_mask_map(char *string);    /* find prio mask from user input */
+#else
 extern int valid_act_opt(int);
+#endif /* CONFIG_BLKTRACE_EXT */
 extern int find_mask_map(char *);
 extern char *find_process_name(pid_t);
 
-- 
2.19.1


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

* [RFC PATCH blktrace-tools 04/10] blktrace.c: add support for extensions
  2019-05-01  4:33 [RFC PATCH blktrace-tools 00/10] blktrace: add blktrace extension support Chaitanya Kulkarni
                   ` (2 preceding siblings ...)
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 03/10] act-mask: add blktrace extension to act_mask Chaitanya Kulkarni
@ 2019-05-01  4:33 ` Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 05/10] blkparse.c: " Chaitanya Kulkarni
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Chaitanya Kulkarni @ 2019-05-01  4:33 UTC (permalink / raw)
  To: linux-block; +Cc: Chaitanya Kulkarni

This patch adds support for blktrace tool to use the blktrace extension.
Here we also add the support for priority tracking and using priority
mask from the command line just like action mask.

Here we also increase the size of the various bufferes.
We add three new command line options so that user can specify whethere
to track priority and priority mask just like actiom mask.
In order to keep the backward compaibility we by default we turn off
the priority tracking.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 blktrace.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 80 insertions(+), 5 deletions(-)

diff --git a/blktrace.c b/blktrace.c
index d0d271f..e5105f5 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -57,10 +57,17 @@
  * You may want to increase this even more, if you are logging at a high
  * rate and see skipped/missed events
  */
+#ifdef CONFIG_BLKTRACE_EXT
+#define BUF_SIZE		(1024 * 1024)
+#define BUF_NR			(4)
+
+#define FILE_VBUF_SIZE		(256 * 1024)
+#else
 #define BUF_SIZE		(512 * 1024)
 #define BUF_NR			(4)
 
 #define FILE_VBUF_SIZE		(128 * 1024)
+#endif /* CONFIG_BLKTRACE_EXT */
 
 #define DEBUGFS_TYPE		(0x64626720)
 #define TRACE_NET_PORT		(8462)
@@ -279,7 +286,15 @@ static int max_cpus;
 static int ncpus;
 static cpu_set_t *online_cpus;
 static int pagesize;
+
+#ifdef CONFIG_BLKTRACE_EXT
+static uint64_t act_mask = -1ULL;
+/* by default don't trace priority */
+static uint32_t blktrace_prio_mask = 0;
+int btrace_track_prio;
+#else
 static int act_mask = ~0U;
+#endif /* CONFIG_BLKTRACE_EXT */
 static int kill_running_trace;
 static int stop_watch;
 static int piped_output;
@@ -329,7 +344,11 @@ static int *cl_fds;
 static int (*handle_pfds)(struct tracer *, int, int);
 static int (*handle_list)(struct tracer_devpath_head *, struct list_head *);
 
+#ifdef CONFIG_BLKTRACE_EXT
+#define S_OPTS	"d:a:A:r:o:kw:vVb:n:D:lh:p:sI:Px:X:"
+#else
 #define S_OPTS	"d:a:A:r:o:kw:vVb:n:D:lh:p:sI:"
+#endif /* CONFIG_BLKTRACE_EXT */
 static struct option l_opts[] = {
 	{
 		.name = "dev",
@@ -427,6 +446,24 @@ static struct option l_opts[] = {
 		.flag = NULL,
 		.val = 'p'
 	},
+	{
+		.name = "track-priority",
+		.has_arg = no_argument,
+		.flag = NULL,
+		.val = 'P'
+	},
+	{
+		.name = "prio-mask",
+		.has_arg = required_argument,
+		.flag = NULL,
+		.val = 'x'
+	},
+	{
+		.name = "prio-set-mask",
+		.has_arg = required_argument,
+		.flag = NULL,
+		.val = 'X'
+	},
 	{
 		.name = "no-sendfile",
 		.has_arg = no_argument,
@@ -453,6 +490,9 @@ static char usage_str[] = "\n\n" \
         "[ -p <port number>   | --port=<port number>]\n" \
         "[ -s                 | --no-sendfile]\n" \
         "[ -I <devs file>     | --input-devs=<devs file>]\n" \
+        "[ -P                 | --track-priority ]\n" \
+        "[ -x <ioprio field>  | --prio-mask=<ioprio field> ]\n" \
+        "[ -X <ioprio mask>   | --set-mask=<ioprio mask> ]\n" \
         "[ -v <version>       | --version]\n" \
         "[ -V <version>       | --version]\n" \
 
@@ -468,6 +508,9 @@ static char usage_str[] = "\n\n" \
 	"\t-l Run in network listen mode (blktrace server)\n" \
 	"\t-h Run in network client mode, connecting to the given host\n" \
 	"\t-p Network port to use (default 8462)\n" \
+	"\t-P Enable tracking priorites.\n" \
+	"\t-a Only priority specified actions.\n" \
+	"\t-A Give priority mask as a single value.\n" \
 	"\t-s Make the network client NOT use sendfile() to transfer data\n" \
 	"\t-I Add devices found in <devs file>\n" \
 	"\t-v Print program version info\n" \
@@ -633,11 +676,11 @@ static int lock_on_cpu(int cpu)
 	CPU_ZERO_S(size, cpu_mask);
 	CPU_SET_S(cpu, size, cpu_mask);
 	if (sched_setaffinity(0, size, cpu_mask) < 0) {
-		CPU_FREE(cpu_mask);		
+		CPU_FREE(cpu_mask);
 		return errno;
 	}
 
-	CPU_FREE(cpu_mask);		
+	CPU_FREE(cpu_mask);
 	return 0;
 }
 
@@ -1080,7 +1123,9 @@ static int setup_buts(void)
 		buts.buf_size = buf_size;
 		buts.buf_nr = buf_nr;
 		buts.act_mask = act_mask;
-
+#ifdef CONFIG_BLKTRACE_EXT
+		buts.prio_mask = btrace_track_prio ? blktrace_prio_mask : 0;
+#endif /* CONFIG_BLKTRACE_EXT */
 		if (ioctl(dpp->fd, BLKTRACESETUP, &buts) >= 0) {
 			dpp->ncpus = max_cpus;
 			dpp->buts_name = strdup(buts.name);
@@ -2104,7 +2149,7 @@ static int handle_args(int argc, char *argv[])
 {
 	int c, i;
 	struct statfs st;
-	int act_mask_tmp = 0;
+	unsigned int act_mask_tmp = 0;
 
 	while ((c = getopt_long(argc, argv, S_OPTS, l_opts, NULL)) >= 0) {
 		switch (c) {
@@ -2211,6 +2256,29 @@ static int handle_args(int argc, char *argv[])
 		case 'p':
 			net_port = atoi(optarg);
 			break;
+#ifdef CONFIG_BLKTRACE_EXT
+		case 'P': /* enable priority tracking */
+			btrace_track_prio = 1;
+			break;
+		case 'x': /* priority mask values in string */
+			i = find_prio_mask_map(optarg);
+			if (i < 0) {
+				fprintf(stderr,"Invalid prio mask %s\n",
+						optarg);
+				return 1;
+			}
+			blktrace_prio_mask |= i;
+			break;
+		case 'X': /* priority mask values in hex */
+			if ((sscanf(optarg, "%x", &i) != 1) ||
+					!valid_prio_opt(i)) {
+				fprintf(stderr, "Invalid prio mask %s/0x%x\n",
+						optarg, i);
+				return 1;
+			}
+			blktrace_prio_mask = i;
+			break;
+#endif /* CONFIG_BLKTRACE_EXT */
 		case 's':
 			net_use_sendfile = 0;
 			break;
@@ -2243,7 +2311,14 @@ static int handle_args(int argc, char *argv[])
 
 	if (act_mask_tmp != 0)
 		act_mask = act_mask_tmp;
-
+#ifdef CONFIG_BLKTRACE_EXT
+	/*
+	 * When track-priority is on and user didn't specify prio_mask then
+	 * trace all the classes.
+	 */
+	if (btrace_track_prio && !blktrace_prio_mask)
+		blktrace_prio_mask = TRACE_ALL_IOPRIO;
+#endif /* CONFIG_BLKTRACE_EXT */
 	if (net_mode == Net_client && net_setup_addr())
 		return 1;
 
-- 
2.19.1


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

* [RFC PATCH blktrace-tools 05/10] blkparse.c: add support for extensions
  2019-05-01  4:33 [RFC PATCH blktrace-tools 00/10] blktrace: add blktrace extension support Chaitanya Kulkarni
                   ` (3 preceding siblings ...)
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 04/10] blktrace.c: add support for extensions Chaitanya Kulkarni
@ 2019-05-01  4:33 ` Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 06/10] blkparse-fmt.c: add extension support Chaitanya Kulkarni
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Chaitanya Kulkarni @ 2019-05-01  4:33 UTC (permalink / raw)
  To: linux-block; +Cc: Chaitanya Kulkarni

This patch adds support for blkparse tool to use the blktrace extension.
Here we also add the support for priority tracking and using priority
mask from the command line just like action mask.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 blkparse.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 blktrace.h |  1 +
 2 files changed, 83 insertions(+), 3 deletions(-)

diff --git a/blkparse.c b/blkparse.c
index 227cc44..228c8d6 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -105,7 +105,7 @@ static struct per_process_info *ppi_list;
 static int ppi_list_entries;
 
 static struct option l_opts[] = {
- 	{
+	{
 		.name = "act-mask",
 		.has_arg = required_argument,
 		.flag = NULL,
@@ -177,6 +177,26 @@ static struct option l_opts[] = {
 		.flag = NULL,
 		.val = 'O'
 	},
+#ifdef CONFIG_BLKTRACE_EXT
+	{
+		.name = "track-priority",
+		.has_arg = no_argument,
+		.flag = NULL,
+		.val = 'p'
+	},
+	{
+		.name = "prio-mask",
+		.has_arg = required_argument,
+		.flag = NULL,
+		.val = 'x'
+	},
+	{
+		.name = "prio-set-mask",
+		.has_arg = required_argument,
+		.flag = NULL,
+		.val = 'X'
+	},
+#endif /* CONFIG_BLKTRACE_EXT */
 	{
 		.name = "quiet",
 		.has_arg = no_argument,
@@ -273,9 +293,21 @@ static int per_device_and_cpu_stats = 1;
 static int track_ios;
 static int ppi_hash_by_pid = 1;
 static int verbose;
+
+#ifdef CONFIG_BLKTRACE_EXT
+static uint64_t act_mask = -1ULL;
+/* by default don't trace priority */
+uint32_t blkparse_prio_mask;
+#else
 static unsigned int act_mask = -1U;
+#endif /* CONFIG_BLKTRACE_EXT */
+
 static int stats_printed;
 static int bin_output_msgs = 1;
+
+#ifdef CONFIG_BLKTRACE_EXT
+int bparse_track_prio;
+#endif /* CONFIG_BLKTRACE_EXT */
 int data_is_native = -1;
 
 static FILE *dump_fp;
@@ -1614,7 +1646,11 @@ static void dump_trace_fs(struct blk_io_trace *t, struct per_dev_info *pdi,
 			/* dump to binary file only */
 			break;
 		default:
+#ifdef CONFIG_BLKTRACE_EXT
+			fprintf(stderr, "Bad fs action %llx\n", t->action);
+#else
 			fprintf(stderr, "Bad fs action %x\n", t->action);
+#endif /* CONFIG_BLKTRACE_EXT */
 			break;
 	}
 }
@@ -2730,7 +2766,11 @@ static int is_pipe(const char *str)
 	return 0;
 }
 
+#ifdef CONFIG_BLKTRACE_EXT
+#define S_OPTS  "a:A:b:D:d:f:F:hi:o:Oqstw:vVMpx:X:"
+#else
 #define S_OPTS  "a:A:b:D:d:f:F:hi:o:Oqstw:vVM"
+#endif /* CONFIG_BLKTRACE_EXT */
 static char usage_str[] =    "\n\n" \
 	"-i <file>           | --input=<file>\n" \
 	"[ -a <action field> | --act-mask=<action field> ]\n" \
@@ -2746,6 +2786,9 @@ static char usage_str[] =    "\n\n" \
 	"[ -q                | --quiet ]\n" \
 	"[ -s                | --per-program-stats ]\n" \
 	"[ -t                | --track-ios ]\n" \
+	"[ -p                | --track-prio ]\n" \
+	"[ -x <ioprio field> | --act-mask=<ioprio field> ]\n" \
+	"[ -X <ioprio mask>  | --set-mask=<ioprio mask> ]\n" \
 	"[ -w <time>         | --stopwatch=<time> ]\n" \
 	"[ -M                | --no-msgs\n" \
 	"[ -v                | --verbose ]\n" \
@@ -2762,6 +2805,9 @@ static char usage_str[] =    "\n\n" \
 	"\t-i Input file containing trace data, or '-' for stdin\n" \
 	"\t-o Output file. If not given, output is stdout\n" \
 	"\t-O Do NOT output text data\n" \
+	"\t-p Track indivisual I/Os priority.\n" \
+	"\t-x Only trace specified priority.\n" \
+	"\t-X Give priority class mask as a single value.\n" \
 	"\t-q Quiet. Don't display any stats at the end of the trace\n" \
 	"\t-s Show per-program io statistics\n" \
 	"\t-t Track individual ios. Will tell you the time a request took\n" \
@@ -2780,9 +2826,9 @@ static void usage(char *prog)
 int main(int argc, char *argv[])
 {
 	int i, c, ret, mode;
-	int act_mask_tmp = 0;
 	char *ofp_buffer = NULL;
 	char *bin_ofp_buffer = NULL;
+	unsigned int act_mask_tmp = 0;
 
 	while ((c = getopt_long(argc, argv, S_OPTS, l_opts, NULL)) != -1) {
 		switch (c) {
@@ -2797,7 +2843,7 @@ int main(int argc, char *argv[])
 			break;
 
 		case 'A':
-			if ((sscanf(optarg, "%x", &i) != 1) || 
+			if ((sscanf(optarg, "%x", &i) != 1) ||
 							!valid_act_opt(i)) {
 				fprintf(stderr,
 					"Invalid set action mask %s/0x%x\n",
@@ -2833,6 +2879,31 @@ int main(int argc, char *argv[])
 		case 't':
 			track_ios = 1;
 			break;
+#ifdef CONFIG_BLKTRACE_EXT
+		case 'p':
+			bparse_track_prio = 1;
+			break;
+		case 'x':
+			i = find_prio_mask_map(optarg);
+			if (i < 0) {
+				fprintf(stderr,"Invalid priority mask %s\n",
+					optarg);
+				return 1;
+			}
+			blkparse_prio_mask |= i;
+			break;
+
+		case 'X':
+			if ((sscanf(optarg, "%x", &i) != 1) ||
+							!valid_prio_opt(i)) {
+				fprintf(stderr,
+					"Invalid set priority mask %s/0x%x\n",
+					optarg, i);
+				return 1;
+			}
+			blkparse_prio_mask = i;
+			break;
+#endif /* CONFIG_BLKTRACE_EXT */
 		case 'q':
 			per_device_and_cpu_stats = 0;
 			break;
@@ -2884,6 +2955,14 @@ int main(int argc, char *argv[])
 
 	if (act_mask_tmp != 0)
 		act_mask = act_mask_tmp;
+#ifdef CONFIG_BLKTRACE_EXT
+	/*
+	 * When track-priority is on and user didn't specify prio_mask then trace
+	 * all the ioprio classes.
+	 */
+	if (bparse_track_prio && !blkparse_prio_mask)
+		blkparse_prio_mask = TRACE_ALL_IOPRIO;
+#endif /* CONFIG_BLKTRACE_EXT */
 
 	memset(&rb_sort_root, 0, sizeof(rb_sort_root));
 
diff --git a/blktrace.h b/blktrace.h
index c860bf9..8473951 100644
--- a/blktrace.h
+++ b/blktrace.h
@@ -57,6 +57,7 @@ enum {
 #define TRACE_ALL_IOPRIO ((1 << IOPRIO_CLASS_NONE) | (1 << IOPRIO_CLASS_RT) | \
 		(1 << IOPRIO_CLASS_BE) | (1 << IOPRIO_CLASS_IDLE))
 
+extern int bparse_track_prior;
 #endif /* CONFIG_BLKTRACE_EXT */
 
 typedef __u32 u32;
-- 
2.19.1


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

* [RFC PATCH blktrace-tools 06/10] blkparse-fmt.c: add extension support
  2019-05-01  4:33 [RFC PATCH blktrace-tools 00/10] blktrace: add blktrace extension support Chaitanya Kulkarni
                   ` (4 preceding siblings ...)
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 05/10] blkparse.c: " Chaitanya Kulkarni
@ 2019-05-01  4:33 ` Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 07/10] iowatcher/blkparse: add extension definitions Chaitanya Kulkarni
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Chaitanya Kulkarni @ 2019-05-01  4:33 UTC (permalink / raw)
  To: linux-block; +Cc: Chaitanya Kulkarni

This patch adds support for blkparse format to use the blktrace
extension. Here we update the blkparse format processing and add
extension support for handling the priorities.

By default for any command blkparse format only prints the sector
in and bytes transfer if trace has bytes associated with it.
For zone reset command we need to print the sectors even though
it doesn't have bytes associated with it.

1. Using blktrace with blkparse with these changes from command line :-

prio mask F=00001111 -> IDLE BEST REAL NONE

Will produce a following output for the write zeroes command
issued with the blkdiscard -z options (where write-zeroes is
enabled on the null_blk, please see the later patches) :-
#for prio in 0 1 2 3;
> do
> 	echo "$prio"
> 	ionice -c ${prio} blkdiscard -z -o 0 -l 4096 /dev/nullb0
> done

252,0    7        1     0.000000000 11683  Q WZS NONE 0 0 + 8 [blkdiscard]
252,0    7        2     0.000017726 11683  G WZS NONE 0 0 + 8 [blkdiscard]
252,0    7        5     0.000036753 11683  I WZS NONE 0 0 + 8 [blkdiscard]
252,0    7        6     0.000084833   590  D WZS NONE 0 0 + 8 [kworker/7:1H]
252,0    7        7     0.000123823    46  C WZS NONE 0 0 + 8 [0]
252,0    5        1     0.457135696 11685  Q WZS REAL 4 0 + 8 [blkdiscard]
252,0    5        2     0.457149696 11685  G WZS REAL 4 0 + 8 [blkdiscard]
252,0    5        5     0.457168205 11685  I WZS REAL 4 0 + 8 [blkdiscard]
252,0    5        6     0.457213155   526  D WZS REAL 4 0 + 8 [kworker/5:1H]
252,0    5        7     0.457250408    36  C WZS REAL 4 0 + 8 [0]
252,0    7        8     0.715223985 11686  Q WZS BEST 4 0 + 8 [blkdiscard]
252,0    7        9     0.715238045 11686  G WZS BEST 4 0 + 8 [blkdiscard]
252,0    7       12     0.715255462 11686  I WZS BEST 4 0 + 8 [blkdiscard]
252,0    7       13     0.715297718   590  D WZS BEST 4 0 + 8 [kworker/7:1H]
252,0    7       14     0.715330957    46  C WZS BEST 4 0 + 8 [0]
252,0    8        1     0.949218847 11687  Q WZS IDLE 7 0 + 8 [blkdiscard]
252,0    8        2     0.949232970 11687  G WZS IDLE 7 0 + 8 [blkdiscard]
252,0    8        5     0.949250266 11687  I WZS IDLE 7 0 + 8 [blkdiscard]
252,0    8        6     0.949294703   519  D WZS IDLE 7 0 + 8 [kworker/8:1H]
252,0    8        7     0.949330943    51  C WZS IDLE 7 0 + 8 [0]

2. Using blktrace with blkparse with these changes from command line :-

prio mask B=00001011 -> IDEL 0 REAL NONE

Will produce a following output for the write zeroes command
issued with the blkdiscard -z options (where write-zeroes is
enabled on the null_blk, please see the later patches) :-
#for prio in 0 1 2 3;
> do
> 	echo "$prio"
> 	ionice -c ${prio} blkdiscard -z -o 0 -l 4096 /dev/nullb0
> done

252,0    0        1     0.000000000 11584  Q WZS NONE 0 0 + 8 [blkdiscard]
252,0    0        2     0.000031548 11584  G WZS NONE 0 0 + 8 [blkdiscard]
252,0    0        5     0.000054369 11584  I WZS NONE 0 0 + 8 [blkdiscard]
252,0    0        6     0.000109033   517  D WZS NONE 0 0 + 8 [kworker/0:1H]
252,0    0        7     0.000151984     9  C WZS NONE 0 0 + 8 [0]
252,0    0        9     0.656430970 11586  G WZS REAL 4 0 + 8 [blkdiscard]
252,0    0       12     0.656448477 11586  I WZS REAL 4 0 + 8 [blkdiscard]
252,0    0       13     0.656488270   517  D WZS REAL 4 0 + 8 [kworker/0:1H]
252,0    0       14     0.656521240     9  C WZS REAL 4 0 + 8 [0]
252,0    0       15    10.598584665 11587  Q WZS 0 + 8 [blkdiscard]
252,0    0       16    10.598600772 11587  G WZS 0 + 8 [blkdiscard]
252,0    0       19    10.598619039 11587  I WZS 0 + 8 [blkdiscard]
252,0    0       20    10.598670130   517  D WZS 0 + 8 [kworker/0:1H]
252,0    0       21    10.598693597     9  C WZS 0 + 8 [0]
252,0    0       22    10.604513117 11588  Q WZS IDLE 7 0 + 8 [blkdiscard]
252,0    0       23    10.604523031 11588  G WZS IDLE 7 0 + 8 [blkdiscard]
252,0    0       26    10.604535549 11588  I WZS IDLE 7 0 + 8 [blkdiscard]
252,0    0       27    10.604563234   517  D WZS IDLE 7 0 + 8 [kworker/0:1H]
252,0    0       28    10.604586205     9  C WZS IDLE 7 0 + 8 [0]

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 blkparse_fmt.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/blkparse_fmt.c b/blkparse_fmt.c
index c42e6d7..2935680 100644
--- a/blkparse_fmt.c
+++ b/blkparse_fmt.c
@@ -5,6 +5,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <unistd.h>
 #include <ctype.h>
 #include <time.h>
@@ -15,6 +16,11 @@
 
 #define HEADER		"%D %2c %8s %5T.%9t %5p %2a %3d "
 
+#ifdef CONFIG_BLKTRACE_EXT
+extern uint32_t blkparse_prio_mask;
+extern int bparse_track_prio;
+#endif /* CONFIG_BLKTRACE_EXT */
+
 static char *override_format[256];
 
 static inline int valid_spec(int spec)
@@ -52,6 +58,17 @@ int add_format_spec(char *option)
 
 static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t)
 {
+#ifdef CONFIG_BLKTRACE_EXT
+	uint64_t w = t->action & BLK_TC_ACT(BLK_TC_WRITE);
+	uint64_t a = t->action & BLK_TC_ACT(BLK_TC_AHEAD);
+	uint64_t s = t->action & BLK_TC_ACT(BLK_TC_SYNC);
+	uint64_t m = t->action & BLK_TC_ACT(BLK_TC_META);
+	uint64_t d = t->action & BLK_TC_ACT(BLK_TC_DISCARD);
+	uint64_t f = t->action & BLK_TC_ACT(BLK_TC_FLUSH);
+	uint64_t u = t->action & BLK_TC_ACT(BLK_TC_FUA);
+	uint64_t z = t->action & BLK_TC_ACT(BLK_TC_WRITE_ZEROES);
+	uint64_t r = t->action & BLK_TC_ACT(BLK_TC_ZONE_RESET);
+#else
 	int w = t->action & BLK_TC_ACT(BLK_TC_WRITE);
 	int a = t->action & BLK_TC_ACT(BLK_TC_AHEAD);
 	int s = t->action & BLK_TC_ACT(BLK_TC_SYNC);
@@ -59,6 +76,7 @@ static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t)
 	int d = t->action & BLK_TC_ACT(BLK_TC_DISCARD);
 	int f = t->action & BLK_TC_ACT(BLK_TC_FLUSH);
 	int u = t->action & BLK_TC_ACT(BLK_TC_FUA);
+#endif /* CONFIG_BLKTRACE_EXT */
 	int i = 0;
 
 	if (f)
@@ -66,6 +84,15 @@ static inline void fill_rwbs(char *rwbs, struct blk_io_trace *t)
 
 	if (d)
 		rwbs[i++] = 'D';
+#ifdef CONFIG_BLKTRACE_EXT
+	else if (z) {
+		rwbs[i++] = 'W'; /* write-zeroes */
+		rwbs[i++] = 'Z';
+	} else if (r) {
+		rwbs[i++] = 'Z'; /* zone-reset */
+		rwbs[i++] = 'R';
+	}
+#endif /* CONFIG_BLKTRACE_EXT */
 	else if (w)
 		rwbs[i++] = 'W';
 	else if (t->bytes)
@@ -311,6 +338,35 @@ static void process_default(char *act, struct per_cpu_info *pci,
 		MAJOR(t->device), MINOR(t->device), pci->cpu, t->sequence,
 		(int) SECONDS(t->time), (unsigned long) NANO_SECONDS(t->time),
 		t->pid, act, rwbs);
+#ifdef CONFIG_BLKTRACE_EXT
+	/* XXX: optimize the print format somthing like NN/RT/BT/ID */
+	if (bparse_track_prio) {
+		switch (IOPRIO_PRIO_CLASS(t->ioprio)) {
+		case IOPRIO_CLASS_NONE:
+			if (blkparse_prio_mask & 0x1)
+				fprintf(ofp, "NONE %1lu ",
+						IOPRIO_PRIO_DATA(t->ioprio));
+			break;
+		case IOPRIO_CLASS_RT:
+			if (blkparse_prio_mask & 0x2)
+				fprintf(ofp, "REAL %1lu ",
+						IOPRIO_PRIO_DATA(t->ioprio));
+			break;
+		case IOPRIO_CLASS_BE:
+			if (blkparse_prio_mask & 0x4)
+				fprintf(ofp, "BEST %1lu ",
+						IOPRIO_PRIO_DATA(t->ioprio));
+			break;
+		case IOPRIO_CLASS_IDLE:
+			if (blkparse_prio_mask & 0x8)
+				fprintf(ofp, "IDLE %1lu ",
+						IOPRIO_PRIO_DATA(t->ioprio));
+			break;
+		default:
+			fprintf(ofp, "ERRR   ");
+		}
+	}
+#endif /* CONFIG_BLKTRACE_EXT */
 
 	name = find_process_name(t->pid);
 
@@ -324,7 +380,11 @@ static void process_default(char *act, struct per_cpu_info *pci,
 			fprintf(ofp, "[%d]\n", t->error);
 		} else {
 			if (elapsed != -1ULL) {
+#ifdef CONFIG_BLKTRACE_EXT
+				if (t_sec(t) || t->sector) /* needed for ZR */
+#else
 				if (t_sec(t))
+#endif /* CONFIG_BLKTRACE_EXT */
 					fprintf(ofp, "%llu + %u (%8llu) [%d]\n",
 						(unsigned long long) t->sector,
 						t_sec(t), elapsed, t->error);
@@ -333,7 +393,11 @@ static void process_default(char *act, struct per_cpu_info *pci,
 						(unsigned long long) t->sector,
 						elapsed, t->error);
 			} else {
+#ifdef CONFIG_BLKTRACE_EXT
+				if (t_sec(t) || t->sector) /* needed for ZR */
+#else
 				if (t_sec(t))
+#endif /* CONFIG_BLKTRACE_EXT */
 					fprintf(ofp, "%llu + %u [%d]\n",
 						(unsigned long long) t->sector,
 						t_sec(t), t->error);
@@ -358,7 +422,11 @@ static void process_default(char *act, struct per_cpu_info *pci,
 			fprintf(ofp, "[%s]\n", name);
 		} else {
 			if (elapsed != -1ULL) {
+#ifdef CONFIG_BLKTRACE_EXT
 				if (t_sec(t))
+#else
+				if (t_sec(t) || t->sector) /* needed for ZR */
+#endif /* CONFIG_BLKTRACE_EXT */
 					fprintf(ofp, "%llu + %u (%8llu) [%s]\n",
 						(unsigned long long) t->sector,
 						t_sec(t), elapsed, name);
@@ -366,7 +434,11 @@ static void process_default(char *act, struct per_cpu_info *pci,
 					fprintf(ofp, "(%8llu) [%s]\n", elapsed,
 						name);
 			} else {
+#ifdef CONFIG_BLKTRACE_EXT
+				if (t_sec(t) || t->sector) /* needed for ZR */
+#else
 				if (t_sec(t))
+#endif /* CONFIG_BLKTRACE_EXT */
 					fprintf(ofp, "%llu + %u [%s]\n",
 						(unsigned long long) t->sector,
 						t_sec(t), name);
@@ -380,7 +452,11 @@ static void process_default(char *act, struct per_cpu_info *pci,
 	case 'F':	/* Front merge */
 	case 'G':	/* Get request */
 	case 'S':	/* Sleep request */
+#ifdef CONFIG_BLKTRACE_EXT
+		if (t_sec(t) || t->sector) /* needed for ZR */
+#else
 		if (t_sec(t))
+#endif /* CONFIG_BLKTRACE_EXT */
 			fprintf(ofp, "%llu + %u [%s]\n",
 				(unsigned long long) t->sector, t_sec(t), name);
 		else
-- 
2.19.1


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

* [RFC PATCH blktrace-tools 07/10] iowatcher/blkparse: add extension definitions
  2019-05-01  4:33 [RFC PATCH blktrace-tools 00/10] blktrace: add blktrace extension support Chaitanya Kulkarni
                   ` (5 preceding siblings ...)
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 06/10] blkparse-fmt.c: add extension support Chaitanya Kulkarni
@ 2019-05-01  4:33 ` Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 08/10] blkiomon: add extension support Chaitanya Kulkarni
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Chaitanya Kulkarni @ 2019-05-01  4:33 UTC (permalink / raw)
  To: linux-block; +Cc: Chaitanya Kulkarni

Here we synchronize the blktrace extension definitions.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 iowatcher/blkparse.c | 70 +++++++++++++++++++++++++++++++-------------
 1 file changed, 49 insertions(+), 21 deletions(-)

diff --git a/iowatcher/blkparse.c b/iowatcher/blkparse.c
index 41e20f0..fce7de3 100644
--- a/iowatcher/blkparse.c
+++ b/iowatcher/blkparse.c
@@ -52,29 +52,43 @@ extern int io_per_process;
 /*
  * Trace categories
  */
-enum {
-	BLK_TC_READ	= 1 << 0,	/* reads */
-	BLK_TC_WRITE	= 1 << 1,	/* writes */
-	BLK_TC_FLUSH	= 1 << 2,	/* flush */
-	BLK_TC_SYNC	= 1 << 3,	/* sync */
-	BLK_TC_QUEUE	= 1 << 4,	/* queueing/merging */
-	BLK_TC_REQUEUE	= 1 << 5,	/* requeueing */
-	BLK_TC_ISSUE	= 1 << 6,	/* issue */
-	BLK_TC_COMPLETE	= 1 << 7,	/* completions */
-	BLK_TC_FS	= 1 << 8,	/* fs requests */
-	BLK_TC_PC	= 1 << 9,	/* pc requests */
-	BLK_TC_NOTIFY	= 1 << 10,	/* special message */
-	BLK_TC_AHEAD	= 1 << 11,	/* readahead */
-	BLK_TC_META	= 1 << 12,	/* metadata */
-	BLK_TC_DISCARD	= 1 << 13,	/* discard requests */
-	BLK_TC_DRV_DATA	= 1 << 14,	/* binary driver data */
-	BLK_TC_FUA	= 1 << 15,	/* fua requests */
-
-	BLK_TC_END	= 1 << 15,	/* we've run out of bits! */
-};
-
+enum blktrace_cat {
+        BLK_TC_READ             = 1 << 0,       /* reads */
+        BLK_TC_WRITE            = 1 << 1,       /* writes */
+        BLK_TC_FLUSH            = 1 << 2,       /* flush */
+        BLK_TC_SYNC             = 1 << 3,       /* sync IO */
+        BLK_TC_SYNCIO           = BLK_TC_SYNC,
+        BLK_TC_QUEUE            = 1 << 4,       /* queueing/merging */
+        BLK_TC_REQUEUE          = 1 << 5,       /* requeueing */
+        BLK_TC_ISSUE            = 1 << 6,       /* issue */
+        BLK_TC_COMPLETE         = 1 << 7,       /* completions */
+        BLK_TC_FS               = 1 << 8,       /* fs requests */
+        BLK_TC_PC               = 1 << 9,       /* pc requests */
+        BLK_TC_NOTIFY           = 1 << 10,      /* special message */
+        BLK_TC_AHEAD            = 1 << 11,      /* readahead */
+        BLK_TC_META             = 1 << 12,      /* metadata */
+        BLK_TC_DISCARD          = 1 << 13,      /* discard requests */
+        BLK_TC_DRV_DATA         = 1 << 14,      /* binary per-driver data */
+        BLK_TC_FUA              = 1 << 15,      /* fua requests */
+#ifdef CONFIG_BLKTRACE_EXT
+        BLK_TC_WRITE_ZEROES     = 1 << 16,      /* write-zeores */
+        BLK_TC_ZONE_RESET       = 1 << 17,      /* zone-reset */
+
+        BLK_TC_END              = 1 << 31,      /* we've run out of bits! */
+#else
+        BLK_TC_END              = 1 << 16,      /* we've run out of bits! */
+#endif
+ };
+
+#ifdef CONFIG_BLKTRACE_EXT
+#define BLK_TC_SHIFT		(32)
+#define BLK_TC_ACT(act)		(((uint64_t)act) << BLK_TC_SHIFT)
+#else
 #define BLK_TC_SHIFT		(16)
 #define BLK_TC_ACT(act)		((act) << BLK_TC_SHIFT)
+
+#endif
+
 #define BLK_DATADIR(a) (((a) >> BLK_TC_SHIFT) & (BLK_TC_READ | BLK_TC_WRITE))
 
 /*
@@ -100,7 +114,12 @@ enum {
 	__BLK_TA_DRV_DATA,		/* binary driver data */
 };
 
+#ifdef CONFIG_BLKTRACE_EXT
+#define BLK_TA_MASK ((1ULL << BLK_TC_SHIFT) - 1)
+#else
 #define BLK_TA_MASK ((1 << BLK_TC_SHIFT) - 1)
+#endif
+
 
 /*
  * Notify events.
@@ -137,7 +156,11 @@ enum blktrace_notify {
 #define BLK_TN_MESSAGE		(__BLK_TN_MESSAGE | BLK_TC_ACT(BLK_TC_NOTIFY))
 
 #define BLK_IO_TRACE_MAGIC	0x65617400
+#ifdef CONFIG_BLKTRACE_EXT
+#define BLK_IO_TRACE_VERSION	0x08
+#else
 #define BLK_IO_TRACE_VERSION	0x07
+#endif
 /*
  * The trace itself
  */
@@ -147,7 +170,12 @@ struct blk_io_trace {
 	__u64 time;		/* in nanoseconds */
 	__u64 sector;		/* disk offset */
 	__u32 bytes;		/* transfer length */
+#ifdef CONFIG_BLKTRACE_EXT
+	__u64 action;		/* what happened */
+	__u32 ioprio;		/* ioprio */
+#else
 	__u32 action;		/* what happened */
+#endif
 	__u32 pid;		/* who did it */
 	__u32 device;		/* device identifier (dev_t) */
 	__u32 cpu;		/* on what cpu did it happen */
-- 
2.19.1


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

* [RFC PATCH blktrace-tools 08/10] blkiomon: add extension support
  2019-05-01  4:33 [RFC PATCH blktrace-tools 00/10] blktrace: add blktrace extension support Chaitanya Kulkarni
                   ` (6 preceding siblings ...)
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 07/10] iowatcher/blkparse: add extension definitions Chaitanya Kulkarni
@ 2019-05-01  4:33 ` Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 09/10] blkrawverify: " Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 10/10] blktrace-tools: " Chaitanya Kulkarni
  9 siblings, 0 replies; 11+ messages in thread
From: Chaitanya Kulkarni @ 2019-05-01  4:33 UTC (permalink / raw)
  To: linux-block; +Cc: Chaitanya Kulkarni

Update blkiomon to support the blktrace extension.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 blkiomon.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/blkiomon.c b/blkiomon.c
index f8b0c9d..67ef4ac 100644
--- a/blkiomon.c
+++ b/blkiomon.c
@@ -36,6 +36,10 @@
 #include <pthread.h>
 #include <time.h>
 
+#ifdef CONFIG_BLKTRACE_EXT
+#include <inttypes.h>
+#endif /* CONFIG_BLKTRACE_EXT */
+
 #include "blktrace.h"
 #include "rbtree.h"
 #include "jhash.h"
@@ -116,7 +120,11 @@ static void dump_bit(struct trace *t, const char *descr)
 	fprintf(debug.fp, "time     %16ld\n", (unsigned long)bit->time);
 	fprintf(debug.fp, "sector   %16ld\n", (unsigned long)bit->sector);
 	fprintf(debug.fp, "bytes    %16d\n", bit->bytes);
+#ifdef CONFIG_BLKTRACE_EXT
+	fprintf(debug.fp, "action   %"PRIx64"\n", (unsigned long)bit->action);
+#else
 	fprintf(debug.fp, "action   %16x\n", bit->action);
+#endif /* CONFIG_BLKTRACE_EXT */
 	fprintf(debug.fp, "pid      %16d\n", bit->pid);
 	fprintf(debug.fp, "device   %16d\n", bit->device);
 	fprintf(debug.fp, "cpu      %16d\n", bit->cpu);
@@ -142,8 +150,16 @@ static void dump_bits(struct trace *t1, struct trace *t2, const char *descr)
 		(unsigned long)bit1->time, (unsigned long)bit2->time);
 	fprintf(debug.fp, "sector   %16ld %16ld\n",
 		(unsigned long)bit1->sector, (unsigned long)bit2->sector);
+
+#ifdef CONFIG_BLKTRACE_EXT
 	fprintf(debug.fp, "bytes    %16d %16d\n", bit1->bytes, bit2->bytes);
+	fprintf(debug.fp, "action   %"PRIx64" %"PRIx64"\n",
+			(unsigned long) bit1->action,
+			(unsigned long) bit2->action);
+#else
 	fprintf(debug.fp, "action   %16x %16x\n", bit1->action, bit2->action);
+#endif /* CONFIG_BLKTRACE_EXT */
+
 	fprintf(debug.fp, "pid      %16d %16d\n", bit1->pid, bit2->pid);
 	fprintf(debug.fp, "device   %16d %16d\n", bit1->device, bit2->device);
 	fprintf(debug.fp, "cpu      %16d %16d\n", bit1->cpu, bit2->cpu);
-- 
2.19.1


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

* [RFC PATCH blktrace-tools 09/10] blkrawverify: add extension support
  2019-05-01  4:33 [RFC PATCH blktrace-tools 00/10] blktrace: add blktrace extension support Chaitanya Kulkarni
                   ` (7 preceding siblings ...)
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 08/10] blkiomon: add extension support Chaitanya Kulkarni
@ 2019-05-01  4:33 ` Chaitanya Kulkarni
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 10/10] blktrace-tools: " Chaitanya Kulkarni
  9 siblings, 0 replies; 11+ messages in thread
From: Chaitanya Kulkarni @ 2019-05-01  4:33 UTC (permalink / raw)
  To: linux-block; +Cc: Chaitanya Kulkarni

Update blkrawverify to support blktrace extension.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 blkrawverify.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/blkrawverify.c b/blkrawverify.c
index ed5d258..8fa16f0 100644
--- a/blkrawverify.c
+++ b/blkrawverify.c
@@ -19,6 +19,10 @@
  *
  */
 #include <stdio.h>
+
+#ifdef CONFIG_BLKTRACE_EXT
+#include <inttypes.h>
+#endif /* CONFIG_BLKTRACE_EXT */
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -51,6 +55,10 @@ static struct trace_info traces[] = {
 	TRACE_TO_STRING( BLK_TC_META ),
 	TRACE_TO_STRING( BLK_TC_DISCARD ),
 	TRACE_TO_STRING( BLK_TC_FUA ),
+#ifdef CONFIG_BLKTRACE_EXT
+	TRACE_TO_STRING( BLK_TC_WRITE_ZEROES ),
+	TRACE_TO_STRING( BLK_TC_ZONE_RESET ),
+#endif /* CONFIG_BLKTRACE_EXT */
 };
 #define N_TRACES (sizeof(traces) / sizeof(struct trace_info))
 
@@ -80,12 +88,22 @@ static struct act_info acts[] = {
 };
 #define N_ACTS (sizeof(acts) / sizeof(struct act_info))
 
+
+#ifdef CONFIG_BLKTRACE_EXT
+static char *act_to_str(__u64 action)
+#else
 static char *act_to_str(__u32 action)
+#endif /* CONFIG_BLKTRACE_EXT */
 {
 	static char buf[1024];
 	unsigned int i;
+#ifdef CONFIG_BLKTRACE_EXT
+	unsigned int act = action & 0xffffffff; /* validate this mask */
+	uint64_t trace = (action >> BLK_TC_SHIFT) & 0xffffffff;
+#else
 	unsigned int act = action & 0xffff;
 	unsigned int trace = (action >> BLK_TC_SHIFT) & 0xffff;
+#endif /* CONFIG_BLKTRACE_EXT */
 
 	if (act < N_ACTS) {
 		sprintf(buf, "%s ", acts[act].string);
@@ -95,9 +113,13 @@ static char *act_to_str(__u32 action)
 				sprintf(buf2, "| %s ", traces[i].string);
 				strcat(buf, buf2);
 			}
-	}
-	else
+	} else {
+#ifdef CONFIG_BLKTRACE_EXT
+		sprintf(buf, "Invalid action=%"PRIx64"", (long unsigned)action);
+#else
 		sprintf(buf, "Invalid action=%08x", action);
+#endif /* CONFIG_BLKTRACE_EXT */
+	}
 
 	return buf;
 }
-- 
2.19.1


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

* [RFC PATCH blktrace-tools 10/10] blktrace-tools: add extension support
  2019-05-01  4:33 [RFC PATCH blktrace-tools 00/10] blktrace: add blktrace extension support Chaitanya Kulkarni
                   ` (8 preceding siblings ...)
  2019-05-01  4:33 ` [RFC PATCH blktrace-tools 09/10] blkrawverify: " Chaitanya Kulkarni
@ 2019-05-01  4:33 ` Chaitanya Kulkarni
  9 siblings, 0 replies; 11+ messages in thread
From: Chaitanya Kulkarni @ 2019-05-01  4:33 UTC (permalink / raw)
  To: linux-block; +Cc: Chaitanya Kulkarni

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 5917814..d784b64 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
 CC	= gcc
 CFLAGS	= -Wall -O2 -g -W
-ALL_CFLAGS = $(CFLAGS) -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+ALL_CFLAGS = $(CFLAGS) -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
+	     -DCONFIG_BLKTRACE_EXT
 PROGS	= blkparse blktrace verify_blkparse blkrawverify blkiomon
 LIBS	= -lpthread
 SCRIPTS	= btrace
-- 
2.19.1


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

end of thread, other threads:[~2019-05-01  4:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-01  4:33 [RFC PATCH blktrace-tools 00/10] blktrace: add blktrace extension support Chaitanya Kulkarni
2019-05-01  4:33 ` [RFC PATCH blktrace-tools 01/10] blktrace.h: add blktrace extension to the header Chaitanya Kulkarni
2019-05-01  4:33 ` [RFC PATCH blktrace-tools 02/10] blktrace_api.h: update blktrace API header Chaitanya Kulkarni
2019-05-01  4:33 ` [RFC PATCH blktrace-tools 03/10] act-mask: add blktrace extension to act_mask Chaitanya Kulkarni
2019-05-01  4:33 ` [RFC PATCH blktrace-tools 04/10] blktrace.c: add support for extensions Chaitanya Kulkarni
2019-05-01  4:33 ` [RFC PATCH blktrace-tools 05/10] blkparse.c: " Chaitanya Kulkarni
2019-05-01  4:33 ` [RFC PATCH blktrace-tools 06/10] blkparse-fmt.c: add extension support Chaitanya Kulkarni
2019-05-01  4:33 ` [RFC PATCH blktrace-tools 07/10] iowatcher/blkparse: add extension definitions Chaitanya Kulkarni
2019-05-01  4:33 ` [RFC PATCH blktrace-tools 08/10] blkiomon: add extension support Chaitanya Kulkarni
2019-05-01  4:33 ` [RFC PATCH blktrace-tools 09/10] blkrawverify: " Chaitanya Kulkarni
2019-05-01  4:33 ` [RFC PATCH blktrace-tools 10/10] blktrace-tools: " Chaitanya Kulkarni

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).