Fix rhbz2081102 and rhbz2085647

This commit is contained in:
Martin Cermak 2022-05-17 10:50:56 +00:00
parent 396e21b1a2
commit b8a6290bd2
3 changed files with 333 additions and 1 deletions

258
rhbz2081102.patch Normal file
View File

@ -0,0 +1,258 @@
commit 093b972294256b3ad68712daecdfdc5da1418a13
Author: Martin Cermak <mcermak@redhat.com>
Date: Mon May 9 20:00:15 2022 +0200
refix PR28634 for rhel8+ kernels
The rhel kernel backports do not always align to upstream, so that
the KERNEL_VERSION() based gate needs to be updated using a version
that does the expected thing for the rhel{7,8,9} kernels.
diff --git a/tapset/linux/ioscheduler.stp b/tapset/linux/ioscheduler.stp
index 3096a73ea..c7231878d 100644
--- a/tapset/linux/ioscheduler.stp
+++ b/tapset/linux/ioscheduler.stp
@@ -11,7 +11,7 @@
// </tapsetdescription>
%{
#include <linux/blkdev.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5,16,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,18,0)
#include <linux/elevator.h>
#endif
%}
@@ -41,7 +41,7 @@ probe ioscheduler.elv_next_request = kernel.function("blk_peek_request") !,
*/
probe ioscheduler.elv_next_request.return =
kernel.function("blk_peek_request").return !,
- kernel.function("elv_next_request").return
+ kernel.function("elv_next_request").return ?
{
name = "elv_next_request"
if ($return == 0) {
@@ -80,18 +80,14 @@ probe ioscheduler.elv_completed_request
@choose_defined($q->elevator->elevator_type->elevator_name,
@choose_defined($q->elevator->elevator_name,
0))), "")
- if($rq == 0) {
- disk_major = -1
- disk_minor = -1
- } else {
- if($rq->rq_disk == 0) {
- disk_major = -1
- disk_minor = -1
- } else {
- disk_major = $rq->rq_disk->major
- disk_minor = $rq->rq_disk->first_minor
- }
- }
+ disk_major = -1
+ disk_minor = -1
+ // kernel f3fa33acca9f0058157214800f68b10d8e71ab7a
+ // block: remove the ->rq_disk field in struct request
+ if(@defined($rq->rq_disk) && ($rq->rq_disk != 0)) {
+ disk_major = $rq->rq_disk->major
+ disk_minor = $rq->rq_disk->first_minor
+ }
rq = $rq
rq_flags = ($rq == 0) ? 0
@@ -111,7 +107,7 @@ probe ioscheduler.elv_completed_request
// when a request is added to the request queue
probe ioscheduler.elv_add_request.kp =
kernel.function("elv_insert") !,
- kernel.function("__elv_add_request")
+ kernel.function("__elv_add_request") ?
{
name = "elv_add_request"
elevator_name = kernel_string(
@@ -120,18 +116,15 @@ probe ioscheduler.elv_add_request.kp =
@choose_defined($q->elevator->elevator_name,
0))), "")
q = $q
- if($rq == 0) {
- disk_major = -1
- disk_minor = -1
- } else {
- if($rq->rq_disk == 0) {
- disk_major = -1
- disk_minor = -1
- } else {
- disk_major = $rq->rq_disk->major
- disk_minor = $rq->rq_disk->first_minor
- }
- }
+
+ disk_major = -1
+ disk_minor = -1
+ // kernel f3fa33acca9f0058157214800f68b10d8e71ab7a
+ // block: remove the ->rq_disk field in struct request
+ if(@defined($rq->rq_disk) && ($rq->rq_disk != 0)) {
+ disk_major = $rq->rq_disk->major
+ disk_minor = $rq->rq_disk->first_minor
+ }
rq = $rq
rq_flags = ($rq == 0) ? 0
@@ -160,11 +153,11 @@ probe ioscheduler.elv_add_request.tp = kernel.trace("block_rq_insert") ?
0))), "")
rq = $rq
- if ($rq == 0 || $rq->rq_disk ==0) {
- disk_major = -1
- disk_minor = -1
- }
- else {
+ disk_major = -1
+ disk_minor = -1
+ // kernel f3fa33acca9f0058157214800f68b10d8e71ab7a
+ // block: remove the ->rq_disk field in struct request
+ if(@defined($rq->rq_disk) && ($rq->rq_disk != 0)) {
disk_major = $rq->rq_disk->major
disk_minor = $rq->rq_disk->first_minor
}
@@ -184,7 +177,7 @@ probe ioscheduler.elv_add_request.tp = kernel.trace("block_rq_insert") ?
*
*/
probe ioscheduler.elv_add_request =
- ioscheduler.elv_add_request.tp !, ioscheduler.elv_add_request.kp
+ ioscheduler.elv_add_request.tp !, ioscheduler.elv_add_request.kp ?
{}
/**
@@ -211,14 +204,14 @@ probe ioscheduler_trace.elv_completed_request
rq = $rq
- if ($rq == 0 || $rq->rq_disk ==0) {
- disk_major = -1
- disk_minor = -1
- }
- else {
- disk_major = $rq->rq_disk->major
- disk_minor = $rq->rq_disk->first_minor
- }
+ disk_major = -1
+ disk_minor = -1
+ // kernel f3fa33acca9f0058157214800f68b10d8e71ab7a
+ // block: remove the ->rq_disk field in struct request
+ if(@defined($rq->rq_disk) && ($rq->rq_disk != 0)) {
+ disk_major = $rq->rq_disk->major
+ disk_minor = $rq->rq_disk->first_minor
+ }
rq_flags = ($rq == 0) ? 0
: @choose_defined($rq->cmd_flags, $rq->flags)
@@ -247,14 +240,14 @@ probe ioscheduler_trace.elv_issue_request
0))), "")
rq = $rq
- if ($rq == 0 || $rq->rq_disk ==0) {
- disk_major = -1
- disk_minor = -1
- }
- else {
+ disk_major = -1
+ disk_minor = -1
+ // kernel f3fa33acca9f0058157214800f68b10d8e71ab7a
+ // block: remove the ->rq_disk field in struct request
+ if(@defined($rq->rq_disk) && ($rq->rq_disk != 0)) {
disk_major = $rq->rq_disk->major
disk_minor = $rq->rq_disk->first_minor
- }
+ }
rq_flags = ($rq == 0) ? 0
: @choose_defined($rq->cmd_flags, $rq->flags)
@@ -283,14 +276,14 @@ probe ioscheduler_trace.elv_requeue_request
0))), "")
rq = $rq
- if ($rq == 0 || $rq->rq_disk ==0) {
- disk_major = -1
- disk_minor = -1
- }
- else {
- disk_major = $rq->rq_disk->major
- disk_minor = $rq->rq_disk->first_minor
- }
+ disk_major = -1
+ disk_minor = -1
+ // kernel f3fa33acca9f0058157214800f68b10d8e71ab7a
+ // block: remove the ->rq_disk field in struct request
+ if(@defined($rq->rq_disk) && ($rq->rq_disk != 0)) {
+ disk_major = $rq->rq_disk->major
+ disk_minor = $rq->rq_disk->first_minor
+ }
rq_flags = ($rq == 0) ? 0
: @choose_defined($rq->cmd_flags, $rq->flags)
@@ -318,14 +311,14 @@ probe ioscheduler_trace.elv_abort_request
0))), "")
rq = $rq
- if ($rq == 0 || $rq->rq_disk ==0) {
- disk_major = -1
- disk_minor = -1
- }
- else {
- disk_major = $rq->rq_disk->major
- disk_minor = $rq->rq_disk->first_minor
- }
+ disk_major = -1
+ disk_minor = -1
+ // kernel f3fa33acca9f0058157214800f68b10d8e71ab7a
+ // block: remove the ->rq_disk field in struct request
+ if(@defined($rq->rq_disk) && ($rq->rq_disk != 0)) {
+ disk_major = $rq->rq_disk->major
+ disk_minor = $rq->rq_disk->first_minor
+ }
rq_flags = ($rq == 0) ? 0
: @choose_defined($rq->cmd_flags, $rq->flags)
diff --git a/testsuite/buildok/ioscheduler-all-probes.stp b/testsuite/buildok/ioscheduler-all-probes.stp
index da182c774..a8d8e08c5 100755
--- a/testsuite/buildok/ioscheduler-all-probes.stp
+++ b/testsuite/buildok/ioscheduler-all-probes.stp
@@ -2,6 +2,6 @@
// Tests if all probes in the ioscheduler tapset are resolvable.
-probe ioscheduler.*, ioscheduler.*.return {}
+probe ioscheduler.* ?, ioscheduler.*.return ? {}
probe ioscheduler_trace.* ? {}
diff --git a/testsuite/buildok/ioscheduler-detailed.stp b/testsuite/buildok/ioscheduler-detailed.stp
index 143f20cd6..033e955dc 100755
--- a/testsuite/buildok/ioscheduler-detailed.stp
+++ b/testsuite/buildok/ioscheduler-detailed.stp
@@ -6,24 +6,24 @@
# test the kprobes aliases (*.kp). This could cause them to get out
# of sync with the kprobed functions. So, we test them explicitly.
-probe ioscheduler.elv_next_request
+probe ioscheduler.elv_next_request ?
{
printf("%s: %s\n", name, elevator_name)
}
-probe ioscheduler.elv_next_request.return
+probe ioscheduler.elv_next_request.return ?
{
printf("name: %s, %d, %d, %p, %d", name, disk_major,
disk_minor, rq, rq_flags)
}
-probe ioscheduler.elv_completed_request
+probe ioscheduler.elv_completed_request ?
{
printf("name: %s, elv_name: %s, %d, %d, %p, %d", name, elevator_name,
disk_major, disk_minor, rq, rq_flags)
}
-probe ioscheduler.elv_add_request,
- ioscheduler.elv_add_request.kp,
+probe ioscheduler.elv_add_request ?,
+ ioscheduler.elv_add_request.kp ?,
ioscheduler.elv_add_request.tp ?
{
printf("name: %s, elv_name: %s, %d, %d, %p, %d", name, elevator_name,

66
rhbz2085647.patch Normal file
View File

@ -0,0 +1,66 @@
commit a0fa7bf0b68058d8f41a5fde608362172a2c3d77
Author: Martin Cermak <mcermak@redhat.com>
Date: Wed May 11 22:22:00 2022 +0200
Update examples/io/iostat-scsi.stp for modern rhel9 kernels.
Update examples/io/iostat-scsi.stp for kernels having following
upstream kernel commit backported:
commit f3fa33acca9f0058157214800f68b10d8e71ab7a
Author: Christoph Hellwig <hch@lst.de>
Date: Fri Nov 26 13:18:00 2021 +0100
block: remove the ->rq_disk field in struct request
Just use the disk attached to the request_queue instead.
[ ... stuff deleted ... ]
diff --git a/testsuite/systemtap.examples/io/iostat-scsi.stp b/testsuite/systemtap.examples/io/iostat-scsi.stp
index 3faf32fe9..aa0238a7b 100755
--- a/testsuite/systemtap.examples/io/iostat-scsi.stp
+++ b/testsuite/systemtap.examples/io/iostat-scsi.stp
@@ -2,12 +2,18 @@
global devices, reads, writes
+/* kernel commit f3fa33acca9f0058157214800f68b10d8e71ab7a */
+@define __disk_name(__request)
+%(
+ ( @choose_defined(@__request->rq_disk->disk_name, @__request->q->disk->disk_name ) )
+%)
+
/* data collection: SCSI disk */
%(kernel_v < "2.6.24" %?
probe module("sd_mod").function("sd_init_command") !,
kernel.function("sd_init_command")
{
- device = kernel_string($SCpnt->request->rq_disk->disk_name)
+ device = kernel_string(@__disk_name($SCpnt->request))
sector_size = $SCpnt->device->sector_size
nr_sectors = $SCpnt->request->nr_sectors
devices[device] = 1
@@ -38,7 +44,7 @@ function get_nr_sectors:long(rq:long)
probe sd_prep_fn = module("sd_mod").function("sd_prep_fn") !,
kernel.function("sd_prep_fn")
{
- device = kernel_string($rq->rq_disk->disk_name)
+ device = kernel_string(@__disk_name($rq))
sector_size = @cast($q->queuedata, "scsi_device", "kernel<scsi/scsi_device.h>")->sector_size
%(kernel_v>="2.6.31" %?
nr_sectors = get_nr_sectors($rq)
@@ -58,11 +64,11 @@ probe sd_init_command = module("sd_mod").function("sd_init_command") !,
sector_size = @choose_defined($cmd, $SCpnt)->device->sector_size
# Kernel commits aa8e25e5006aac52c943c84e9056ab488630ee19 2266a2def97ce11ec979b6c58a1b637a16eca7dd
if (@defined(@choose_defined($cmd, $SCpnt)->request)) {
- device = kernel_string(@choose_defined($cmd, $SCpnt)->request->rq_disk->disk_name)
+ device = kernel_string(@__disk_name(@choose_defined($cmd, $SCpnt)->request))
nr_sectors = get_nr_sectors(@choose_defined($cmd, $SCpnt)->request)
_cmd_flags = @choose_defined($cmd, $SCpnt)->request->cmd_flags
} else {
- device = kernel_string(@cast(scsi_cmd_to_rq(@choose_defined($cmd, $SCpnt)), "request", "kernel")->rq_disk->disk_name)
+ device = kernel_string(@__disk_name(@cast(scsi_cmd_to_rq(@choose_defined($cmd, $SCpnt)), "request", "kernel")))
nr_sectors = get_nr_sectors(scsi_cmd_to_rq(@choose_defined($cmd, $SCpnt)))
_cmd_flags = @cast(scsi_cmd_to_rq(@choose_defined($cmd, $SCpnt)), "request", "kernel")->cmd_flags
}

View File

@ -118,7 +118,7 @@ m stapdev stapdev
Name: systemtap
Version: 4.7
Release: 1%{?release_override}%{?dist}
Release: 2%{?release_override}%{?dist}
# for version, see also configure.ac
@ -154,6 +154,9 @@ License: GPLv2+
URL: http://sourceware.org/systemtap/
Source: ftp://sourceware.org/pub/systemtap/releases/systemtap-%{version}.tar.gz
Patch1: rhbz2081102.patch
Patch2: rhbz2085647.patch
# Build*
BuildRequires: make
BuildRequires: gcc-c++
@ -573,6 +576,8 @@ systemtap-runtime-virthost machine to execute systemtap scripts.
%prep
%setup -q
%patch1 -p1
%patch2 -p1
%build
@ -1275,6 +1280,9 @@ exit 0
# PRERELEASE
%changelog
* Tue May 17 2022 Martin Cermak <mcermak@redhat.com> - 4.1-2
- Fix rhbz2081102 and rhbz2085647
* Mon May 02 2022 Frank Ch. Eigler <fche@redhat.com> - 4.7-1
- Upstream release, see wiki page below for detailed notes.
https://sourceware.org/systemtap/wiki/SystemTapReleases