netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next V2 0/6] net/mlx5: hw counters refactor
@ 2024-10-01 10:37 Tariq Toukan
  2024-10-01 10:37 ` [PATCH net-next V2 1/6] net/mlx5: hw counters: Make fc_stats & fc_pool private Tariq Toukan
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Tariq Toukan @ 2024-10-01 10:37 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
  Cc: netdev, Saeed Mahameed, Gal Pressman, Leon Romanovsky,
	Simon Horman, Tariq Toukan

This is a patchset re-post, see:
https://lore.kernel.org/netdev/20240815054656.2210494-7-tariqt@nvidia.com/T/

In this patchset, Cosmin refactors hw counters and solves perf scaling
issue. 

Series generated against:
commit c824deb1a897 ("cxgb4: clip_tbl: Fix spelling mistake "wont" -> "won't"")

HW counters are central to mlx5 driver operations. They are hardware
objects created and used alongside most steering operations, and queried
from a variety of places. Most counters are queried in bulk from a
periodic task in fs_counters.c.

Counter performance is important and as such, a variety of improvements
have been done over the years. Currently, counters are allocated from
pools, which are bulk allocated to amortize the cost of firmware
commands. Counters are managed through an IDR, a doubly linked list and
two atomic single linked lists. Adding/removing counters is a complex
dance between user contexts requesting it and the mlx5_fc_stats_work
task which does most of the work.

Under high load (e.g. from connection tracking flow insertion/deletion),
the counter code becomes a bottleneck, as seen on flame graphs. Whenever
a counter is deleted, it gets added to a list and the wq task is
scheduled to run immediately to actually delete it. This is done via
mod_delayed_work which uses an internal spinlock. In some tests, waiting
for this spinlock took up to 66% of all samples.

This series refactors the counter code to use a more straight-forward
approach, avoiding the mod_delayed_work problem and making the code
easier to understand. For that:

- patch #1 moves counters data structs to a more appropriate place.
- patch #2 simplifies the bulk query allocation scheme by using vmalloc.
- patch #3 replaces the IDR+3 lists with an xarray. This is the main
  patch of the series, solving the spinlock congestion issue.
- patch #4 removes an unnecessary cacheline alignment causing a lot of
  memory to be wasted.
- patches #5 and #6 are small cleanups enabled by the refactoring.

Regards,
Tariq

V2:
- no changes, re-posting.

Cosmin Ratiu (6):
  net/mlx5: hw counters: Make fc_stats & fc_pool private
  net/mlx5: hw counters: Use kvmalloc for bulk query buffer
  net/mlx5: hw counters: Replace IDR+lists with xarray
  net/mlx5: hw counters: Drop unneeded cacheline alignment
  net/mlx5: hw counters: Don't maintain a counter count
  net/mlx5: hw counters: Remove mlx5_fc_create_ex

 .../ethernet/mellanox/mlx5/core/en/tc_ct.c    |   2 +-
 .../ethernet/mellanox/mlx5/core/fs_counters.c | 387 +++++++-----------
 include/linux/mlx5/driver.h                   |  33 +-
 include/linux/mlx5/fs.h                       |   3 -
 4 files changed, 147 insertions(+), 278 deletions(-)

-- 
2.44.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-10-04 18:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-01 10:37 [PATCH net-next V2 0/6] net/mlx5: hw counters refactor Tariq Toukan
2024-10-01 10:37 ` [PATCH net-next V2 1/6] net/mlx5: hw counters: Make fc_stats & fc_pool private Tariq Toukan
2024-10-01 10:37 ` [PATCH net-next V2 2/6] net/mlx5: hw counters: Use kvmalloc for bulk query buffer Tariq Toukan
2024-10-01 10:37 ` [PATCH net-next V2 3/6] net/mlx5: hw counters: Replace IDR+lists with xarray Tariq Toukan
2024-10-04  8:58   ` Simon Horman
2024-10-04  9:32     ` Cosmin Ratiu
2024-10-04 10:34       ` Simon Horman
2024-10-01 10:37 ` [PATCH net-next V2 4/6] net/mlx5: hw counters: Drop unneeded cacheline alignment Tariq Toukan
2024-10-01 10:37 ` [PATCH net-next V2 5/6] net/mlx5: hw counters: Don't maintain a counter count Tariq Toukan
2024-10-01 10:37 ` [PATCH net-next V2 6/6] net/mlx5: hw counters: Remove mlx5_fc_create_ex Tariq Toukan
2024-10-04 18:50 ` [PATCH net-next V2 0/6] net/mlx5: hw counters refactor patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).