linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: linux-block@vger.kernel.org
Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Subject: [RFC PATCH 07/18] blktrace: allow user to track iopriority
Date: Tue, 30 Apr 2019 21:28:20 -0700	[thread overview]
Message-ID: <20190501042831.5313-8-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20190501042831.5313-1-chaitanya.kulkarni@wdc.com>

Now that we have added the support for to track the iopriority
update the blktrace extension code to actually track the priority
and use priority mask to filter out the log.

Priority mask just works same as action mask where we discard all the
traces where they don't match the priority mask.

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

diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 6d2b4adae76e..1b113ba284fe 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -16,6 +16,7 @@
 #include <linux/uaccess.h>
 #include <linux/list.h>
 #include <linux/blk-cgroup.h>
+#include <linux/ioprio.h>
 
 #include "../../block/blk.h"
 
@@ -189,6 +190,54 @@ EXPORT_SYMBOL_GPL(__trace_note_message);
 
 
 #ifdef CONFIG_BLKTRACE_EXT
+static bool prio_log_check(struct blk_trace *bt, u32 ioprio)
+{
+	bool ret;
+
+	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:
+		if (bt->prio_mask & 0x01)
+			ret = true;
+		else
+			ret = false;
+		break;
+	case IOPRIO_CLASS_RT:
+		if (bt->prio_mask & 0x02)
+			ret = true;
+		else
+			ret = false;
+		break;
+	case IOPRIO_CLASS_BE:
+		if (bt->prio_mask & 0x04)
+			ret = true;
+		else
+			ret = false;
+		break;
+	case IOPRIO_CLASS_IDLE:
+		if (bt->prio_mask & 0x08)
+			ret = true;
+		else
+			ret = false;
+		break;
+	default:
+		ret = false;
+	}
+out:
+	return ret;
+}
+
 static int act_log_check(struct blk_trace *bt, u64 what, sector_t sector,
 			 pid_t pid)
 #else
@@ -279,6 +328,10 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
 	pid = tsk->pid;
 	if (act_log_check(bt, what, sector, pid))
 		return;
+#ifdef CONFIG_BLKTRACE_EXT
+	if (bt->prio_mask && !prio_log_check(bt, ioprio))
+		return;
+#endif /* CONFIG_BLKTRACE_EXT */
 	cpu = raw_smp_processor_id();
 
 	if (blk_tracer) {
@@ -324,6 +377,9 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
 		t->sector = sector;
 		t->bytes = bytes;
 		t->action = what;
+#ifdef CONFIG_BLKTRACE_EXT
+		t->ioprio = ioprio;
+#endif /* CONFIG_BLKTRACE_EXT */
 		t->device = bt->dev;
 		t->error = error;
 		t->pdu_len = pdu_len + cgid_len;
@@ -574,6 +630,7 @@ 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;
+	bt->prio_mask = buts->prio_mask;
 #else
 	if (!bt->act_mask)
 		bt->act_mask = (u16) -1;
@@ -1773,7 +1830,8 @@ static int blk_trace_setup_queue(struct request_queue *q,
 
 #ifdef CONFIG_BLKTRACE_EXT
 	bt->act_mask = (u64)-1ULL;
-
+	/* do not track priorities by default */
+	bt->prio_mask = 0;
 #else
 	bt->act_mask = (u16)-1;
 #endif /* CONFIG_BLKTRACE_EXT */
-- 
2.19.1


  parent reply	other threads:[~2019-05-01  4:29 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-01  4:28 [RFC PATCH 00/18] blktrace: add blktrace extension support Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 01/18] blktrace: increase the size of action mask Chaitanya Kulkarni
2019-05-01 15:48   ` Bart Van Assche
2019-05-02  3:43     ` Chaitanya Kulkarni
2019-05-02 15:12       ` Bart Van Assche
2019-05-01  4:28 ` [RFC PATCH 02/18] blktrace: add more definitions for BLK_TC_ACT Chaitanya Kulkarni
2019-05-01 12:31   ` Christoph Hellwig
2019-05-01 12:56     ` Jeff Moyer
2019-05-02  3:48       ` Chaitanya Kulkarni
2019-05-02  3:49     ` Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 03/18] blktrace: update trace to track more actions Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 04/18] kernel/trace: add KConfig to enable blktrace_ext Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 05/18] blktrace: add iopriority mask Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 06/18] " Chaitanya Kulkarni
2019-05-01  4:28 ` Chaitanya Kulkarni [this message]
2019-05-01  4:28 ` [RFC PATCH 08/18] blktrace: add sysfs ioprio mask Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 09/18] blktrace: add debug support for extension Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 10/18] block: set ioprio for write-zeroes, discard etc Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 11/18] block: set ioprio for zone-reset Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 12/18] block: set ioprio for flush bio Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 13/18] drivers: set bio iopriority field Chaitanya Kulkarni
2019-05-01  6:23   ` Javier González
2019-05-01  4:28 ` [RFC PATCH 14/18] fs: " Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 15/18] power/swap: " Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 16/18] mm: " Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 17/18] null_blk: add write-zeroes flag to nullb_device Chaitanya Kulkarni
2019-05-01  4:28 ` [RFC PATCH 18/18] null_blk: add module param discard/write-zeroes Chaitanya Kulkarni

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=20190501042831.5313-8-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=linux-block@vger.kernel.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).