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

Conversation

marinav123
Copy link

@marinav123 marinav123 commented Jul 10, 2023

On some hosts, script could run for many minutes.
Reason : On host with many NICs, each interface is scanned unordered with all the GIDs.
Fix: Order the GID table, break from loop once empty GID is found. Explanation: GIDs are assigned in order, if GID is empty, it means all the following will be empty as well

@marinav123 marinav123 force-pushed the show_gids branch 2 times, most recently from 3775437 to 4768504 Compare July 11, 2023 21:14
On some hosts, script could run for many minutes.
Reason : On host with many NICs, each interface is scanned unordered
with all the GIDs.
Add:
1. Flag --slim - order the GID table, count number of empty GIDs,
break from loop once number of empty GIDs is larger than predefined MAX (2).
Explanation: GIDs are assigned in order, if GID is empty, it means all the following
GIDs will be empty as well.
Exception: if some GID index was freed and new GID was assigned, there might be holes.

2. Flag --dev - show_gids used to get device as an optional only argument.
As there is additional argument now, need dedicated option to allow several arguments.

3. Add help

Result:
By default - script will run as before - will scan all GIDs
--slim should be used for large scale to allow reasonable timed run.
@@ -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

#Break after predefined number of 0 GIDS found
#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.

Copy link

@MarkZhang81 MarkZhang81 left a comment

Choose a reason for hiding this comment

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

Need to support "-h" and "--help";

Add a usage() function to print usage;
Make sure the program exit with 0 when it succeeds, and non-0 when it fails. Can check with "echo $?". For example:

$ ./sbin/show_gids -m
DEV PORT INDEX GID IPv4 VER DEV // This line is not needed in this case
--- ---- ----- --- ------------ --- --- // same with this line
show_gids will print gids table for all RDMA devices
-d|--dev= Can choose specifci mlx devices
-s|--slim will break gid table scan after predefine max num-2 of zero GIDs
[markzhang@c-236-0-180-183 mlnx-tools]$ echo $?
1

For your reference the output could be:

$ show_gids -h
Show all gid entries.
Usage: show_gids [ OPTIONS ]
[-d, --dev=<rdma_dev>]: Show git entries of a specific rdma device
[-s, --slim]: Show git entries in a fast way: stop checking left gid entries when a 0 gid is encountered
[-h, --help]: Show help

On a unsupported parameter, e.g.:
$ show_gids -m
Unsupported parameter "-m".
Usage: show_gids [ OPTIONS ]
[-d, --dev=<rdma_dev>]: Show git entries of a specific rdma device
[-s, --slim]: Show git entries in a fast way: stop checking left gid entries when a 0 gid is encountered
[-h, --help]: Show help

@marinav123
Copy link
Author

I agree with the idea of more organizes parameters and help, but this change main goal was to reduce run time on large scale. The only reason I added these options was due to the fact that show_gids was assuming that only parameter can be device. As I had to change that, I added a bit more. I cannot guarantee I will have time for adding all you suggest, but I will try. If not - this part can be improved in separate commit by anyone :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants