Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
3101a71040
!82 [sync] PR-77: blkparse: Fix a potential coredump issue
From: @openeuler-sync-bot 
Reviewed-by: @volcanodragon 
Signed-off-by: @volcanodragon
2025-03-24 09:10:38 +00:00
Kou Wenqi
d93d259719 blkparse: Fix a potential coredump issue
(cherry picked from commit 8232b1005399fcaf6c03eba235a39efac36dd774)
2025-03-24 12:00:38 +08:00
openeuler-ci-bot
bca358c9ee
!60 backport bugfix patches from upstream
From: @foolstrong 
Reviewed-by: @swf504 
Signed-off-by: @swf504
2024-07-31 06:24:34 +00:00
foolstrong
3bb0852c74 backport bugfix patches from upstream 2024-07-31 11:44:15 +08:00
openeuler-ci-bot
aa4cbaec82
!52 provide iowatcher via Provides
From: @windfine 
Reviewed-by: @liuzhiqiang26 
Signed-off-by: @liuzhiqiang26
2022-05-17 12:28:14 +00:00
Li Jinlin
958edb7506 provide iowatcher via Provide 2022-05-16 17:53:13 +08:00
openeuler-ci-bot
659bcf47c5 !50 Update blktrace version to 1.3.0
From: @windfine
Reviewed-by: @liuzhiqiang26
Signed-off-by: @liuzhiqiang26
2021-11-23 10:44:21 +00:00
Li Jinlin
34ffb3887d Update blktrace version to 1.3.0 2021-11-22 16:30:40 +08:00
openeuler-ci-bot
0429f76147 !43 Fixed the issue of modifying parallel compilation
From: @hifi521
Reviewed-by: @liuzhiqiang26
Signed-off-by: @liuzhiqiang26
2021-10-11 02:23:51 +00:00
zhanchengbin
5c12e46926 Fixed the issue of modifying parallel compilation 2021-10-09 15:14:34 +08:00
24 changed files with 249 additions and 1179 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,37 @@
From ac416ab67cd7add0089c3bc668427e6b909eb59e Mon Sep 17 00:00:00 2001
From: Jeff Mahoney <jeffm@suse.com>
Date: Thu, 21 Oct 2021 10:16:19 -0400
Subject: [PATCH 2/5] blkparse: skip check_cpu_map with pipe input
When we're using pipe input, we don't track online CPUs and don't have a
cpu_map. When we start to show entries, check_sequence will be invoked.
If the first entry isn't sequence 1 (perhaps it's been dropped?), we'll
proceed to check_cpu_map. Since we haven't tracked online CPUs,
pdi->cpu_map_max will be 0 and we'll do a malloc(0). Then we'll start
setting bits corresponding to CPU numbers in memory we don't own. Since
there's nothing to check here, let's skip it on pipe input.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
blkparse.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/blkparse.c b/blkparse.c
index f88204a..498857c 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2229,6 +2229,10 @@ static int check_cpu_map(struct per_dev_info *pdi)
unsigned int i;
int ret, cpu;
+ /* Pipe input doesn't do CPU online tracking. */
+ if (!pdi->cpu_map_max)
+ return 0;
+
/*
* create a map of the cpus we have traces for
*/
--
2.33.0

View File

@ -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

View File

@ -0,0 +1,32 @@
From 7f5d2c5173d72018aa29c583c9291ef10abaf8df Mon Sep 17 00:00:00 2001
From: Jeff Mahoney <jeffm@suse.com>
Date: Thu, 21 Oct 2021 10:16:20 -0400
Subject: [PATCH 3/5] blkparse: fix incorrectly sized memset in check_cpu_map
The memset call in check_cpu_map always clears sizeof(unsigned long *)
regardless of what size was allocated. Use calloc instead to allocate
the map so it's zeroed properly regardless of the size requested.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
blkparse.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/blkparse.c b/blkparse.c
index 498857c..9d2029a 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -2236,8 +2236,7 @@ static int check_cpu_map(struct per_dev_info *pdi)
/*
* create a map of the cpus we have traces for
*/
- cpu_map = malloc(pdi->cpu_map_max / sizeof(long));
- memset(cpu_map, 0, sizeof(*cpu_map));
+ cpu_map = calloc(1, pdi->cpu_map_max / sizeof(long));
n = rb_first(&rb_sort_root);
while (n) {
__t = rb_entry(n, struct trace, rb_node);
--
2.33.0

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,54 @@
From 1836be5d99c9362f1e2b39206c95270f19cb7faa Mon Sep 17 00:00:00 2001
From: Eric Sandeen <sandeen@redhat.com>
Date: Wed, 5 Jun 2024 23:07:27 -0500
Subject: [PATCH 5/5] fix hang when BLKTRACESETUP fails and "-o -" is used
# blktrace -o - /dev/sda /dev/sdb /dev/sdc
has to be SIGKILLed if BLKTRACESETUP fails for any or all of the devices
listed. (I simulated this by just catching one of the devices in
setup_buts(), skipping the ioctl, and doing ret++).
This seems to be because with "-o -" on the command line, use_tracer_devpaths()
sees piped_output set, so we call process_trace_bufs which ends up waiting on
(!done) and "done" is never set. i.e.
atexit(exit_tracing)
wait_tracers
if (use_tracer_devpaths()) // true because "-o -"
process_trace_bufs
while (wait_empty_entries())
wait_empty_entries
while (!done ... )
<loop forever>
I think this can be avoided by just setting "done = 1" before returning
when setup_buts() fails in run_tracers().
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Link: https://lore.kernel.org/r/f3204c9d-1384-40b5-a5fb-3bb967ca2bec@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
blktrace.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/blktrace.c b/blktrace.c
index 3444fbb..038b2cb 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -2684,8 +2684,10 @@ static int run_tracers(void)
if (net_mode == Net_client)
printf("blktrace: connecting to %s\n", hostname);
- if (setup_buts())
+ if (setup_buts()) {
+ done = 1;
return 1;
+ }
if (use_tracer_devpaths()) {
if (setup_tracer_devpaths())
--
2.33.0

View File

@ -0,0 +1,96 @@
From f9bd00dfbd67ce62ca6df6f55d6275b523cd0b39 Mon Sep 17 00:00:00 2001
From: Kou Wenqi <kouwenqi@kylinos.cn>
Date: Wed, 19 Mar 2025 21:02:49 +0800
Subject: [PATCH] blkparse: Fix a potential coredump issue
Executing "blkparse -t" may cause coredump due to
accessing uninitialized memory.
8,16 0 6092 1.436280373 20685 Q W 15356912 + 4096 [kworker/u256:2]
8,16 0 6093 1.436282093 20685 X W 15356912 / 15357936 [kworker/u256:2]
8,16 0 6094 1.436282735 20685 G W 15356912 + 1024 [kworker/u256:2]
8,16 0 6099 1.436358617 20685 X W 15357936 / 15358960 [kworker/u256:2]
8,16 0 6100 1.436359418 20685 G W 15357936 + 1024 [kworker/u256:2]
8,16 0 6102 1.436359931 20685 I W 15356912 + 1024 [kworker/u256:2]
8,16 0 6103 1.436360874 20685 D W 15356912 + 1024 [kworker/u256:2]
8,16 0 6105 1.436436572 20685 X W 15358960 / 15359984 [kworker/u256:2]
8,16 0 6106 1.436437679 20685 G W 15358960 + 1024 [kworker/u256:2]
8,16 0 6108 1.436438205 20685 I W 15357936 + 1024 [kworker/u256:2]
8,16 0 6109 1.436439368 20685 D W 15357936 + 1024 [kworker/u256:2]
8,16 0 6111 1.436530404 20685 G W 15359984 + 1024 [kworker/u256:2]
8,16 0 6113 1.436530842 20685 I W 15358960 + 1024 [kworker/u256:2]
8,16 0 6114 1.436531748 20685 D W 15358960 + 1024 [kworker/u256:2]
8,16 0 6120 1.436755261 20685 I W 15359984 + 1024 [kworker/u256:2]
8,16 0 6121 1.436756476 20685 D W 15359984 + 1024 [kworker/u256:2]
8,16 0 6128 1.437120354 0 C W 15356912 + 1024 [0]
8,16 0 6129 1.437121875 0 C W 15356912 + 2048 [0]
Breakpoint 3, log_track_split (pdi=0x430260, t=0x711990) at blkparse.c:1076
1076 iot = find_track(pdi, t->pid, t->sector);
(gdb) n
1077 split = malloc(sizeof(*iot));
(gdb)
1078 split->req = iot->req;
(gdb) p split
$1 = (struct io_track *) 0x69bdd0
(gdb) p *split
$2 = {rb_node = {rb_parent_color = 6929360, rb_right = 0x0, rb_left = 0xe81bf0}, req = 0x2000d00080000, next = 0x800010000050cd, sector = 2251799813685248}
Program received signal SIGSEGV, Segmentation fault.
0x000000000040bcbc in rb_set_parent (rb=0xe81bf0, p=0x69bbd0) at rbtree.h:133
133 rb->rb_parent_color = (rb->rb_parent_color & 3) | (unsigned long)p;
(gdb) bt
#0 0x000000000040bcbc in rb_set_parent (rb=0xe81bf0, p=0x69bbd0) at rbtree.h:133
#1 0x000000000040c724 in rb_erase (node=0x69bdd0, root=0x430418) at rbtree.c:273
#2 0x0000000000404810 in log_track_complete (pdi=0x430260, t=0x712810) at blkparse.c:1223
#3 0x00000000004055e4 in log_complete (pdi=0x430260, pci=0x4bc100, t=0x712810, act=0x40cf60 "C") at blkparse.c:1518
#4 0x0000000000405ea0 in dump_trace_fs (t=0x712810, pdi=0x430260, pci=0x4bc100) at blkparse.c:1680
#5 0x000000000040604c in dump_trace (t=0x712810, pci=0x4bc100, pdi=0x430260) at blkparse.c:1722
#6 0x00000000004090e8 in handle (msp=0x433cf0) at blkparse.c:2639
#7 0x000000000040931c in do_file () at blkparse.c:2712
#8 0x000000000040a0cc in main (argc=4, argv=0xfffffffff438) at blkparse.c:3045
(gdb) p rb
$3 = (struct rb_node *) 0xe81bf0
(gdb) p *rb
Cannot access memory at address 0xe81bf0
(gdb) up
273 rb_set_parent(child, parent);
(gdb) p child
$4 = (struct rb_node *) 0xe81bf0
(gdb) p node
$5 = (struct rb_node *) 0x69bdd0
(gdb) p *node
$6 = {rb_parent_color = 6929360, rb_right = 0x0, rb_left = 0xe81bf0}
Signed-off-by: Kou Wenqi <kouwenqi@kylinos.cn>
Link: https://lore.kernel.org/r/tencent_DE806EEE1852F9E79115172254B8A2789207@qq.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
blkparse.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/blkparse.c b/blkparse.c
index 9d2029a..d6aaa8b 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -1022,7 +1022,7 @@ static struct io_track *find_track(struct per_dev_info *pdi, pid_t pid,
if (!iot) {
struct io_track_req *req;
- req = malloc(sizeof(*req) + sizeof(*iot));
+ req = calloc(1, sizeof(*req) + sizeof(*iot));
req->ppm = find_ppm(pid);
if (!req->ppm)
req->ppm = add_ppm_hash(pid, "unknown");
@@ -1106,7 +1106,7 @@ static void log_track_split(struct per_dev_info *pdi, struct blk_io_trace *t)
* parts.
*/
iot = find_track(pdi, t->pid, t->sector);
- split = malloc(sizeof(*iot));
+ split = calloc(1, sizeof(*iot));
split->req = iot->req;
split->next = iot->next;
iot->next = split;
--
2.43.0

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

Binary file not shown.

BIN
blktrace-1.3.0.tar.bz2 Normal file

Binary file not shown.

View File

@ -1,31 +1,23 @@
Name: blktrace
Version: 1.2.0
Release: 25
Version: 1.3.0
Release: 4
Summary: Block IO tracer in the Linux kernel
License: GPLv2+
Source: http://brick.kernel.dk/snaps/blktrace-%{version}.tar.bz2
URL: https://git.kernel.dk/cgit/blktrace
BuildRequires: gcc, xz, libaio-devel, python3, librsvg2-devel blktrace sysstat theora-tools
Provides: iowatcher = %{version}-%{release}
Obsoletes: iowatcher < %{version}-%{release}
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
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
Patch4: 0004-blkparse-skip-check_cpu_map-with-pipe-input.patch
Patch5: 0005-blkparse-fix-incorrectly-sized-memset-in-check_cpu_m.patch
Patch6: 0006-fix-hang-when-BLKTRACESETUP-fails-and-o-is-used.patch
Patch7: 0007-blkparse-Fix-a-potential-coredump-issue.patch
%description
blktrace is a block layer IO tracing mechanism which provides detailed
@ -52,44 +44,31 @@ make dest=%{buildroot} prefix=%{buildroot}/%{_prefix} mandir=%{buildroot}/%{_man
%files
%defattr(-,root,root)
%doc README COPYING
%{_bindir}/blkparse
%{_bindir}/blkrawverify
%{_bindir}/bno_plot.py
%{_bindir}/btt
%{_bindir}/verify_blkparse
%{_bindir}/blkiomon
%{_bindir}/blktrace
%{_bindir}/btrace
%{_bindir}/btrecord
%{_bindir}/btreplay
%{_bindir}/*
%{_bindir}/iowatcher
%files help
%{_mandir}/man1/blkparse.*
%{_mandir}/man1/blkrawverify.*
%{_mandir}/man1/bno_plot.*
%{_mandir}/man1/btt.*
%{_mandir}/man1/verify_blkparse.*
%{_mandir}/man8/blkiomon.*
%{_mandir}/man8/blktrace.*
%{_mandir}/man8/btrace.*
%{_mandir}/man8/btrecord.*
%{_mandir}/man8/btreplay.*
%{_mandir}/man1/*
%{_mandir}/man8/*
%package -n iowatcher
Summary: Utility for visualizing block layer IO patterns and performance
Requires: blktrace sysstat theora-tools
%description -n iowatcher
iowatcher can plot multiple blktrace runs together,
comparing the differences between different benchmark runs.
%files -n iowatcher
%doc README iowatcher/COPYING
%{_bindir}/iowatcher
%{_mandir}/man1/iowatcher.*
%changelog
* Fri Mar 21 2025 kouwenqi <kouwenqi@kylinos.cn> - 1.3.0-4
- blkparse: Fix a potential coredump issue
* Wed Jul 31 2024 wangzhiqiang <wangzhiqiang95@huawei.com> - 1.3.0-3
- backport bugfix patches from upstream
* Mon May 16 2022 Li Jinlin <lijinlin3@huawei.com> - 1.3.0-2
- provide iowatcher via Provides
* 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
* Wed Sep 29 2021 Wenchao Hao <haowenchao@huawei.com> - 1.2.0-25
- NOP:nothing but to make it able to sync between differnt branches