2727from drgn import Program
2828from drgn .helpers .linux import for_each_online_cpu
2929from drgn .helpers .linux import per_cpu
30+ from drgn .helpers .linux import xa_for_each
3031from drgn .helpers .linux .list import hlist_for_each_entry
3132from drgn .helpers .linux .list import list_empty
3233from drgn .helpers .linux .list import list_for_each
3334from drgn .helpers .linux .list import list_for_each_entry
3435from drgn .helpers .linux .pid import find_task
35- from drgn . helpers . linux import xa_for_each
36+
3637from drgn_tools .corelens import CorelensModule
3738from drgn_tools .module import ensure_debuginfo
3839from drgn_tools .table import print_table
8687
8788# Helpers #
8889
90+
8991def be64_to_host (prog : drgn .Program , value : int ) -> int :
9092 """
9193 Convert 64 byte value from big endian to host order
@@ -570,7 +572,10 @@ def rds_dev_info(
570572 else :
571573 return None
572574
573- def rdma_resource_usage (prog : Program , outfile : Optional [str ] = None , report : bool = False ) -> None :
575+
576+ def rdma_resource_usage (
577+ prog : Program , outfile : Optional [str ] = None , report : bool = False
578+ ) -> None :
574579 """
575580 Print RDMA restrack resource usage counts for ALL mlx5_* devices, similar to 'rdma res show'
576581
@@ -582,7 +587,9 @@ def rdma_resource_usage(prog: Program, outfile: Optional[str] = None, report: bo
582587 data = [["Index" , "Device" , "PD" , "CQ" , "QP" , "CM_ID" , "MR" , "CTX" , "SRQ" ]]
583588 index = 0
584589 res_types_enum = prog .type ("enum rdma_restrack_type" )
585- for dev in list_for_each_entry ("struct device" , dev_kset .list .address_of_ (), "kobj.entry" ):
590+ for dev in list_for_each_entry (
591+ "struct device" , dev_kset .list .address_of_ (), "kobj.entry"
592+ ):
586593 try :
587594 name = dev .kobj .name .string_ ().decode ()
588595 ib_dev = container_of (dev , "struct ib_device" , "dev" )
@@ -591,33 +598,38 @@ def rdma_resource_usage(prog: Program, outfile: Optional[str] = None, report: bo
591598 continue
592599 counts = {}
593600 for name , i in res_types_enum .enumerators :
594- res_name = name [len ("RDMA_RESTRACK_" ):].lower ()
601+ res_name = name [len ("RDMA_RESTRACK_" ) :].lower ()
595602 try :
596603 xa = ib_dev .res [i ].xa
597- counts [res_name ] = sum (1 for _ in xa_for_each (xa .address_of_ ()))
604+ counts [res_name ] = sum (
605+ 1 for _ in xa_for_each (xa .address_of_ ())
606+ )
598607 except Exception :
599608 counts [res_name ] = - 1
600609
601610 def fmt (val ):
602611 return "NA" if val == - 1 else str (val )
603612
604- data .append ([
605- index ,
606- dev_name ,
607- fmt (counts ["pd" ]),
608- fmt (counts ["cq" ]),
609- fmt (counts ["qp" ]),
610- fmt (counts ["cm_id" ]),
611- fmt (counts ["mr" ]),
612- fmt (counts ["ctx" ]),
613- fmt (counts ["srq" ]),
614- ])
613+ data .append (
614+ [
615+ str (index ),
616+ dev_name ,
617+ fmt (counts ["pd" ]),
618+ fmt (counts ["cq" ]),
619+ fmt (counts ["qp" ]),
620+ fmt (counts ["cm_id" ]),
621+ fmt (counts ["mr" ]),
622+ fmt (counts ["ctx" ]),
623+ fmt (counts ["srq" ]),
624+ ]
625+ )
615626 index += 1
616627 except Exception :
617628 continue
618629
619630 print_table (data , outfile , report )
620631
632+
621633def rds_stats (
622634 prog : drgn .Program ,
623635 fields : Optional [str ] = None ,
@@ -1534,6 +1546,7 @@ def rds_print_msg_queue(
15341546 prog , laddr , raddr , tos , lport , rport , ret , outfile , report
15351547 )
15361548
1549+
15371550def print_mr_list_head_info (
15381551 prog : drgn .Program , list_head : Object , pool_name : str , list_name : str
15391552) -> None :
0 commit comments