diff mbox series

[RFC,09/18] blktrace: add debug support for extension

Message ID 20190501042831.5313-10-chaitanya.kulkarni@wdc.com (mailing list archive)
State New, archived
Headers show
Series blktrace: add blktrace extension support | expand

Commit Message

Chaitanya Kulkarni May 1, 2019, 4:28 a.m. UTC
This patch adds a new keconfig options to enable debug messages for
blktrace extension.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 kernel/trace/Kconfig    | 11 +++++++++++
 kernel/trace/blktrace.c | 36 +++++++++++++++++++++++-------------
 2 files changed, 34 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index 5f8c938e495f..d01bd7972638 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -481,6 +481,17 @@  config BLKTRACE_EXT
 
 	  If unsure, say N.
 
+config DEBUG_BLKTRACE_EXT
+	bool "Debug blktrace extension"
+	depends on BLK_DEV_IO_TRACE
+	depends on BLOCK
+	depends on BLKTRACE_EXT
+	select TRACEPOINTS
+	select GENERIC_TRACER
+	select STACKTRACE
+	help
+	  This enables debug messages for the blktrace extension.
+
 config KPROBE_EVENTS
 	depends on KPROBES
 	depends on HAVE_REGS_AND_STACK_ACCESS_API
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 84163fa6a61f..d03473614b3c 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -196,45 +196,51 @@  static bool prio_log_check(struct blk_trace *bt, u32 ioprio)
 
 	switch (IOPRIO_PRIO_CLASS(ioprio)) {
 	case IOPRIO_CLASS_NONE:
-	case IOPRIO_CLASS_RT:
-	case IOPRIO_CLASS_BE:
-	case IOPRIO_CLASS_IDLE:
-		break;
-	default:
-		/*XXX: print rate limit warn here */
-		ret = false;
-		goto out;
-	}
-
-	switch (IOPRIO_PRIO_CLASS(ioprio)) {
-	case IOPRIO_CLASS_NONE:
+#ifdef CONFIG_DEBUG_BLKTRACE_EXT
+		trace_printk("%s %d NONE %s\n", __func__, __LINE__,
+				bt->prio_mask & 0x01 ? "TRUE" : "FALSE");
+#endif /* CONFIG_DEBUG_BLKTRACE_EXT */
 		if (bt->prio_mask & 0x01)
 			ret = true;
 		else
 			ret = false;
 		break;
 	case IOPRIO_CLASS_RT:
+#ifdef CONFIG_DEBUG_BLKTRACE_EXT
+		trace_printk("%s %d REAL %s\n", __func__, __LINE__,
+				bt->prio_mask & 0x02 ? "TRUE" : "FALSE");
+#endif /* CONFIG_DEBUG_BLKTRACE_EXT */
 		if (bt->prio_mask & 0x02)
 			ret = true;
 		else
 			ret = false;
 		break;
 	case IOPRIO_CLASS_BE:
+#ifdef CONFIG_DEBUG_BLKTRACE_EXT
+		trace_printk("%s %d BEST %s\n", __func__, __LINE__,
+				bt->prio_mask & 0x03 ? "TRUE" : "FALSE");
+#endif /* CONFIG_DEBUG_BLKTRACE_EXT */
 		if (bt->prio_mask & 0x04)
 			ret = true;
 		else
 			ret = false;
 		break;
 	case IOPRIO_CLASS_IDLE:
+#ifdef CONFIG_DEBUG_BLKTRACE_EXT
+		trace_printk("%s %d IDLE %s\n", __func__, __LINE__,
+				bt->prio_mask & 0x04 ? "TRUE" : "FALSE");
+#endif /* CONFIG_DEBUG_BLKTRACE_EXT */
 		if (bt->prio_mask & 0x08)
 			ret = true;
 		else
 			ret = false;
 		break;
 	default:
+#ifdef CONFIG_DEBUG_BLKTRACE_EXT
+		trace_printk("%s %d ERROR\n", __func__, __LINE__);
+#endif /* CONFIG_DEBUG_BLKTRACE_EXT */
 		ret = false;
 	}
-out:
 	return ret;
 }
 
@@ -630,6 +636,10 @@  static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
 #ifdef CONFIG_BLKTRACE_EXT
 	if (!bt->act_mask)
 		bt->act_mask = (u64) -1ULL;
+
+#ifdef CONFIG_DEBUG_BLKTRACE_EXT
+	trace_printk("blktrace: prio mask 0x%x\n", buts->prio_mask);
+#endif /* CONFIG_DEBUG_BLKTRACE_EXT */
 	bt->prio_mask = buts->prio_mask;
 #else
 	if (!bt->act_mask)