[RFC,blktrace-tools,01/10] blktrace.h: add blktrace extension to the header
diff mbox series

Message ID 20190501043317.5507-2-chaitanya.kulkarni@wdc.com
State New
Headers show
Series
  • blktrace: add blktrace extension support
Related show

Commit Message

Chaitanya Kulkarni May 1, 2019, 4:33 a.m. UTC
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(-)

Patch
diff mbox series

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;
 	}