!75 backport upstream patches

From: @wangxiao65 
Reviewed-by: @swf504 
Signed-off-by: @swf504
This commit is contained in:
openeuler-ci-bot 2024-09-24 06:42:10 +00:00 committed by Gitee
commit f769320612
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 142 additions and 1 deletions

View File

@ -0,0 +1,40 @@
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] 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>
Conflict: no
Reference: https://git.kernel.dk/cgit/blktrace/commit/?id=ac416ab67cd7add0089c3bc668427e6b909eb59e
---
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

@ -0,0 +1,35 @@
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] 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>
Conflict: no
Reference: https://git.kernel.dk/cgit/blktrace/commit/?id=7f5d2c5173d72018aa29c583c9291ef10abaf8df
---
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

@ -0,0 +1,57 @@
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] 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>
Conflict: no
Reference: https://git.kernel.dk/cgit/blktrace/commit/?id=1836be5d99c9362f1e2b39206c95270f19cb7faa
---
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

@ -1,6 +1,6 @@
Name: blktrace
Version: 1.2.0
Release: 26
Release: 27
Summary: Block IO tracer in the Linux kernel
License: GPLv2+
Source: http://brick.kernel.dk/snaps/blktrace-%{version}.tar.bz2
@ -30,6 +30,9 @@ Patch16: 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
Patch20: 0020-blkparse-skip-check_cpu_map-with-pipe-input.patch
Patch21: 0021-blkparse-fix-incorrectly-sized-memset-in-check_cpu_m.patch
Patch22: 0022-fix-hang-when-BLKTRACESETUP-fails-and-o-is-used.patch
%description
blktrace is a block layer IO tracing mechanism which provides detailed
@ -64,6 +67,12 @@ make dest=%{buildroot} prefix=%{buildroot}/%{_prefix} mandir=%{buildroot}/%{_man
%{_mandir}/man8/*
%changelog
* Tue Sep 24 2024 wangxiao <wangxiao184@h-partners.com> - 1.2.0-27
- DESC: backport upstream patches
blkparse skip check_cpu_map with pipe input
blkparse fix incorrectly sized memset in check_cpu_map
fix hang when BLKTRACESETUP fails and "-o -" is used
* Sat Oct 09 2021 zhanchengbin <zhanchengbin1@huawei.com> - 1.2.0-26
- Fixed the issue of modifying parallel compilation