mlx5: add Corelens device and queue diagnostics - #218
Conversation
db52843 to
bcb5bb3
Compare
Add an mlx5 Corelens module for device, network, RDMA, queue, completion, event, and queue-pair state. Support summary, full, and JSON rendering, bounded descriptor dumps, compatibility helpers, selection policy, and filters. Add package integration, API documentation, and focused unit tests. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Remove unused device-selection state and the unused stored receive-WQ handle. Import drgn helpers guaranteed by the supported version and shorten repeated argument lists. Merge Corelens discovery into the module contract test and remove duplicate WQE coverage. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Remove repeated table walks, rebuilt QP indexes, one-use wrappers, and broad exception handling. Use direct drgn reads for stable fields and keep compatibility handling at known kernel layout differences. Simplify channel, CQ, EQ, QP, and descriptor collection. Use clearer names and keyword arguments where calls would otherwise be ambiguous. Remove mock-only tests while keeping focused behavior and output checks. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Retry the PR checks after the OL9 job failed before tests started due to a hosted runner container error. Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
brenns10
left a comment
There was a problem hiding this comment.
I have mainly started reading the ancillary modules: drgn_tools.mlx5_support.*. I jumped around within them and flagged a few issues, but I was finding that to be unhelpful for understanding the code. So I pivoted and started from the CorelensModule and followed the logic of device discovery.
From what I can see, this PR discovers mlx5 devices in three different ways: (1) by enumerating netdevs and finding ones that look like mlx5 devices, (2) by enumerating RDMA devices and finding mlx5 devices, and (3) by trying global variables that might look like a global list. I think we can make the third one work universally by using a global list. Here's a minimal example of what I mean:
from typing import Iterator
from drgn import cast, container_of, NULL, Object, Program
from drgn.helpers.linux.list import list_for_each_entry
from drgn.helpers.common.format import escape_ascii_string
from drgn_tools.table import Table
def mlx5_netdev(mdev: Object) -> Object:
"""
:param mdev: object of type ``struct mlx5_core_dev *``
:returns: the corresponding ``struct net_device *`` or NULL
"""
return mdev.mlx5e_res.uplink_netdev
def mlx5_core_ib_device(mdev: Object) -> Object:
"""
Return the primary RDMA device for the MLX5 device. This does not include
any special secondary devices.
:param mdev: object of type ``struct mlx5_core_dev *``
:returns: the corresponding ``struct ib_device *`` or NULL
"""
prog = mdev.prog_
MLX5_INTERFACE_PROTOCOL_IB = prog.constant("MLX5_INTERFACE_PROTOCOL_IB")
ib_adev = mdev.priv.adev[MLX5_INTERFACE_PROTOCOL_IB]
if not ib_adev:
return NULL(prog, "struct ib_device *")
mlx5_ib = cast("struct mlx5_ib_dev *", ib_adev.adev.dev.driver_data)
if not mlx5_ib:
return NULL(prog, "struct ib_device *")
return mlx5_ib.ib_dev.address_of_()
def for_each_mlx5_core_dev(prog: Program) -> Iterator[Object]:
"""
Iterate over all MLX5 devices on the system.
:returns: an iterator of ``struct mlx5_core_dev *``
"""
mlx5_driver = prog["mlx5_core_driver"]
for knode in list_for_each_entry(
"struct klist_node",
mlx5_driver.driver.p.klist_devices.k_list.address_of_(),
"n_node",
):
dev_priv = container_of(
knode, "struct device_private", "knode_driver"
)
pdev = container_of(dev_priv.device, "struct pci_dev", "dev")
yield cast("struct mlx5_core_dev *", pdev.dev.driver_data)
def mlx5_report(prog: Program) -> None:
table = Table(["MLX5_CORE_DEV", "NETDEV", "RDMA_DEV"])
for mdev in for_each_mlx5_core_dev(prog):
netdev = mlx5_netdev(mdev)
netdev_name = escape_ascii_string(netdev.name.string_()) if netdev else "-"
ibdev = mlx5_core_ib_device(mdev)
ibdev_name = escape_ascii_string(ibdev.name.string_()) if ibdev else "-"
table.row(hex(mdev), netdev_name, ibdev_name)
table.write()
if __name__ == "__main__":
mlx5_report(prog)Use drgn_tools.irq.irq_to_desc() instead of an optional drgn compatibility import. Let IRQ lookup and affinity errors surface instead of treating them as missing data. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Use the standard netdev helper and identify mlx5 devices from netdev_ops. Walk RDMA device lists directly and let unexpected kernel structure changes raise errors instead of silently returning incomplete data. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Treat queue and descriptor identifiers as typed internal report data instead of suppressing invalid values during selection and rendering. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Walk the mlx5 PCI and SF driver device lists as the authoritative source of core devices. Derive the uplink netdev and primary RDMA device through their direct kernel relationships. Remove netdev and RDMA registry scans, guessed device-list symbols, driver-name heuristics, fallback device records, and nullable core-device handling. Add vmcore coverage for the driver-owned relationships. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Move device collection directly into Mlx5Collector instead of using a single-use mixin. Replace untyped device dictionaries with a DeviceRecord class whose mlx5_core_dev is required. Keep low-level mlx5 object helpers in collect_device and convert records to report dictionaries only at the output boundary. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Remove hard-coded mlx5 and RDMA enum tables. Resolve device states, queue flags, descriptor values, event types, and QP values from the loaded program's enum definitions. Use program constants for semantic comparisons and cache enum tables used during descriptor decoding. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Use the mlx5 driver's canonical channel, queue, and CQ fields instead of probing lists of possible member paths. Select XDP, XSK, and PTP queues from driver state and use kernel constants for receive queue layout. Remove unused compatibility helpers and add vmcore coverage for the direct device-to-channel relationships. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Remove the device discovery smoke test, static module metadata assertions, and the test which expects malformed descriptors to be silently accepted. Keep the suite focused on concrete collection, decoding, selection, and rendering behavior. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Use mdev addresses for internal correlation and keep netdev and RDMA labels separate. Remove low-value mlx5 tests. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Remove the generic walk-limit machinery and use kernel-defined channel and QoS queue bounds. Remove unused compatibility and ring helpers. Keep IPv4 and IPv6 collection statically typed. Orabug: 39751588 Signed-off-by: Aryamann Sherora <aryamann.sherora@oracle.com>
Use required CQ, EQ, and QP identities directly. Remove unreachable QP creator reporting and small wrappers that no longer provide useful behavior. Orabug: 39751588 Signed-off-by: Aryamann Sherora <aryamann.sherora@oracle.com>
Limit device collection to devices bound to mlx5_core_driver. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Avoid truth-testing embedded mlx5_ib_wq structures and ignore sentinel or unreadable GSI WR-ID pointers during CQE annotation. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Count canonical mlx5_ib QP list nodes directly and skip temporary device counts that summary collection immediately replaces. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Use canonical UEK mlx5 device, queue, EQ, CQ, QP, and fragment-buffer layouts. Remove repeated walks and compatibility fallbacks, cache repeated metadata, and keep summary and full counts aligned. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Prefer the cached RDMA firmware version and treat unreadable mlx5 initialization-segment MMIO as unavailable instead of aborting vmcore reports. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Keep focused checks for descriptor decoding, CQ ownership, fragmented RDMA rings, WR-ID mapping, and unavailable firmware MMIO. Remove fake-heavy orchestration tests and their custom unittest adapter. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Move the safe-access helpers into their only caller and remove the unnecessary compatibility module. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Run selection, validation, collection, and rendering directly from Mlx5.run(). Remove the unused programmatic report wrappers. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Remove the Device details section and stop collecting capability, mlx5e_priv, and other device fields that no remaining report consumes. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Store mlx5 IB and uplink netdev objects directly on each device record. Share queue discovery between summary and detailed collection and avoid repeated work queue reads. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Collect EQs before CQs and use mlx5_core_cq.eq instead of matching vectors and IRQs after collection. Remove redundant CQ, EQ, and channel metadata and the extra linkage walk. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Avoid the post-collection object count walk and collect only WQ fields used by reports and dumps. Remove duplicate queue and QP metadata while keeping selectors, findings, and rendered output unchanged. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
| raise FaultError("test memory fault", address) | ||
|
|
||
|
|
||
| class TestMlx5(unittest.TestCase): |
There was a problem hiding this comment.
I don't have any specific issue with the unit tests below. But the most important tests we want are:
- mlx5 smoke test that runs on any vmcore (skip live kernels), and if the mlx5_core module is loaded, it runs the mlx5 report and prints it to stdout. This just verifies that the report does not crash.
- For specific vmcores we can record a known good output and commit it to a file in git, then assert that the output matches.
…terators for cq, eq, qps
Remove EQE columns and decoding for event-specific fields which are not present in the available vmcore coverage. Keep completion queue and error syndrome decoding unchanged. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Remove the EQE subtype column and decoding. It remained zero and was hidden for every EQE across the available CTF and DWARF vmcores. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Remove WR-ID correlation and descriptor fields not exercised by the available CTF and DWARF vmcores. Avoid the QP walk for CQE-only reports while retaining the QPN decoded directly from each CQE. Orabug: 39751588 Signed-off-by: Aryamann Sheoran <aryamann.sheoran@oracle.com>
Summary
Testing
Orabug: 39751588