linux-stable/include
Jakub Kicinski 6025b9135f net: dqs: add NIC stall detector based on BQL
softnet_data->time_squeeze is sometimes used as a proxy for
host overload or indication of scheduling problems. In practice
this statistic is very noisy and has hard to grasp units -
e.g. is 10 squeezes a second to be expected, or high?

Delaying network (NAPI) processing leads to drops on NIC queues
but also RTT bloat, impacting pacing and CA decisions.
Stalls are a little hard to detect on the Rx side, because
there may simply have not been any packets received in given
period of time. Packet timestamps help a little bit, but
again we don't know if packets are stale because we're
not keeping up or because someone (*cough* cgroups)
disabled IRQs for a long time.

We can, however, use Tx as a proxy for Rx stalls. Most drivers
use combined Rx+Tx NAPIs so if Tx gets starved so will Rx.
On the Tx side we know exactly when packets get queued,
and completed, so there is no uncertainty.

This patch adds stall checks to BQL. Why BQL? Because
it's a convenient place to add such checks, already
called by most drivers, and it has copious free space
in its structures (this patch adds no extra cache
references or dirtying to the fast path).

The algorithm takes one parameter - max delay AKA stall
threshold and increments a counter whenever NAPI got delayed
for at least that amount of time. It also records the length
of the longest stall.

To be precise every time NAPI has not polled for at least
stall thrs we check if there were any Tx packets queued
between last NAPI run and now - stall_thrs/2.

Unlike the classic Tx watchdog this mechanism does not
ignore stalls caused by Tx being disabled, or loss of link.
I don't think the check is worth the complexity, and
stall is a stall, whether due to host overload, flow
control, link down... doesn't matter much to the application.

We have been running this detector in production at Meta
for 2 years, with the threshold of 8ms. It's the lowest
value where false positives become rare. There's still
a constant stream of reported stalls (especially without
the ksoftirqd deferral patches reverted), those who like
their stall metrics to be 0 may prefer higher value.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2024-03-08 10:23:26 +00:00
..
acpi IOMMU Updates for Linux v6.8 2024-01-18 15:16:57 -08:00
asm-generic RISC-V Patches for the 6.8 Merge Window, Part 4 2024-01-20 11:06:04 -08:00
clocksource
crypto
drm drm/bridge: aux-hpd: separate allocation and registration 2024-02-23 17:00:56 +02:00
dt-bindings dmaengine fixes for v6.8-rc1 2024-01-20 15:03:25 -08:00
keys
kunit
kvm
linux net: dqs: add NIC stall detector based on BQL 2024-03-08 10:23:26 +00:00
math-emu
media
memory
misc
net netdev: add queue stat for alloc failures 2024-03-07 21:13:26 -08:00
pcmcia
ras
rdma
rv
scsi scsi: core: Consult supported VPD page list prior to fetching page 2024-02-15 14:41:26 -05:00
soc - New Device Support 2024-01-17 15:21:21 -08:00
sound ASoC: soc-card: Fix missing locking in snd_soc_card_get_kcontrol() 2024-02-23 13:40:06 +00:00
target
trace net: dqs: add NIC stall detector based on BQL 2024-03-08 10:23:26 +00:00
uapi netdev: add queue stat for alloc failures 2024-03-07 21:13:26 -08:00
ufs
vdso
video
xen