[PATCH 1/3] sbitmapq: Fix for sbitmap_queue without ws_active member
by Kazuhito Hagio
The sbitmap_queue.ws_active member was added by kernel commit 5d2ee7122c73
("sbitmap: optimize wakeup check") at Linux 5.0. Without the patch, on
earlier kernels the "sbitmapq" command fails with the following error:
crash> sbitmapq ffff8f1a3611cf10
sbitmapq: invalid structure member offset: sbitmap_queue_ws_active
FILE: sbitmap.c LINE: 393 FUNCTION: sbitmap_queue_context_load()
Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
---
sbitmap.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sbitmap.c b/sbitmap.c
index e8ebd62fe01c..37db21d15219 100644
--- a/sbitmap.c
+++ b/sbitmap.c
@@ -325,7 +325,8 @@ static void sbitmap_queue_show(const struct sbitmap_queue_context *sqc,
fprintf(fp, "wake_batch = %u\n", sqc->wake_batch);
fprintf(fp, "wake_index = %d\n", sqc->wake_index);
- fprintf(fp, "ws_active = %d\n", sqc->ws_active);
+ if (VALID_MEMBER(sbitmap_queue_ws_active)) /* 5.0 and later */
+ fprintf(fp, "ws_active = %d\n", sqc->ws_active);
sbq_wait_state_size = SIZE(sbq_wait_state);
wait_cnt_off = OFFSET(sbq_wait_state_wait_cnt);
@@ -380,7 +381,8 @@ static void sbitmap_queue_context_load(ulong addr, struct sbitmap_queue_context
sqc->wake_batch = UINT(sbitmap_queue_buf + OFFSET(sbitmap_queue_wake_batch));
sqc->wake_index = INT(sbitmap_queue_buf + OFFSET(sbitmap_queue_wake_index));
sqc->ws_addr = ULONG(sbitmap_queue_buf + OFFSET(sbitmap_queue_ws));
- sqc->ws_active = INT(sbitmap_queue_buf + OFFSET(sbitmap_queue_ws_active));
+ if (VALID_MEMBER(sbitmap_queue_ws_active))
+ sqc->ws_active = INT(sbitmap_queue_buf + OFFSET(sbitmap_queue_ws_active));
if (VALID_MEMBER(sbitmap_queue_round_robin))
sqc->round_robin = BOOL(sbitmap_queue_buf + OFFSET(sbitmap_queue_round_robin));
sqc->min_shallow_depth = UINT(sbitmap_queue_buf + OFFSET(sbitmap_queue_min_shallow_depth));
--
2.27.0
2 years, 6 months
[PATCH] Make "dev -d|-D" options use sbitmap on RHEL8
by HAGIO KAZUHITO(萩尾 一仁)
There have been some reports that the "dev -d|-D" options displayed
incorrect I/O stats due to racy blk_mq_ctx.rq_completed value.
To fix it, make the options use sbitmap to count I/O stats on RHEL8
and adjust to its blk_mq_tags structure.
Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
---
The patch tested ok with upstream 4.0 to 5.18 kernels and several
RHEL7 and RHEL8 ones.
dev.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/dev.c b/dev.c
index 0172c83ffaea..733e3a8a40cd 100644
--- a/dev.c
+++ b/dev.c
@@ -4339,6 +4339,10 @@ static void bt_for_each(ulong q, ulong tags, ulong sbq, uint reserved, uint nr_r
static void queue_for_each_hw_ctx(ulong q, ulong *hctx, uint cnt, struct diskio *dio)
{
uint i;
+ int bitmap_tags_is_ptr = 0;
+
+ if (MEMBER_TYPE("blk_mq_tags", "bitmap_tags") == TYPE_CODE_PTR)
+ bitmap_tags_is_ptr = 1;
for (i = 0; i < cnt; i++) {
ulong addr = 0, tags = 0;
@@ -4357,9 +4361,17 @@ static void queue_for_each_hw_ctx(ulong q, ulong *hctx, uint cnt, struct diskio
if (nr_reserved_tags) {
addr = tags + OFFSET(blk_mq_tags_breserved_tags);
+ if (bitmap_tags_is_ptr &&
+ !readmem(addr, KVADDR, &addr, sizeof(ulong),
+ "blk_mq_tags.bitmap_tags", RETURN_ON_ERROR))
+ break;
bt_for_each(q, tags, addr, 1, nr_reserved_tags, dio);
}
addr = tags + OFFSET(blk_mq_tags_bitmap_tags);
+ if (bitmap_tags_is_ptr &&
+ !readmem(addr, KVADDR, &addr, sizeof(ulong),
+ "blk_mq_tags.bitmap_tags", RETURN_ON_ERROR))
+ break;
bt_for_each(q, tags, addr, 0, nr_reserved_tags, dio);
}
}
@@ -4423,8 +4435,13 @@ get_mq_diskio(unsigned long q, unsigned long *mq_count)
unsigned long mctx_addr;
struct diskio tmp = {0};
- if (INVALID_MEMBER(blk_mq_ctx_rq_dispatched) ||
- INVALID_MEMBER(blk_mq_ctx_rq_completed)) {
+ /*
+ * Currently it does not support earlier sbitmap and blk-mq
+ * implementation e.g. RHEL7, so filter them out.
+ */
+ if (VALID_STRUCT(sbitmap) &&
+ VALID_MEMBER(sbitmap_word_cleared) &&
+ VALID_MEMBER(request_state)) {
get_mq_diskio_from_hw_queues(q, &tmp);
mq_count[0] = tmp.read;
mq_count[1] = tmp.write;
--
2.27.0
2 years, 6 months
[PATCH] Doc: update man page for the "bpf|sbitmapq" commands
by Lianbo Jiang
The "bpf|sbitmapq" commands information is missing in the man page
of the crash utility. Let's add it to the man page.
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
---
crash.8 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/crash.8 b/crash.8
index 1f3657b11e4c..e553a0b4adb3 100644
--- a/crash.8
+++ b/crash.8
@@ -584,6 +584,9 @@ creates a single-word alias for a command.
.I ascii
displays an ascii chart or translates a numeric value into its ascii components.
.TP
+.I bpf
+provides information on currently-loaded eBPF programs and maps.
+.TP
.I bt
displays a task's kernel-stack backtrace. If it is given the
.I \-a
@@ -706,6 +709,11 @@ number of seconds between each command execution.
.I runq
displays the tasks on the run queue.
.TP
+.I sbitmapq
+dumps the contents of the sbitmap_queue structure and the used
+bits in the bitmap. Also, it shows the dump of a structure array
+associated with the sbitmap_queue.
+.TP
.I search
searches a range of user or kernel memory space for given value.
.TP
--
2.31.1
2 years, 7 months
[PATCH v4 0/2] Get diskio statistics from the hw queues in blk-mq
by Lianbo Jiang
Currently, crash doesn't support to display disk I/O statistics
for blk-mq devices. The patchset will implement it by parsing
the bitmap, it includes two patches:
[1] [PATCH 1/2] Support for "dev -d|-D" options by parsing bitmap in
blk-mq layer
[2] [PATCH 2/2] Fix for "dev -d|-D" options to correctly display disk I/O
statistics on linux v5.18-rc1
Related kernel commits:
[1] commit 9a14d6ce4135 ("block: remove debugfs blk_mq_ctx
dispatched/merged/completed attributes")
[2] commit 4e5cc99e1e48 ("blk-mq: manage hctx map via xarray")
The patchset is tested on v5.17.0-rc8 and the latest kernel 5.18.0-rc4.
With the patchset:
crash> dev -d
MAJOR GENDISK NAME REQUEST_QUEUE TOTAL ASYNC SYNC
8 ffff93d2ca593400 sda ffff93d2c917b960 18 15 3
Changes since v3:
[1] rename the 'struct bt_iter_data' to 'struct mq_inflight'
[2] rename the 'struct bt_tags_iter_data' to 'struct bt_iter_data'
[3] rename the 'flags' to 'reserved'
[4] rename the 'bt_tags_for_each' to 'bt_for_each'
[5] rename the 'bt_tags_iter' to 'bt_iter'
[6] removed the 'if (!hctx || !dio)' from the queue_for_each_hw_ctx()
[7] removed the 'if (!IS_KVADDR(hctx[i]))' from the queue_for_each_hw_ctx()
[8] removed the local variable 'struct diskio tmp'
Lianbo Jiang (2):
Support for "dev -d|-D" options by parsing bitmap in blk-mq layer
Fix for "dev -d|-D" options to correctly display disk I/O statistics
on linux v5.18-rc1
defs.h | 12 +++
dev.c | 268 ++++++++++++++++++++++++++++++++++++++++++++++--------
symbols.c | 24 +++++
3 files changed, 265 insertions(+), 39 deletions(-)
--
2.20.1
2 years, 7 months
[PATCH v3 0/2] Get diskio statistics from the hw queues in blk-mq
by Lianbo Jiang
Currently, crash doesn't support to display disk I/O statistics
for blk-mq devices. The patchset will implement it by parsing
the bitmap, it includes two patches:
[1] [PATCH 1/2] Support for "dev -d|-D" options by parsing bitmap in
blk-mq layer
[2] [PATCH 2/2] Fix for "dev -d|-D" options to correctly display disk I/O
statistics on linux v5.18-rc1
Related kernel commits:
[1] commit <9a14d6ce4135> ("block: remove debugfs blk_mq_ctx
dispatched/merged/completed attributes")
[2] commit <4e5cc99e1e48> ("blk-mq: manage hctx map via xarray")
The patchset is tested on v5.17.0-rc8 and the latest kernel 5.18.0-rc4.
With the patchset:
crash> dev -d
MAJOR GENDISK NAME REQUEST_QUEUE TOTAL ASYNC SYNC
8 ffff93d2ca593400 sda ffff93d2c917b960 18 15 3
Changes since v2:
[1] Remove the static_rqs[] and sched_tags to exactly follow up the
kernel path
[2] Add checking if the status of rq is inflight
[3] Use TRUE/FALSE for readability
[4] Replace "if MEMBER_EXISTS()" with "if VALID_MEMBER"
[5] Align it with the colons
Lianbo Jiang (2):
Support for "dev -d|-D" options by parsing bitmap in blk-mq layer
Fix for "dev -d|-D" options to correctly display disk I/O statistics
on linux v5.18-rc1
defs.h | 12 +++
dev.c | 285 ++++++++++++++++++++++++++++++++++++++++++++++--------
symbols.c | 24 +++++
3 files changed, 282 insertions(+), 39 deletions(-)
--
2.20.1
2 years, 7 months