iowatcher: Handle cgroup information
authorJan Kara <jack@suse.cz>
Wed, 6 May 2020 13:39:33 +0000 (15:39 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 20 May 2020 13:37:56 +0000 (07:37 -0600)
Since Linux kernel commit 35fe6d763229 "block: use standard blktrace API
to output cgroup info for debug notes" the kernel can pass
__BLK_TA_CGROUP flag in the action field of generated events. Teach
iowatcher to ignore this information.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
iowatcher/blkparse.c

index 982de945982627dfdaacc8b8b19014f147667d9d..6203854bd49c548fc851c64005e718edb1561807 100644 (file)
@@ -51,7 +51,7 @@ extern int plot_io_action;
 extern int io_per_process;
 
 #define BLK_DATADIR(a) (((a) >> BLK_TC_SHIFT) & (BLK_TC_READ | BLK_TC_WRITE))
-#define BLK_TA_MASK ((1 << BLK_TC_SHIFT) - 1)
+#define BLK_TA_MASK (((1 << BLK_TC_SHIFT) - 1) & ~__BLK_TA_CGROUP)
 
 struct pending_io {
        /* sector offset of this IO */
@@ -260,18 +260,23 @@ static void handle_notify(struct trace *trace)
 {
        struct blk_io_trace *io = trace->io;
        void *payload = (char *)io + sizeof(*io);
+       int pdu_len = io->pdu_len;
        u32 two32[2];
 
-       if (io->action == BLK_TN_PROCESS) {
+       if (io->action & __BLK_TN_CGROUP) {
+               payload += sizeof(struct blk_io_cgroup_payload);
+               pdu_len -= sizeof(struct blk_io_cgroup_payload);
+       }
+       if ((io->action & ~__BLK_TN_CGROUP) == BLK_TN_PROCESS) {
                if (io_per_process)
                        process_hash_insert(io->pid, payload);
                return;
        }
 
-       if (io->action != BLK_TN_TIMESTAMP)
+       if ((io->action & ~__BLK_TN_CGROUP) != BLK_TN_TIMESTAMP)
                return;
 
-       if (io->pdu_len != sizeof(two32))
+       if (pdu_len != sizeof(two32))
                return;
 
        memcpy(two32, payload, sizeof(two32));
@@ -309,11 +314,16 @@ static int is_io_event(struct blk_io_trace *test)
        char *message;
        if (!(test->action & BLK_TC_ACT(BLK_TC_NOTIFY)))
                return 1;
-       if (test->action == BLK_TN_MESSAGE) {
+       if ((test->action & ~__BLK_TN_CGROUP) == BLK_TN_MESSAGE) {
                int len = test->pdu_len;
+
+               message = (char *)(test + 1);
+               if (test->action & __BLK_TN_CGROUP) {
+                       len -= sizeof(struct blk_io_cgroup_payload);
+                       message += sizeof(struct blk_io_cgroup_payload);
+               }
                if (len < 3)
                        return 0;
-               message = (char *)(test + 1);
                if (strncmp(message, "fio ", 4) == 0) {
                        return 1;
                }
@@ -372,13 +382,17 @@ static int parse_fio_bank_message(struct trace *trace, u64 *bank_ret, u64 *offse
 
        if (!(test->action & BLK_TC_ACT(BLK_TC_NOTIFY)))
                return -1;
-       if (test->action != BLK_TN_MESSAGE)
+       if ((test->action & ~__BLK_TN_CGROUP) != BLK_TN_MESSAGE)
                return -1;
 
+       message = (char *)(test + 1);
+       if (test->action & __BLK_TN_CGROUP) {
+               len -= sizeof(struct blk_io_cgroup_payload);
+               message += sizeof(struct blk_io_cgroup_payload);
+       }
        /* the message is fio rw bank offset num_banks */
        if (len < 3)
                return -1;
-       message = (char *)(test + 1);
        if (strncmp(message, "fio r ", 6) != 0)
                return -1;