Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show_gids: Fix slow run on hosts with many interfaces #58

Open
wants to merge 1 commit into
base: mlnx_ofed
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions sbin/show_gids
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,46 @@ function print_gids()

echo -e "DEV\tPORT\tINDEX\tGID\t\t\t\t\tIPv4 \t\tVER\tDEV"
echo -e "---\t----\t-----\t---\t\t\t\t\t------------ \t---\t---"
DEVS=$1
#Break after predefined number of 0 GIDS found
Copy link

@MarkZhang81 MarkZhang81 Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space between "#" and comment:

# Break after...
# Assuming..
# Needed on host ..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

#Assuming that the rest will be zero as well
#Needed on hosst with large number of NICs, to avoid script slow run
MAX_NUM_OF_ZERO_GIDS=2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need this, istead of break on first zero gid?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per my experience with holes in git table, we have seen such issue recently. During ib_write_bw run if link is toggled, a hole will be created. Reasonable assumption is if there is a hole, most of the times it will be small, not in higher indexes. Thus the idea of scanning several more GIDs after the hole, it will not increase total time by much, but will account for most of the cases with holes.

IS_SLIM=0

while [ $# -gt 0 ]; do
case "$1" in
--dev=*)
DEVS="${1#*=}"
;;
--slim)
IS_SLIM=1
;;
*)
echo "show_gids will print gids table for all RDMA devices"
echo "-d|--dev=<rdma device> Can choose specifci mlx devices"
echo "-s|--slim will break gid table scan after predefine max num-2 of zero GIDs"
exit 1
esac
shift
done

if [ -z "$DEVS" ] ; then
DEVS=$(ls /sys/class/infiniband/)
fi

for d in $DEVS ; do
for p in $(ls /sys/class/infiniband/$d/ports/) ; do
for g in $(ls /sys/class/infiniband/$d/ports/$p/gids/) ; do
declare -i ZERO_GIDS_CNT
ZERO_GIDS_CNT=0
for g in $(ls -v /sys/class/infiniband/$d/ports/$p/gids/) ; do
gid=$(cat /sys/class/infiniband/$d/ports/$p/gids/$g);
if [ $gid = 0000:0000:0000:0000:0000:0000:0000:0000 ] ; then
if [ $IS_SLIM = 1 ] ; then
ZERO_GIDS_CNT+=1
if [ $ZERO_GIDS_CNT = $MAX_NUM_OF_ZERO_GIDS ] ; then
break
fi
fi
continue
fi
if [ $gid = fe80:0000:0000:0000:0000:0000:0000:0000 ] ; then
Expand Down