]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net/mlx5: hw counters: Don't maintain a counter count
authorCosmin Ratiu <cratiu@nvidia.com>
Tue, 1 Oct 2024 10:37:08 +0000 (13:37 +0300)
committerJakub Kicinski <kuba@kernel.org>
Fri, 4 Oct 2024 18:33:46 +0000 (11:33 -0700)
commit4a67ebf85f384853970c56099bfc3096f66c20ed
tree5c0d702a58c6fe4520e24953aff02de72876363b
parentd95f77f1196a9458f61a08faa0eb569cf6f03a84
net/mlx5: hw counters: Don't maintain a counter count

num_counters is only used for deciding whether to grow the bulk query
buffer, which is done once more counters than a small initial threshold
are present. After that, maintaining num_counters serves no purpose.

This commit replaces that with an actual xarray traversal to count the
counters. This appears expensive at first sight, but is only done when
the number of counters is less than the initial threshold (8) and only
once every sampling interval. Once the number of counters goes above the
threshold, the bulk query buffer is grown to max size and the xarray
traversal is never done again.

Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20241001103709.58127-6-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c