Skip to content

Commit

Permalink
block: show request_queue freeze status
Browse files Browse the repository at this point in the history
When request_queue is freezed, processes which start issuing io will be
blocked, add two new field to blockinfo dump, "Freeze Depth" will tell
how many queue freezing operations is going on and "Usage Counter"
represents those operations who own one ref count of the queue,
queue freezed succeed only when this counter drops to 0, so none zero
"Freeze Depth" with none zero "Usage Counter" means queue freezeing
operation is blocked by the "Usage Counter", the most common reason
for this is that there is in flight ios, check "Inflight I/Os" field.

Orabug: 37361260

Signed-off-by: Junxiao Bi <[email protected]>
  • Loading branch information
biger410 authored and brenns10 committed Dec 6, 2024
1 parent 10e68ea commit ecc99b0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
40 changes: 37 additions & 3 deletions drgn_tools/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from drgn_tools.corelens import CorelensModule
from drgn_tools.table import print_table
from drgn_tools.util import has_member
from drgn_tools.util import percpu_ref_sum
from drgn_tools.util import timestamp_str
from drgn_tools.util import type_exists

Expand Down Expand Up @@ -631,18 +632,51 @@ def get_inflight_io_nr(prog: drgn.Program, disk: Object) -> int:
return int(nr)


def queue_freezed_depth(q: Object) -> int:
depth = q.mq_freeze_depth
if depth.type_.kind == TypeKind.INT:
return int(depth)
else:
return int(depth.counter)


def queue_usage_counter(q: Object) -> int:
return percpu_ref_sum(q.prog_, q.q_usage_counter)


def print_block_devs_info(prog: drgn.Program) -> None:
"""
Prints the block device information
"""
output = [["MAJOR", "GENDISK", "NAME", "REQUEST_QUEUE", "Inflight I/Os"]]
output = [
[
"MAJOR",
"GENDISK",
"NAME",
"REQUEST_QUEUE",
"Inflight I/Os",
"Freezed Depth",
"Usage Counter",
]
]
for disk in for_each_disk(prog):
q = disk.queue
major = int(disk.major)
gendisk = hex(disk.value_())
name = disk.disk_name.string_().decode("utf-8")
rq = hex(disk.queue.value_())
rq = hex(q.value_())
ios = get_inflight_io_nr(prog, disk)
output.append([str(major), gendisk, name, rq, str(ios)])
output.append(
[
str(major),
gendisk,
name,
rq,
str(ios),
str(queue_freezed_depth(q)),
str(queue_usage_counter(q)),
]
)
print_table(output)


Expand Down
4 changes: 2 additions & 2 deletions drgn_tools/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ def percpu_ref_sum(prog: Program, ref: Object) -> int:
PERCPU_COUNT_BIAS = 1 << (bits_per_long - 1)
counter = atomic_count.counter & ~PERCPU_COUNT_BIAS
if ptr & 0x3 != 0 or ptr == 0:
return counter
return int(counter)
percpu = Object(prog, "unsigned long", address=ptr)
for cpu in for_each_possible_cpu(prog):
counter += per_cpu(percpu, cpu).value_()
return counter
return int(counter)


def to_binary_units(num: t.Union[float, int], units: t.List[str]) -> str:
Expand Down

0 comments on commit ecc99b0

Please sign in to comment.