net: provide macros for commonly copied lockless queue stop/wake code
authorJakub Kicinski <kuba@kernel.org>
Fri, 7 Apr 2023 01:25:33 +0000 (18:25 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 11 Apr 2023 00:56:18 +0000 (17:56 -0700)
commitc91c46de6bbc1147ae5dfe046b87f5f3d6593215
tree991868725389937ee41fa504abdc098e5d4360e5
parent8336462539ae751cbf7d59822eb331602a69df99
net: provide macros for commonly copied lockless queue stop/wake code

A lot of drivers follow the same scheme to stop / start queues
without introducing locks between xmit and NAPI tx completions.
I'm guessing they all copy'n'paste each other's code.
The original code dates back all the way to e1000 and Linux 2.6.19.

Smaller drivers shy away from the scheme and introduce a lock
which may cause deadlocks in netpoll.

Provide macros which encapsulate the necessary logic.

The macros do not prevent false wake ups, the extra barrier
required to close that race is not worth it. See discussion in:
https://lore.kernel.org/all/c39312a2-4537-14b4-270c-9fe1fbb91e89@gmail.com/

Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Documentation/networking/driver.rst
include/linux/netdevice.h
include/net/netdev_queues.h [new file with mode: 0644]