Update blktrace version to 1.3.0
This commit is contained in:
parent
0429f76147
commit
34ffb3887d
@ -1,67 +0,0 @@
|
||||
From 9967365e47e90511b89d2f20bb1d5c91c31cc610 Mon Sep 17 00:00:00 2001
|
||||
From: Jens Axboe <axboe@kernel.dk>
|
||||
Date: Sun, 5 Nov 2017 08:52:21 -0700
|
||||
Subject: [PATCH 01/15] jhash: fix annoying gcc fall through warnings
|
||||
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
jhash.h | 34 ++++++++++++++++------------------
|
||||
1 file changed, 16 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/jhash.h b/jhash.h
|
||||
index 4cebd23..a4d3106 100644
|
||||
--- a/jhash.h
|
||||
+++ b/jhash.h
|
||||
@@ -73,22 +73,21 @@ static inline u32 jhash(const void *key, u32 length, u32 initval)
|
||||
k += 12;
|
||||
}
|
||||
|
||||
- /* last block: affect all 32 bits of (c) */
|
||||
- /* all the case statements fall through */
|
||||
+ /* Last block: affect all 32 bits of (c) */
|
||||
switch (length) {
|
||||
- case 12: c += (u32)k[11]<<24;
|
||||
- case 11: c += (u32)k[10]<<16;
|
||||
- case 10: c += (u32)k[9]<<8;
|
||||
- case 9 : c += k[8];
|
||||
- case 8 : b += (u32)k[7]<<24;
|
||||
- case 7 : b += (u32)k[6]<<16;
|
||||
- case 6 : b += (u32)k[5]<<8;
|
||||
- case 5 : b += k[4];
|
||||
- case 4 : a += (u32)k[3]<<24;
|
||||
- case 3 : a += (u32)k[2]<<16;
|
||||
- case 2 : a += (u32)k[1]<<8;
|
||||
- case 1 : a += k[0];
|
||||
- __jhash_final(a, b, c);
|
||||
+ case 12: c += (u32)k[11]<<24; /* fall through */
|
||||
+ case 11: c += (u32)k[10]<<16; /* fall through */
|
||||
+ case 10: c += (u32)k[9]<<8; /* fall through */
|
||||
+ case 9: c += k[8]; /* fall through */
|
||||
+ case 8: b += (u32)k[7]<<24; /* fall through */
|
||||
+ case 7: b += (u32)k[6]<<16; /* fall through */
|
||||
+ case 6: b += (u32)k[5]<<8; /* fall through */
|
||||
+ case 5: b += k[4]; /* fall through */
|
||||
+ case 4: a += (u32)k[3]<<24; /* fall through */
|
||||
+ case 3: a += (u32)k[2]<<16; /* fall through */
|
||||
+ case 2: a += (u32)k[1]<<8; /* fall through */
|
||||
+ case 1: a += k[0];
|
||||
+ __jhash_final(a, b, c);
|
||||
case 0 :
|
||||
break;
|
||||
}
|
||||
@@ -117,10 +116,9 @@ static inline u32 jhash2(u32 *k, u32 length, u32 initval)
|
||||
}
|
||||
|
||||
/* handle the last 3 u32's */
|
||||
- /* all the case statements fall through */
|
||||
switch (length) {
|
||||
- case 3: c += k[2];
|
||||
- case 2: b += k[1];
|
||||
+ case 3: c += k[2]; /* fall through */
|
||||
+ case 2: b += k[1]; /* fall through */
|
||||
case 1: a += k[0];
|
||||
__jhash_final(a, b, c);
|
||||
case 0: /* case 0: nothing left to add */
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
From 84a054951222f902a07bf77dfee0d80c83ee9c6a Mon Sep 17 00:00:00 2001
|
||||
From: Jens Axboe <axboe@kernel.dk>
|
||||
Date: Sun, 5 Nov 2017 08:54:41 -0700
|
||||
Subject: [PATCH 02/15] btt/devs: silence warning on sprintf overflow
|
||||
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
btt/devs.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/btt/devs.c b/btt/devs.c
|
||||
index ccaae87..12ce2ca 100644
|
||||
--- a/btt/devs.c
|
||||
+++ b/btt/devs.c
|
||||
@@ -108,7 +108,7 @@ void dip_exit(void)
|
||||
static inline FILE *open_pit(struct d_info *dip)
|
||||
{
|
||||
FILE *fp;
|
||||
- char str[256];
|
||||
+ char str[272];
|
||||
|
||||
sprintf(str, "%s_pit.dat", dip->dip_name);
|
||||
if ((fp = my_fopen(str, "w")) == NULL)
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,66 +0,0 @@
|
||||
From 4ad65be104d69a100354897e0f04602b4a68461d Mon Sep 17 00:00:00 2001
|
||||
From: Gwendal Grignou <gwendal@chromium.org>
|
||||
Date: Fri, 18 Aug 2017 15:00:22 -0700
|
||||
Subject: [PATCH 03/15] btt: Fix overlapping IO stats.
|
||||
|
||||
Keep scanning the tree for overlapping IO otherwise Q2G and process
|
||||
traces will be incorrect.
|
||||
|
||||
Let assume we have 2 IOs:
|
||||
|
||||
A A+a
|
||||
|---------------------------------------|
|
||||
B B+b
|
||||
|-----------------|
|
||||
|
||||
In the red/black tree we have:
|
||||
|
||||
o -> [A,A+a]
|
||||
/ \
|
||||
left right
|
||||
/ \
|
||||
[...]o o -> [B, B+b]
|
||||
|
||||
In the current code, if we would not be able to find [B+b] in the tree:
|
||||
B is greater than A, so we won't go left
|
||||
B+b is smaller than A+a, so we are not going right either.
|
||||
|
||||
When we have a [X, X+x] IO to look for:
|
||||
We need to check for right when either:
|
||||
X+x >= A+a (for merged IO)
|
||||
and
|
||||
X > A (for overlapping IO)
|
||||
|
||||
TEST=Check with a trace with overlapping IO: Q2C and Q2G are expected.
|
||||
|
||||
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
btt/dip_rb.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/btt/dip_rb.c b/btt/dip_rb.c
|
||||
index 2aa7ffc..6efef6c 100644
|
||||
--- a/btt/dip_rb.c
|
||||
+++ b/btt/dip_rb.c
|
||||
@@ -57,7 +57,7 @@ struct io *rb_find_sec(struct rb_root *root, __u64 sec)
|
||||
__iop = rb_entry(n, struct io, rb_node);
|
||||
if (sec < BIT_START(__iop))
|
||||
n = n->rb_left;
|
||||
- else if (sec >= BIT_END(__iop))
|
||||
+ else if (sec > BIT_START(__iop))
|
||||
n = n->rb_right;
|
||||
else
|
||||
return __iop;
|
||||
@@ -82,7 +82,7 @@ void rb_foreach(struct rb_node *n, struct io *iop,
|
||||
}
|
||||
if (iop_s < this_s)
|
||||
rb_foreach(n->rb_left, iop, fnc, head);
|
||||
- if (this_e < iop_e)
|
||||
+ if ((this_e < iop_e) || (this_s < iop_s))
|
||||
rb_foreach(n->rb_right, iop, fnc, head);
|
||||
}
|
||||
}
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
From 3f8cadf8435fa3c9b0fe8aa1f7e2a50832310560 Mon Sep 17 00:00:00 2001
|
||||
From: weiping zhang <zhangweiping@didichuxing.com>
|
||||
Date: Mon, 15 Jan 2018 23:53:42 +0800
|
||||
Subject: [PATCH 04/15] blktrace: don't stop tracer if not setup trace
|
||||
successfully
|
||||
|
||||
if we run blktrace on same device twice, the second time will failed
|
||||
to ioctl(BLKTRACESETUP), then it will call __stop_tracer, which lead
|
||||
the first blktrace failed to access debugfs entries. So this patch add
|
||||
a check to handle this case, to avoid stop tracer uncondionally.
|
||||
|
||||
Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
blktrace.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/blktrace.c b/blktrace.c
|
||||
index e048f68..d0d271f 100644
|
||||
--- a/blktrace.c
|
||||
+++ b/blktrace.c
|
||||
@@ -112,6 +112,7 @@ struct devpath {
|
||||
struct cl_host *ch;
|
||||
u32 cl_id;
|
||||
time_t cl_connect_time;
|
||||
+ int setup_done; /* ioctl BLKTRACESETUP done */
|
||||
struct io_info *ios;
|
||||
};
|
||||
|
||||
@@ -1083,6 +1084,7 @@ static int setup_buts(void)
|
||||
if (ioctl(dpp->fd, BLKTRACESETUP, &buts) >= 0) {
|
||||
dpp->ncpus = max_cpus;
|
||||
dpp->buts_name = strdup(buts.name);
|
||||
+ dpp->setup_done = 1;
|
||||
if (dpp->stats)
|
||||
free(dpp->stats);
|
||||
dpp->stats = calloc(dpp->ncpus, sizeof(*dpp->stats));
|
||||
@@ -1285,7 +1287,8 @@ static void rel_devpaths(void)
|
||||
struct devpath *dpp = list_entry(p, struct devpath, head);
|
||||
|
||||
list_del(&dpp->head);
|
||||
- __stop_trace(dpp->fd);
|
||||
+ if (dpp->setup_done)
|
||||
+ __stop_trace(dpp->fd);
|
||||
close(dpp->fd);
|
||||
|
||||
if (dpp->heads)
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
From 39aa42dd6baeb9b7eb97b9bc4dadf6925799deee Mon Sep 17 00:00:00 2001
|
||||
From: Weiping Zhang <zhangweiping@didichuxing.com>
|
||||
Date: Sat, 7 Apr 2018 17:12:00 +0800
|
||||
Subject: [PATCH 05/15] blkparse: remove duplicated entry for flag M
|
||||
|
||||
remove dupliated entry 'M' for man page of blkparse.
|
||||
|
||||
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
|
||||
Signed-off-by: Weiping Zhang <zhangweiping@didichuxing.com>
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
doc/blkparse.1 | 4 ----
|
||||
1 file changed, 4 deletions(-)
|
||||
|
||||
diff --git a/doc/blkparse.1 b/doc/blkparse.1
|
||||
index be9b34b..b1cb6ef 100644
|
||||
--- a/doc/blkparse.1
|
||||
+++ b/doc/blkparse.1
|
||||
@@ -243,10 +243,6 @@ Same as the back merge, except this i/o ends where a previously inserted
|
||||
requests starts.
|
||||
|
||||
.HP 4
|
||||
-\fBM --front or back merge\fR
|
||||
-One of the above
|
||||
-
|
||||
-.HP 4
|
||||
\fBM -- front or back merge\fR
|
||||
One of the above.
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,143 +0,0 @@
|
||||
From 4c31f93b0f2e2d44e598f7b7b63381811a192a5d Mon Sep 17 00:00:00 2001
|
||||
From: Jens Axboe <axboe@kernel.dk>
|
||||
Date: Wed, 2 May 2018 10:24:17 -0600
|
||||
Subject: [PATCH 06/15] btt: make device/devno use PATH_MAX to avoid overflow
|
||||
|
||||
Herbo Zhang reports:
|
||||
|
||||
I found a bug in blktrace/btt/devmap.c. The code is just as follows:
|
||||
|
||||
https://git.kernel.org/pub/scm/linux/kernel/git/axboe/blktrace.git/tree/btt/devmap.c?id=8349ad2f2d19422a6241f94ea84d696b21de4757
|
||||
|
||||
struct devmap {
|
||||
|
||||
struct list_head head;
|
||||
char device[32], devno[32]; // #1
|
||||
};
|
||||
|
||||
LIST_HEAD(all_devmaps);
|
||||
|
||||
static int dev_map_add(char *line)
|
||||
{
|
||||
struct devmap *dmp;
|
||||
|
||||
if (strstr(line, "Device") != NULL)
|
||||
return 1;
|
||||
|
||||
dmp = malloc(sizeof(struct devmap));
|
||||
if (sscanf(line, "%s %s", dmp->device, dmp->devno) != 2) { //#2
|
||||
free(dmp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
list_add_tail(&dmp->head, &all_devmaps);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dev_map_read(char *fname)
|
||||
{
|
||||
char line[256]; // #3
|
||||
FILE *fp = my_fopen(fname, "r");
|
||||
|
||||
if (!fp) {
|
||||
perror(fname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (fscanf(fp, "%255[a-zA-Z0-9 :.,/_-]\n", line) == 1) {
|
||||
if (dev_map_add(line))
|
||||
break;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
The line length is 256, but the dmp->device, dmp->devno max length
|
||||
is only 32. We can put strings longer than 32 into dmp->device and
|
||||
dmp->devno , and then they will be overflowed.
|
||||
|
||||
we can trigger this bug just as follows:
|
||||
|
||||
$ python -c "print 'A'*256" > ./test
|
||||
$ btt -M ./test
|
||||
|
||||
*** Error in btt': free(): invalid next size (fast): 0x000055ad7349b250 ***
|
||||
======= Backtrace: =========
|
||||
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f7f158ce7e5]
|
||||
/lib/x86_64-linux-gnu/libc.so.6(+0x7fe0a)[0x7f7f158d6e0a]
|
||||
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f7f158da98c]
|
||||
btt(+0x32e0)[0x55ad7306f2e0]
|
||||
btt(+0x2c5f)[0x55ad7306ec5f]
|
||||
btt(+0x251f)[0x55ad7306e51f]
|
||||
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f7f15877830]
|
||||
btt(+0x26b9)[0x55ad7306e6b9]
|
||||
======= Memory map: ========
|
||||
55ad7306c000-55ad7307f000 r-xp 00000000 08:14 3698139
|
||||
/usr/bin/btt
|
||||
55ad7327e000-55ad7327f000 r--p 00012000 08:14 3698139
|
||||
/usr/bin/btt
|
||||
55ad7327f000-55ad73280000 rw-p 00013000 08:14 3698139
|
||||
/usr/bin/btt
|
||||
55ad73280000-55ad73285000 rw-p 00000000 00:00 0
|
||||
55ad7349a000-55ad734bb000 rw-p 00000000 00:00 0
|
||||
[heap]
|
||||
7f7f10000000-7f7f10021000 rw-p 00000000 00:00 0
|
||||
7f7f10021000-7f7f14000000 ---p 00000000 00:00 0
|
||||
7f7f15640000-7f7f15656000 r-xp 00000000 08:14 14942237
|
||||
/lib/x86_64-linux-gnu/libgcc_s.so.1
|
||||
7f7f15656000-7f7f15855000 ---p 00016000 08:14 14942237
|
||||
/lib/x86_64-linux-gnu/libgcc_s.so.1
|
||||
7f7f15855000-7f7f15856000 r--p 00015000 08:14 14942237
|
||||
/lib/x86_64-linux-gnu/libgcc_s.so.1
|
||||
7f7f15856000-7f7f15857000 rw-p 00016000 08:14 14942237
|
||||
/lib/x86_64-linux-gnu/libgcc_s.so.1
|
||||
7f7f15857000-7f7f15a16000 r-xp 00000000 08:14 14948477
|
||||
/lib/x86_64-linux-gnu/libc-2.23.so
|
||||
7f7f15a16000-7f7f15c16000 ---p 001bf000 08:14 14948477
|
||||
/lib/x86_64-linux-gnu/libc-2.23.so
|
||||
7f7f15c16000-7f7f15c1a000 r--p 001bf000 08:14 14948477
|
||||
/lib/x86_64-linux-gnu/libc-2.23.so
|
||||
7f7f15c1a000-7f7f15c1c000 rw-p 001c3000 08:14 14948477
|
||||
/lib/x86_64-linux-gnu/libc-2.23.so
|
||||
7f7f15c1c000-7f7f15c20000 rw-p 00000000 00:00 0
|
||||
7f7f15c20000-7f7f15c46000 r-xp 00000000 08:14 14948478
|
||||
/lib/x86_64-linux-gnu/ld-2.23.so
|
||||
7f7f15e16000-7f7f15e19000 rw-p 00000000 00:00 0
|
||||
7f7f15e42000-7f7f15e45000 rw-p 00000000 00:00 0
|
||||
7f7f15e45000-7f7f15e46000 r--p 00025000 08:14 14948478
|
||||
/lib/x86_64-linux-gnu/ld-2.23.so
|
||||
7f7f15e46000-7f7f15e47000 rw-p 00026000 08:14 14948478
|
||||
/lib/x86_64-linux-gnu/ld-2.23.so
|
||||
7f7f15e47000-7f7f15e48000 rw-p 00000000 00:00 0
|
||||
7ffdebe5c000-7ffdebe7d000 rw-p 00000000 00:00 0
|
||||
[stack]
|
||||
7ffdebebc000-7ffdebebe000 r--p 00000000 00:00 0
|
||||
[vvar]
|
||||
7ffdebebe000-7ffdebec0000 r-xp 00000000 00:00 0
|
||||
[vdso]
|
||||
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0
|
||||
[vsyscall]
|
||||
[1] 6272 abort btt -M test
|
||||
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
btt/devmap.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/btt/devmap.c b/btt/devmap.c
|
||||
index 0553a9e..5fc1cb2 100644
|
||||
--- a/btt/devmap.c
|
||||
+++ b/btt/devmap.c
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
struct devmap {
|
||||
struct list_head head;
|
||||
- char device[32], devno[32];
|
||||
+ char device[PATH_MAX], devno[PATH_MAX];
|
||||
};
|
||||
|
||||
LIST_HEAD(all_devmaps);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,184 +0,0 @@
|
||||
From 8c28ecc8192e230f859078f527527e31c663cff4 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Sandeen <sandeen@redhat.com>
|
||||
Date: Wed, 28 Mar 2018 15:26:36 -0500
|
||||
Subject: [PATCH 07/15] make btt scripts python3-ready
|
||||
|
||||
Many distributions are moving to python3 by default. Here's
|
||||
an attempt to make the python scripts in blktrace python3-ready.
|
||||
|
||||
Most of this was done with automated tools. I hand fixed some
|
||||
space-vs tab issues, and cast an array index to integer. It
|
||||
passes rudimentary testing when run under python2.7 as well
|
||||
as python3.
|
||||
|
||||
This doesn't do anything with the shebangs, it leaves them both
|
||||
invoking whatever "env python" coughs up on the system.
|
||||
|
||||
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
btt/bno_plot.py | 28 +++++++++++++++-------------
|
||||
btt/btt_plot.py | 22 +++++++++++++---------
|
||||
2 files changed, 28 insertions(+), 22 deletions(-)
|
||||
|
||||
diff --git a/btt/bno_plot.py b/btt/bno_plot.py
|
||||
index aa92480..f05cfdc 100644
|
||||
--- a/btt/bno_plot.py
|
||||
+++ b/btt/bno_plot.py
|
||||
@@ -38,6 +38,8 @@ automatically push the keys under the graph.
|
||||
To exit the plotter, enter 'quit' or ^D at the 'gnuplot> ' prompt.
|
||||
"""
|
||||
|
||||
+from __future__ import absolute_import
|
||||
+from __future__ import print_function
|
||||
import getopt, glob, os, sys, tempfile
|
||||
|
||||
verbose = 0
|
||||
@@ -60,14 +62,14 @@ def parse_args(in_args):
|
||||
|
||||
try:
|
||||
(opts, args) = getopt.getopt(in_args, s_opts, l_opts)
|
||||
- except getopt.error, msg:
|
||||
- print >>sys.stderr, msg
|
||||
- print >>sys.stderr, __doc__
|
||||
+ except getopt.error as msg:
|
||||
+ print(msg, file=sys.stderr)
|
||||
+ print(__doc__, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
for (o, a) in opts:
|
||||
if o in ('-h', '--help'):
|
||||
- print __doc__
|
||||
+ print(__doc__)
|
||||
sys.exit(0)
|
||||
elif o in ('-v', '--verbose'):
|
||||
verbose += 1
|
||||
@@ -84,10 +86,10 @@ if __name__ == '__main__':
|
||||
(bnos, keys_below) = parse_args(sys.argv[1:])
|
||||
|
||||
if verbose:
|
||||
- print 'Using files:',
|
||||
- for bno in bnos: print bno,
|
||||
- if keys_below: print '\nKeys are to be placed below graph'
|
||||
- else: print ''
|
||||
+ print('Using files:', end=' ')
|
||||
+ for bno in bnos: print(bno, end=' ')
|
||||
+ if keys_below: print('\nKeys are to be placed below graph')
|
||||
+ else: print('')
|
||||
|
||||
tmpdir = tempfile.mktemp()
|
||||
os.mkdir(tmpdir)
|
||||
@@ -99,7 +101,7 @@ if __name__ == '__main__':
|
||||
fo = open(t, 'w')
|
||||
for line in open(f, 'r'):
|
||||
fld = line.split(None)
|
||||
- print >>fo, fld[0], fld[1], int(fld[2])-int(fld[1])
|
||||
+ print(fld[0], fld[1], int(fld[2])-int(fld[1]), file=fo)
|
||||
fo.close()
|
||||
|
||||
t = t[t.rfind('/')+1:]
|
||||
@@ -107,16 +109,16 @@ if __name__ == '__main__':
|
||||
else: plot_cmd = "%s,'%s'" % (plot_cmd, t)
|
||||
|
||||
fo = open('%s/plot.cmds' % tmpdir, 'w')
|
||||
- print >>fo, cmds
|
||||
- if len(bnos) > 10 or keys_below: print >>fo, 'set key below'
|
||||
- print >>fo, plot_cmd
|
||||
+ print(cmds, file=fo)
|
||||
+ if len(bnos) > 10 or keys_below: print('set key below', file=fo)
|
||||
+ print(plot_cmd, file=fo)
|
||||
fo.close()
|
||||
|
||||
pid = os.fork()
|
||||
if pid == 0:
|
||||
cmd = 'gnuplot %s/plot.cmds -' % tmpdir
|
||||
|
||||
- if verbose: print 'Executing %s' % cmd
|
||||
+ if verbose: print('Executing %s' % cmd)
|
||||
|
||||
os.chdir(tmpdir)
|
||||
os.system(cmd)
|
||||
diff --git a/btt/btt_plot.py b/btt/btt_plot.py
|
||||
index b81dad5..76fcca8 100755
|
||||
--- a/btt/btt_plot.py
|
||||
+++ b/btt/btt_plot.py
|
||||
@@ -55,6 +55,10 @@ Arguments:
|
||||
but the -o (--output) and -T (--title) options will be ignored.
|
||||
"""
|
||||
|
||||
+from __future__ import absolute_import
|
||||
+from __future__ import print_function
|
||||
+import six
|
||||
+from six.moves import range
|
||||
__author__ = 'Alan D. Brunelle <alan.brunelle@hp.com>'
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@@ -82,7 +86,7 @@ get_base = lambda file: file[file.find('_')+1:file.rfind('_')]
|
||||
def fatal(msg):
|
||||
"""Generate fatal error message and exit"""
|
||||
|
||||
- print >>sys.stderr, 'FATAL: %s' % msg
|
||||
+ print('FATAL: %s' % msg, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@@ -163,7 +167,7 @@ def get_data(files):
|
||||
if not os.path.exists(file):
|
||||
fatal('%s not found' % file)
|
||||
elif verbose:
|
||||
- print 'Processing %s' % file
|
||||
+ print('Processing %s' % file)
|
||||
|
||||
xs = []
|
||||
ys = []
|
||||
@@ -214,8 +218,8 @@ def parse_args(args):
|
||||
|
||||
try:
|
||||
(opts, args) = getopt.getopt(args[1:], s_opts, l_opts)
|
||||
- except getopt.error, msg:
|
||||
- print >>sys.stderr, msg
|
||||
+ except getopt.error as msg:
|
||||
+ print(msg, file=sys.stderr)
|
||||
fatal(__doc__)
|
||||
|
||||
for (o, a) in opts:
|
||||
@@ -293,15 +297,15 @@ def generate_output(type, db):
|
||||
def color(idx, style):
|
||||
"""Returns a color/symbol type based upon the index passed."""
|
||||
|
||||
- colors = [ 'b', 'g', 'r', 'c', 'm', 'y', 'k' ]
|
||||
+ colors = [ 'b', 'g', 'r', 'c', 'm', 'y', 'k' ]
|
||||
l_styles = [ '-', ':', '--', '-.' ]
|
||||
m_styles = [ 'o', '+', '.', ',', 's', 'v', 'x', '<', '>' ]
|
||||
|
||||
color = colors[idx % len(colors)]
|
||||
if style == 'line':
|
||||
- style = l_styles[(idx / len(l_styles)) % len(l_styles)]
|
||||
+ style = l_styles[int((idx / len(l_styles)) % len(l_styles))]
|
||||
elif style == 'marker':
|
||||
- style = m_styles[(idx / len(m_styles)) % len(m_styles)]
|
||||
+ style = m_styles[int((idx / len(m_styles)) % len(m_styles))]
|
||||
|
||||
return '%s%s' % (color, style)
|
||||
|
||||
@@ -314,7 +318,7 @@ def generate_output(type, db):
|
||||
ofile = '%s.png' % type
|
||||
|
||||
if verbose:
|
||||
- print 'Generating plot into %s' % ofile
|
||||
+ print('Generating plot into %s' % ofile)
|
||||
|
||||
fig = plt.figure(figsize=plot_size)
|
||||
ax = fig.add_subplot(111)
|
||||
@@ -329,7 +333,7 @@ def generate_output(type, db):
|
||||
legends = None
|
||||
|
||||
keys = []
|
||||
- for file in db.iterkeys():
|
||||
+ for file in six.iterkeys(db):
|
||||
if not file in ['min_x', 'max_x', 'min_y', 'max_y']:
|
||||
keys.append(file)
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
From 56f1d9991917ff8313e51fba5d3970042ac072ef Mon Sep 17 00:00:00 2001
|
||||
From: Ignat Korchagin <ignat@cloudflare.com>
|
||||
Date: Mon, 16 Sep 2019 10:30:23 -0600
|
||||
Subject: [PATCH 09/15] btreplay: fix device IO remap functionality
|
||||
|
||||
Commit dd093eb1c48e ("Fix warnings on newer gcc") moved string buffers holding
|
||||
device names during map file parse stage to stack. However, only pointers to
|
||||
them are being stored in the allocated "struct map_dev" structure. These
|
||||
pointers are invalid outside of scope of this function and in a different
|
||||
thread context. Also "release_map_devs" function still tries to "free" them
|
||||
later as if they were allocated on the heap.
|
||||
|
||||
Moving the buffers back to the heap by instructing "fscanf" to allocate them
|
||||
while parsing the file.
|
||||
|
||||
Alternatively, we could redefine the "struct map_dev" to include the whole
|
||||
buffers instead of just pointers to them and free them as part of releasing the
|
||||
whole "struct map_dev".
|
||||
|
||||
Fixes: dd093eb1c48e ("Fix warnings on newer gcc")
|
||||
Signed-off-by: Ignat Korchagin <ignat@cloudflare.com>
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
btreplay/btreplay.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/btreplay/btreplay.c b/btreplay/btreplay.c
|
||||
index edaf81f..23cc2a9 100644
|
||||
--- a/btreplay/btreplay.c
|
||||
+++ b/btreplay/btreplay.c
|
||||
@@ -645,7 +645,7 @@ static void find_input_devs(char *idir)
|
||||
static void read_map_devs(char *file_name)
|
||||
{
|
||||
FILE *fp;
|
||||
- char from_dev[256], to_dev[256];
|
||||
+ char *from_dev, *to_dev;
|
||||
|
||||
fp = fopen(file_name, "r");
|
||||
if (!fp) {
|
||||
@@ -653,7 +653,7 @@ static void read_map_devs(char *file_name)
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
- while (fscanf(fp, "%s %s", from_dev, to_dev) == 2) {
|
||||
+ while (fscanf(fp, "%ms %ms", &from_dev, &to_dev) == 2) {
|
||||
struct map_dev *mdp = malloc(sizeof(*mdp));
|
||||
|
||||
mdp->from_dev = from_dev;
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,69 +0,0 @@
|
||||
From 28c81fa538418628addf8b18cbed8ba5c62f3cc8 Mon Sep 17 00:00:00 2001
|
||||
From: Hiroaki Mihara <hmihara@redhat.com>
|
||||
Date: Wed, 25 Sep 2019 07:32:06 +0900
|
||||
Subject: [PATCH 10/15] blkparse: split off the timestamp correction code in to
|
||||
a separate function
|
||||
|
||||
find_genesis() function has code to correct abs_start_time, which is
|
||||
later used to calculate the absolute timestamps of each traced
|
||||
records.
|
||||
|
||||
Put this code in a separate function, so that it can be used later by
|
||||
the blkparse code. No functional change.
|
||||
|
||||
Signed-off-by: Hiroaki Mihara <hmihara@redhat.com>
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
blkparse.c | 29 +++++++++++++++++------------
|
||||
1 file changed, 17 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/blkparse.c b/blkparse.c
|
||||
index 227cc44..fb540ee 100644
|
||||
--- a/blkparse.c
|
||||
+++ b/blkparse.c
|
||||
@@ -1920,6 +1920,22 @@ static void show_device_and_cpu_stats(void)
|
||||
}
|
||||
}
|
||||
|
||||
+static void correct_abs_start_time(void)
|
||||
+{
|
||||
+ long delta = genesis_time - start_timestamp;
|
||||
+
|
||||
+ abs_start_time.tv_sec += SECONDS(delta);
|
||||
+ abs_start_time.tv_nsec += NANO_SECONDS(delta);
|
||||
+ if (abs_start_time.tv_nsec < 0) {
|
||||
+ abs_start_time.tv_nsec += 1000000000;
|
||||
+ abs_start_time.tv_sec -= 1;
|
||||
+ } else
|
||||
+ if (abs_start_time.tv_nsec > 1000000000) {
|
||||
+ abs_start_time.tv_nsec -= 1000000000;
|
||||
+ abs_start_time.tv_sec += 1;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void find_genesis(void)
|
||||
{
|
||||
struct trace *t = trace_list;
|
||||
@@ -1937,18 +1953,7 @@ static void find_genesis(void)
|
||||
*/
|
||||
if (start_timestamp
|
||||
&& start_timestamp != genesis_time) {
|
||||
- long delta = genesis_time - start_timestamp;
|
||||
-
|
||||
- abs_start_time.tv_sec += SECONDS(delta);
|
||||
- abs_start_time.tv_nsec += NANO_SECONDS(delta);
|
||||
- if (abs_start_time.tv_nsec < 0) {
|
||||
- abs_start_time.tv_nsec += 1000000000;
|
||||
- abs_start_time.tv_sec -= 1;
|
||||
- } else
|
||||
- if (abs_start_time.tv_nsec > 1000000000) {
|
||||
- abs_start_time.tv_nsec -= 1000000000;
|
||||
- abs_start_time.tv_sec += 1;
|
||||
- }
|
||||
+ correct_abs_start_time();
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,136 +0,0 @@
|
||||
From 985aa086d949963717d4f730f14eeb8cafd789da Mon Sep 17 00:00:00 2001
|
||||
From: Hiroaki Mihara <hmihara@redhat.com>
|
||||
Date: Wed, 25 Sep 2019 07:32:50 +0900
|
||||
Subject: [PATCH 11/15] blkparse: fix absolute timestamp when reading from file
|
||||
|
||||
This patch fixes the wrong absolute timestamps when blkparse reads
|
||||
data from files.
|
||||
|
||||
The blkparse command prints out wrong timestamps if all the following
|
||||
conditions are met,
|
||||
|
||||
* The blkparse command reads data from files created by blktrace.
|
||||
* "z" format option is set as OUTPUT DESCRIPTION.
|
||||
ex.) blkparse xxx.blktrace.0 -f "%z\n"
|
||||
* start_timestamp(=blktrace command started) != genesis_time(=first
|
||||
I/O traced)
|
||||
|
||||
When blkparse reads data from pipe instead, it yields correct
|
||||
timestamps.
|
||||
|
||||
The root cause of this issue comes from the fact that the time
|
||||
difference between start_timestamp and genesis_time is not added when
|
||||
blkparse reads data from files. When blkparse reads data from pipe,
|
||||
the time-difference is added through find_genesis() function.
|
||||
|
||||
The following test cases show the contradictions in absolute
|
||||
timestams. Also the Step 4 shows that the issue is fixed with the
|
||||
blkparse command with the suggesting patch.
|
||||
|
||||
* Step 1: After invoking blktrace command, test I/O traffic was
|
||||
generated by dd command as follows,
|
||||
|
||||
# date +%Y%m%d_%H%M%S_%N; dd if=/dev/sda3 of=/dev/null count=1 iflag=direct
|
||||
20190919_092726_077032490
|
||||
1+0 records in
|
||||
1+0 records out
|
||||
512 bytes copied, 0.00122329 s, 419 kB/s
|
||||
|
||||
The timestamp was recorded just before executing dd command. The
|
||||
test I/O would have been traced right after 09:27:26.077032490 .
|
||||
|
||||
* Step 2: The blkparse command reads data from "pipe".
|
||||
|
||||
$ cat test.blktrace.* | blkparse - -f "%T.%t %z %C\n"
|
||||
0.000000000 09:27:22.427592 kworker/0:0
|
||||
0.000002080 09:27:22.427594 kworker/0:0
|
||||
.
|
||||
.
|
||||
3.652263118 09:27:26.079855 dd
|
||||
3.652265818 09:27:26.079857 dd
|
||||
3.652274742 09:27:26.079866 dd
|
||||
3.652277266 09:27:26.079869 dd
|
||||
|
||||
The first I/O by dd command showed the relative timestamp as
|
||||
3.652263118 and the absolute timestamp as 09:27:26.079855, which is
|
||||
right after the timestamp shown in the Step 1.
|
||||
|
||||
* Step 3: The blkparse command reads from the trace "file" created in
|
||||
the Step 1.
|
||||
|
||||
$ blkparse test -f "%T.%t %z %C\n"
|
||||
Input file test.blktrace.0 added
|
||||
Input file test.blktrace.1 added
|
||||
Input file test.blktrace.2 added
|
||||
Input file test.blktrace.3 added
|
||||
0.000000000 09:27:21.187304 kworker/0:0
|
||||
0.000002080 09:27:21.187306 kworker/0:0
|
||||
.
|
||||
.
|
||||
3.652263118 09:27:24.839567 dd
|
||||
3.652265818 09:27:24.839570 dd
|
||||
3.652274742 09:27:24.839578 dd
|
||||
3.652277266 09:27:24.839581 dd
|
||||
|
||||
In the previous step (Step 2), the data was passed via pipe. In this
|
||||
case, the blkparse command reads data from the same file, instead.
|
||||
|
||||
The first I/O by dd command showed the relative timestamp as
|
||||
3.652263118 and the absolute timestamp as 09:27:24.839567, which is
|
||||
a few seconds earlier than the absolute timestamp recorded in the
|
||||
Step 1. The order of events and the absolute timestamps contradict.
|
||||
|
||||
* Step 4: The blkparse command with the suggesting patch
|
||||
(./blkparse_with_patch) reads data from the trace file created in
|
||||
the Step 1.
|
||||
|
||||
$ ./blkparse_with_patch test -f "%T.%t %z %C\n"
|
||||
Input file test.blktrace.0 added
|
||||
Input file test.blktrace.1 added
|
||||
Input file test.blktrace.2 added
|
||||
Input file test.blktrace.3 added
|
||||
0.000000000 09:27:22.427592 kworker/0:0
|
||||
0.000002080 09:27:22.427594 kworker/0:0
|
||||
.
|
||||
.
|
||||
3.652263118 09:27:26.079855 dd
|
||||
3.652265818 09:27:26.079857 dd
|
||||
3.652274742 09:27:26.079866 dd
|
||||
3.652277266 09:27:26.079869 dd
|
||||
|
||||
In this case, the absolute timestamps showed the same value as shown
|
||||
in the Step 2(the case with pipe).
|
||||
The time gap between the genesis_ time and the start_timestamp was
|
||||
corrected even if the blkparse reads data from files.
|
||||
|
||||
Signed-off-by: Hiroaki Mihara <hmihara@redhat.com>
|
||||
|
||||
the#
|
||||
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
blkparse.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/blkparse.c b/blkparse.c
|
||||
index fb540ee..08c9f60 100644
|
||||
--- a/blkparse.c
|
||||
+++ b/blkparse.c
|
||||
@@ -2608,6 +2608,14 @@ static int do_file(void)
|
||||
genesis_time = ms_peek_time(ms_head);
|
||||
|
||||
/*
|
||||
+ * Correct abs_start_time if necessary
|
||||
+ */
|
||||
+ if (start_timestamp
|
||||
+ && start_timestamp != genesis_time) {
|
||||
+ correct_abs_start_time();
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
* Keep processing traces while any are left
|
||||
*/
|
||||
while (!is_done() && ms_head && handle(ms_head))
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
From 0980a46e463b1c4286dab77a2a8a3f38dd2266b4 Mon Sep 17 00:00:00 2001
|
||||
From: Vincent Legoll <vincent.legoll@gmail.com>
|
||||
Date: Fri, 20 Mar 2020 22:44:59 +0100
|
||||
Subject: [PATCH 12/15] btt_plot.py: Use `with open() as ...` context manager
|
||||
|
||||
to automatically handle close()
|
||||
|
||||
Signed-off-by: Vincent Legoll <vincent.legoll@gmail.com>
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
btt/btt_plot.py | 28 +++++++++++++++-------------
|
||||
1 file changed, 15 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/btt/btt_plot.py b/btt/btt_plot.py
|
||||
index fcd5838..89ef54f 100755
|
||||
--- a/btt/btt_plot.py
|
||||
+++ b/btt/btt_plot.py
|
||||
@@ -171,14 +171,15 @@ def get_data(files):
|
||||
|
||||
xs = []
|
||||
ys = []
|
||||
- for line in open(file, 'r'):
|
||||
- f = line.rstrip().split(None)
|
||||
- if line.find('#') == 0 or len(f) < 2:
|
||||
- continue
|
||||
- (min_x, max_x, x) = check(min_x, max_x, f[0])
|
||||
- (min_y, max_y, y) = check(min_y, max_y, f[1])
|
||||
- xs.append(x)
|
||||
- ys.append(y)
|
||||
+ with open(file, 'r') as fi:
|
||||
+ for line in fi:
|
||||
+ f = line.rstrip().split(None)
|
||||
+ if line.find('#') == 0 or len(f) < 2:
|
||||
+ continue
|
||||
+ (min_x, max_x, x) = check(min_x, max_x, f[0])
|
||||
+ (min_y, max_y, y) = check(min_y, max_y, f[1])
|
||||
+ xs.append(x)
|
||||
+ ys.append(y)
|
||||
|
||||
db[file] = {'x':xs, 'y':ys}
|
||||
if len(xs) > 10:
|
||||
@@ -388,11 +389,12 @@ def do_live(files):
|
||||
def get_live_data(fn):
|
||||
xs = []
|
||||
ys = []
|
||||
- for line in open(fn, 'r'):
|
||||
- f = line.rstrip().split()
|
||||
- if f[0] != '#' and len(f) == 2:
|
||||
- xs.append(float(f[0]))
|
||||
- ys.append(float(f[1]))
|
||||
+ with open(fn, 'r') as fi:
|
||||
+ for line in fi:
|
||||
+ f = line.rstrip().split()
|
||||
+ if f[0] != '#' and len(f) == 2:
|
||||
+ xs.append(float(f[0]))
|
||||
+ ys.append(float(f[1]))
|
||||
return xs, ys
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,49 +0,0 @@
|
||||
From 2d24805793941d066871f0385a206c4700ea5d59 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Gruenbacher <agruenba@redhat.com>
|
||||
Date: Mon, 13 Apr 2020 21:01:49 +0200
|
||||
Subject: [PATCH 13/15] blkparse: Fix device in event tracking error messages
|
||||
|
||||
For some reason, dev in struct per_dev_info isn't set in the log_track_
|
||||
functions, and so the error messages report (0,0) as the device. Fix by using
|
||||
device in struct blk_io_trace instead.
|
||||
|
||||
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
blkparse.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/blkparse.c b/blkparse.c
|
||||
index 08c9f60..6cba92c 100644
|
||||
--- a/blkparse.c
|
||||
+++ b/blkparse.c
|
||||
@@ -986,7 +986,7 @@ static void log_track_frontmerge(struct per_dev_info *pdi,
|
||||
if (!iot) {
|
||||
if (verbose)
|
||||
fprintf(stderr, "merge not found for (%d,%d): %llu\n",
|
||||
- MAJOR(pdi->dev), MINOR(pdi->dev),
|
||||
+ MAJOR(t->device), MINOR(t->device),
|
||||
(unsigned long long) t->sector + t_sec(t));
|
||||
return;
|
||||
}
|
||||
@@ -1080,7 +1080,7 @@ static unsigned long long log_track_issue(struct per_dev_info *pdi,
|
||||
if (!iot) {
|
||||
if (verbose)
|
||||
fprintf(stderr, "issue not found for (%d,%d): %llu\n",
|
||||
- MAJOR(pdi->dev), MINOR(pdi->dev),
|
||||
+ MAJOR(t->device), MINOR(t->device),
|
||||
(unsigned long long) t->sector);
|
||||
return -1;
|
||||
}
|
||||
@@ -1115,7 +1115,7 @@ static unsigned long long log_track_complete(struct per_dev_info *pdi,
|
||||
if (!iot) {
|
||||
if (verbose)
|
||||
fprintf(stderr,"complete not found for (%d,%d): %llu\n",
|
||||
- MAJOR(pdi->dev), MINOR(pdi->dev),
|
||||
+ MAJOR(t->device), MINOR(t->device),
|
||||
(unsigned long long) t->sector);
|
||||
return -1;
|
||||
}
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,45 +0,0 @@
|
||||
From 83ebfe28ebae191d4435683660a98520b9153401 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Gruenbacher <agruenba@redhat.com>
|
||||
Date: Mon, 13 Apr 2020 21:01:50 +0200
|
||||
Subject: [PATCH 14/15] blkparse: Allow request tracking on non md/dm devices
|
||||
|
||||
Fix queue to completion tracking on devices other than md/dm: without this fix,
|
||||
enabling tracking with the -t option on a non-md/dm device leads to "complete
|
||||
not found" errors.
|
||||
|
||||
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
blkparse.c | 9 ---------
|
||||
1 file changed, 9 deletions(-)
|
||||
|
||||
diff --git a/blkparse.c b/blkparse.c
|
||||
index 6cba92c..2d89bc5 100644
|
||||
--- a/blkparse.c
|
||||
+++ b/blkparse.c
|
||||
@@ -1007,13 +1007,6 @@ static void log_track_getrq(struct per_dev_info *pdi, struct blk_io_trace *t)
|
||||
iot->allocation_time = t->time;
|
||||
}
|
||||
|
||||
-static inline int is_remapper(struct per_dev_info *pdi)
|
||||
-{
|
||||
- int major = MAJOR(pdi->dev);
|
||||
-
|
||||
- return (major == 253 || major == 9);
|
||||
-}
|
||||
-
|
||||
/*
|
||||
* for md/dm setups, the interesting cycle is Q -> C. So track queueing
|
||||
* time here, as dispatch time
|
||||
@@ -1024,8 +1017,6 @@ static void log_track_queue(struct per_dev_info *pdi, struct blk_io_trace *t)
|
||||
|
||||
if (!track_ios)
|
||||
return;
|
||||
- if (!is_remapper(pdi))
|
||||
- return;
|
||||
|
||||
iot = find_track(pdi, t->pid, t->sector);
|
||||
iot->dispatch_time = t->time;
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,148 +0,0 @@
|
||||
From ea086768766f3bf56eec789ba160c90e99a3e622 Mon Sep 17 00:00:00 2001
|
||||
From: Andreas Gruenbacher <agruenba@redhat.com>
|
||||
Date: Mon, 13 Apr 2020 21:01:51 +0200
|
||||
Subject: [PATCH 15/15] blkparse: Initialize and test for undefined request
|
||||
tracking timestamps
|
||||
|
||||
Currently, event tracking timestamps aren't initialized at all even though some
|
||||
places in the code assume that a value of 0 indicates 'undefined'. However, 0
|
||||
is the timestamp of the first event, so use -1ULL for 'undefined' instead.
|
||||
|
||||
In addition, make sure timestamps are only initialized once, and always check
|
||||
if timestamps are defined before using them.
|
||||
|
||||
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
blkparse.c | 46 +++++++++++++++++++++++++++++++++++++++-------
|
||||
1 file changed, 39 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/blkparse.c b/blkparse.c
|
||||
index 2d89bc5..5b3f83a 100644
|
||||
--- a/blkparse.c
|
||||
+++ b/blkparse.c
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
+#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
@@ -306,6 +307,21 @@ static int have_drv_data = 0;
|
||||
#define CPU_IDX(cpu) ((cpu) / CPUS_PER_LONG)
|
||||
#define CPU_BIT(cpu) ((cpu) & (CPUS_PER_LONG - 1))
|
||||
|
||||
+static void io_warn_unless(struct blk_io_trace *t, int condition,
|
||||
+ const char *fmt, ...)
|
||||
+{
|
||||
+ va_list ap;
|
||||
+
|
||||
+ if (condition)
|
||||
+ return;
|
||||
+ va_start(ap, fmt);
|
||||
+ printf("(%d,%d) request %llu + %u: ",
|
||||
+ MAJOR(t->device), MINOR(t->device),
|
||||
+ t->sector, t->bytes);
|
||||
+ vfprintf(stderr, fmt, ap);
|
||||
+ va_end(ap);
|
||||
+}
|
||||
+
|
||||
static void output_binary(void *buf, int len)
|
||||
{
|
||||
if (dump_binary) {
|
||||
@@ -968,6 +984,10 @@ static struct io_track *find_track(struct per_dev_info *pdi, pid_t pid,
|
||||
if (!iot->ppm)
|
||||
iot->ppm = add_ppm_hash(pid, "unknown");
|
||||
iot->sector = sector;
|
||||
+ iot->allocation_time = -1ULL;
|
||||
+ iot->queue_time = -1ULL;
|
||||
+ iot->dispatch_time = -1ULL;
|
||||
+ iot->completion_time = -1ULL;
|
||||
track_rb_insert(pdi, iot);
|
||||
}
|
||||
|
||||
@@ -1004,6 +1024,8 @@ static void log_track_getrq(struct per_dev_info *pdi, struct blk_io_trace *t)
|
||||
return;
|
||||
|
||||
iot = find_track(pdi, t->pid, t->sector);
|
||||
+ io_warn_unless(t, iot->allocation_time == -1ULL,
|
||||
+ "confused about %s time", "allocation");
|
||||
iot->allocation_time = t->time;
|
||||
}
|
||||
|
||||
@@ -1019,6 +1041,8 @@ static void log_track_queue(struct per_dev_info *pdi, struct blk_io_trace *t)
|
||||
return;
|
||||
|
||||
iot = find_track(pdi, t->pid, t->sector);
|
||||
+ io_warn_unless(t, iot->dispatch_time == -1ULL,
|
||||
+ "confused about %s time", "dispatch");
|
||||
iot->dispatch_time = t->time;
|
||||
}
|
||||
|
||||
@@ -1035,9 +1059,11 @@ static unsigned long long log_track_insert(struct per_dev_info *pdi,
|
||||
return -1;
|
||||
|
||||
iot = find_track(pdi, t->pid, t->sector);
|
||||
+ io_warn_unless(t, iot->queue_time == -1ULL,
|
||||
+ "confused about %s time", "queue");
|
||||
iot->queue_time = t->time;
|
||||
|
||||
- if (!iot->allocation_time)
|
||||
+ if (iot->allocation_time == -1ULL)
|
||||
return -1;
|
||||
|
||||
elapsed = iot->queue_time - iot->allocation_time;
|
||||
@@ -1059,7 +1085,7 @@ static unsigned long long log_track_insert(struct per_dev_info *pdi,
|
||||
static unsigned long long log_track_issue(struct per_dev_info *pdi,
|
||||
struct blk_io_trace *t)
|
||||
{
|
||||
- unsigned long long elapsed;
|
||||
+ unsigned long long elapsed = -1ULL;
|
||||
struct io_track *iot;
|
||||
|
||||
if (!track_ios)
|
||||
@@ -1076,10 +1102,13 @@ static unsigned long long log_track_issue(struct per_dev_info *pdi,
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ io_warn_unless(t, iot->dispatch_time == -1ULL,
|
||||
+ "confused about %s time", "dispatch");
|
||||
iot->dispatch_time = t->time;
|
||||
- elapsed = iot->dispatch_time - iot->queue_time;
|
||||
+ if (iot->queue_time != -1ULL)
|
||||
+ elapsed = iot->dispatch_time - iot->queue_time;
|
||||
|
||||
- if (per_process_stats) {
|
||||
+ if (elapsed != -1ULL && per_process_stats) {
|
||||
struct per_process_info *ppi = find_ppi(iot->ppm->pid);
|
||||
int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
|
||||
|
||||
@@ -1096,7 +1125,7 @@ static unsigned long long log_track_issue(struct per_dev_info *pdi,
|
||||
static unsigned long long log_track_complete(struct per_dev_info *pdi,
|
||||
struct blk_io_trace *t)
|
||||
{
|
||||
- unsigned long long elapsed;
|
||||
+ unsigned long long elapsed = -1ULL;
|
||||
struct io_track *iot;
|
||||
|
||||
if (!track_ios)
|
||||
@@ -1111,10 +1140,13 @@ static unsigned long long log_track_complete(struct per_dev_info *pdi,
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ io_warn_unless(t, iot->completion_time == -1ULL,
|
||||
+ "confused about %s time", "completion");
|
||||
iot->completion_time = t->time;
|
||||
- elapsed = iot->completion_time - iot->dispatch_time;
|
||||
+ if (iot->dispatch_time != -1ULL)
|
||||
+ elapsed = iot->completion_time - iot->dispatch_time;
|
||||
|
||||
- if (per_process_stats) {
|
||||
+ if (elapsed != -1ULL && per_process_stats) {
|
||||
struct per_process_info *ppi = find_ppi(iot->ppm->pid);
|
||||
int w = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,70 +0,0 @@
|
||||
From 519fd9a5d08d85f3d9cb4192d624fe8351e40232 Mon Sep 17 00:00:00 2001
|
||||
From: "Robin H. Johnson" <robbat2@gentoo.org>
|
||||
Date: Tue, 23 Jan 2018 17:57:55 -0500
|
||||
Subject: [PATCH] fix parallel build failures
|
||||
|
||||
When building in parallel, the btreplay/btrecord and btreplay/btreplay
|
||||
targets cause make to kick off two jobs for `make -C btreplay` and they
|
||||
sometimes end up clobbering each other. We could fix this by making one
|
||||
a dependency of the other, but it's a bit cleaner to refactor things to
|
||||
be based on subdirs. This way changes in subdirs also get noticed:
|
||||
$ touch btreplay/*.[ch]
|
||||
$ make
|
||||
<btreplay is now correctly updated>
|
||||
|
||||
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
|
||||
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
Makefile | 24 ++++++++++--------------
|
||||
1 file changed, 10 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 68de591..5917814 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -4,23 +4,19 @@ ALL_CFLAGS = $(CFLAGS) -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
|
||||
PROGS = blkparse blktrace verify_blkparse blkrawverify blkiomon
|
||||
LIBS = -lpthread
|
||||
SCRIPTS = btrace
|
||||
+SUBDIRS = btreplay btt iowatcher
|
||||
|
||||
-ALL = $(PROGS) $(SCRIPTS) btt/btt btreplay/btrecord btreplay/btreplay \
|
||||
+ALL = $(PROGS) $(SCRIPTS)
|
||||
+INSTALL_ALL = $(ALL) btt/btt btreplay/btrecord btreplay/btreplay \
|
||||
btt/bno_plot.py iowatcher/iowatcher
|
||||
|
||||
-all: $(ALL)
|
||||
+all: $(ALL) $(SUBDIRS)
|
||||
|
||||
-btt/btt:
|
||||
- $(MAKE) -C btt
|
||||
-
|
||||
-iowatcher/iowatcher:
|
||||
- $(MAKE) -C iowatcher
|
||||
-
|
||||
-btreplay/btrecord:
|
||||
- $(MAKE) -C btreplay
|
||||
-
|
||||
-btreplay/btreplay:
|
||||
- $(MAKE) -C btreplay
|
||||
+# We always descend into subdirs because they contain their own dependency
|
||||
+# information which we don't track in this top level Makefile.
|
||||
+$(SUBDIRS):
|
||||
+ $(MAKE) -C $@
|
||||
+.PHONY: $(SUBDIRS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
|
||||
@@ -85,7 +81,7 @@ install: all
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man8
|
||||
- $(INSTALL) -m 755 $(ALL) $(DESTDIR)$(bindir)
|
||||
+ $(INSTALL) -m 755 $(INSTALL_ALL) $(DESTDIR)$(bindir)
|
||||
$(INSTALL) -m 644 doc/*.1 $(DESTDIR)$(mandir)/man1
|
||||
$(INSTALL) -m 644 doc/*.8 $(DESTDIR)$(mandir)/man8
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,38 +0,0 @@
|
||||
From f4f8ef7cdea138cfaa2f3ca0ee31fa23d3bcf1cc Mon Sep 17 00:00:00 2001
|
||||
From: Gwendal Grignou <gwendal@chromium.org>
|
||||
Date: Thu, 16 Jan 2020 12:33:26 -0800
|
||||
Subject: [PATCH] fix parallel build of btt and blkiomon
|
||||
|
||||
rbtree.c is used by both binaries. It is possible that when make -C btt
|
||||
is invoked rbtree.o does not exist yet, but is already schedule by the
|
||||
compilation of blkiomon. That could result in recompiling rbtree.o again
|
||||
for btt/btt.
|
||||
In that case, at install time, make will recompile blkiomon which can
|
||||
fail in gentoo, because CC variable is not overriden by ebuild script at
|
||||
install time. (see https://bugs.gentoo.org/705594)
|
||||
|
||||
Add a dependency on SUBDIRS to wait for all binary in . to be compiled.
|
||||
It will guarante rbtree.o exists.
|
||||
|
||||
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
|
||||
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
||||
---
|
||||
Makefile | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 5917814..eb3c6a1 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -14,7 +14,7 @@ all: $(ALL) $(SUBDIRS)
|
||||
|
||||
# We always descend into subdirs because they contain their own dependency
|
||||
# information which we don't track in this top level Makefile.
|
||||
-$(SUBDIRS):
|
||||
+$(SUBDIRS): $(PROGS)
|
||||
$(MAKE) -C $@
|
||||
.PHONY: $(SUBDIRS)
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
Binary file not shown.
BIN
blktrace-1.3.0.tar.bz2
Normal file
BIN
blktrace-1.3.0.tar.bz2
Normal file
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
Name: blktrace
|
||||
Version: 1.2.0
|
||||
Release: 26
|
||||
Version: 1.3.0
|
||||
Release: 1
|
||||
Summary: Block IO tracer in the Linux kernel
|
||||
License: GPLv2+
|
||||
Source: http://brick.kernel.dk/snaps/blktrace-%{version}.tar.bz2
|
||||
@ -9,25 +9,9 @@ URL: https://git.kernel.dk/cgit/blktrace
|
||||
BuildRequires: gcc, xz, libaio-devel, python3, librsvg2-devel blktrace sysstat theora-tools
|
||||
Requires: python3
|
||||
|
||||
Patch1: 0001-jhash-fix-annoying-gcc-fall-through-warnings.patch
|
||||
Patch2: 0002-btt-devs-silence-warning-on-sprintf-overflow.patch
|
||||
Patch3: 0003-btt-Fix-overlapping-IO-stats.patch
|
||||
Patch4: 0004-blktrace-don-t-stop-tracer-if-not-setup-trace-succes.patch
|
||||
Patch5: 0005-blkparse-remove-duplicated-entry-for-flag-M.patch
|
||||
Patch6: 0006-btt-make-device-devno-use-PATH_MAX-to-avoid-overflow.patch
|
||||
Patch7: 0007-make-btt-scripts-python3-ready.patch
|
||||
Patch8: 0008-blktrace-remove-python2-dedpendency.patch
|
||||
Patch9: 0009-btreplay-fix-device-IO-remap-functionality.patch
|
||||
Patch10: 0010-blkparse-split-off-the-timestamp-correction-code-in-.patch
|
||||
Patch11: 0011-blkparse-fix-absolute-timestamp-when-reading-from-fi.patch
|
||||
Patch12: 0012-btt_plot.py-Use-with-open-as-.-context-manager.patch
|
||||
Patch13: 0013-blkparse-Fix-device-in-event-tracking-error-messages.patch
|
||||
Patch14: 0014-blkparse-Allow-request-tracking-on-non-md-dm-devices.patch
|
||||
Patch15: 0015-blkparse-Initialize-and-test-for-undefined-request-t.patch
|
||||
Patch16: 0016-blktrace-fix-exit-directly-when-nthreads-running.patch
|
||||
Patch17: 0017-blktrace-Makefile-add-fstack-protector-strong-flag.patch
|
||||
Patch18: 0018-fix-parallel-build-failures.patch
|
||||
Patch19: 0019-fix-parallel-build-of-btt-and-blkiomon.patch
|
||||
Patch1: 0001-blktrace-remove-python2-dedpendency.patch
|
||||
Patch2: 0002-blktrace-Makefile-add-fstack-protector-strong-flag.patch
|
||||
Patch3: 0003-blktrace-fix-exit-directly-when-nthreads-running.patch
|
||||
|
||||
%description
|
||||
blktrace is a block layer IO tracing mechanism which provides detailed
|
||||
@ -92,6 +76,9 @@ comparing the differences between different benchmark runs.
|
||||
%{_mandir}/man1/iowatcher.*
|
||||
|
||||
%changelog
|
||||
* Mon Nov 22 2021 Li Jinlin <lijinlin3@huawei.com> - 1.3.0-1
|
||||
- Update blktrace version to 1.3.0-1
|
||||
|
||||
* Sat Oct 09 2021 zhanchengbin <zhanchengbin1@huawei.com> - 1.2.0-26
|
||||
- Fixed the issue of modifying parallel compilation
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user