mbox series

[net-next,v6,0/6] neighbour: Improve neigh_flush_dev performance

Message ID 20241021102102.2560279-1-gnaaman@drivenets.com (mailing list archive)
Headers show
Series neighbour: Improve neigh_flush_dev performance | expand

Message

Gilad Naaman Oct. 21, 2024, 10:20 a.m. UTC
This patchsets improves the performance of neigh_flush_dev.

Currently, the only way to implement it requires traversing
all neighbours known to the kernel, across all network-namespaces.

This means that some flows are slowed down as a function of neighbour-scale,
even if the specific link they're handling has little to no neighbours.

In order to solve this, this patchset adds a netdev->neighbours list,
as well as making the original linked-list doubly-, so that it is
possible to unlink neighbours without traversing the hash-bucket to
obtain the previous neighbour.

The original use-case we encountered was mass-deletion of links (12K
VLANs) while there are 50K ARPs and 50K NDPs in the system; though the
slowdowns would also appear when the links are set down.

Changes in v6:

 - Reverse changes to mellanox driver
 - Rename iteration macros to emphasize `in_bucket`
 - Remove now-unused variables and parameters

Gilad Naaman (6):
  neighbour: Add hlist_node to struct neighbour
  neighbour: Define neigh_for_each_in_bucket
  neighbour: Convert seq_file functions to use hlist
  neighbour: Convert iteration to use hlist+macro
  neighbour: Remove bare neighbour::next pointer
  neighbour: Create netdev->neighbour association

 .../networking/net_cachelines/net_device.rst  |   1 +
 include/linux/netdevice.h                     |   7 +
 include/net/neighbour.h                       |  24 +-
 include/net/neighbour_tables.h                |  12 +
 net/core/neighbour.c                          | 338 ++++++++----------
 net/ipv4/arp.c                                |   2 +-
 6 files changed, 175 insertions(+), 209 deletions(-)
 create mode 100644 include/net/neighbour_tables.h

Comments

Stanislav Fomichev Oct. 21, 2024, 6:04 p.m. UTC | #1
On 10/21, Gilad Naaman wrote:
> This patchsets improves the performance of neigh_flush_dev.
> 
> Currently, the only way to implement it requires traversing
> all neighbours known to the kernel, across all network-namespaces.
> 
> This means that some flows are slowed down as a function of neighbour-scale,
> even if the specific link they're handling has little to no neighbours.
> 
> In order to solve this, this patchset adds a netdev->neighbours list,
> as well as making the original linked-list doubly-, so that it is
> possible to unlink neighbours without traversing the hash-bucket to
> obtain the previous neighbour.
> 
> The original use-case we encountered was mass-deletion of links (12K
> VLANs) while there are 50K ARPs and 50K NDPs in the system; though the
> slowdowns would also appear when the links are set down.
> 
> Changes in v6:
> 
>  - Reverse changes to mellanox driver
>  - Rename iteration macros to emphasize `in_bucket`
>  - Remove now-unused variables and parameters
> 
> Gilad Naaman (6):
>   neighbour: Add hlist_node to struct neighbour
>   neighbour: Define neigh_for_each_in_bucket
>   neighbour: Convert seq_file functions to use hlist
>   neighbour: Convert iteration to use hlist+macro
>   neighbour: Remove bare neighbour::next pointer
>   neighbour: Create netdev->neighbour association
> 
>  .../networking/net_cachelines/net_device.rst  |   1 +
>  include/linux/netdevice.h                     |   7 +
>  include/net/neighbour.h                       |  24 +-
>  include/net/neighbour_tables.h                |  12 +
>  net/core/neighbour.c                          | 338 ++++++++----------
>  net/ipv4/arp.c                                |   2 +-
>  6 files changed, 175 insertions(+), 209 deletions(-)
>  create mode 100644 include/net/neighbour_tables.h

Seems like the series triggers a bunch of GPFs from
tools/testing/selftests/net/fib_tests.sh:

[  698.336499] Oops: general protection fault, probably for non-canonical address 0xdead000000000122: 0000 [#1] PREEMPT SMP NOPTI
...
[  698.336743] RIP: 0010:neigh_flush_dev.isra.0+0x5d/0x1a0
...
[  698.337531] Call Trace:
[  698.337560]  <TASK>
[  698.337586]  ? die_addr+0x37/0x90
[  698.337626]  ? exc_general_protection+0x1b7/0x3b0
[  698.337674]  ? asm_exc_general_protection+0x26/0x30
[  698.337721]  ? neigh_flush_dev.isra.0+0x5d/0x1a0
[  698.337760]  __neigh_ifdown.isra.0+0x33/0x120
[  698.337798]  neigh_ifdown+0x10/0x20
[  698.337827]  fib_netdev_event+0xa1/0x1a0
[  698.337868]  notifier_call_chain+0x5b/0xd0
[  698.337907]  dev_close_many+0xef/0x160
[  698.337946]  unregister_netdevice_many_notify+0x155/0x910
[  698.337990]  ? sock_def_readable+0x14/0xc0
[  698.338024]  ? __netlink_sendskb+0x64/0x90
[  698.338061]  rtnl_dellink+0x14d/0x3a0
[  698.338101]  ? rtnl_getlink+0x376/0x400
[  698.338139]  ? __rtnl_unlock+0x37/0x70
[  698.338170]  ? netdev_run_todo+0x64/0x550
[  698.338201]  rtnetlink_rcv_msg+0x15d/0x410
[  698.338234]  ? get_page_from_freelist+0xf04/0x10c0
[  698.338278]  ? __pfx_rtnetlink_rcv_msg+0x10/0x10
[  698.338315]  netlink_rcv_skb+0x58/0x110
[  698.338351]  netlink_unicast+0x247/0x370
[  698.338384]  netlink_sendmsg+0x1bf/0x3e0
[  698.338414]  ____sys_sendmsg+0x2bc/0x320

https://netdev.bots.linux.dev/contest.html?branch=net-next-2024-10-21--15-00&executor=vmksft-net&pw-n=0&pass=0

Can you please take a look?

---
pw-bot: cr
Gilad Naaman Oct. 22, 2024, 11:21 a.m. UTC | #2
> Seems like the series triggers a bunch of GPFs from
> tools/testing/selftests/net/fib_tests.sh:
> 
> <snip>
> 
> Can you please take a look?

Hey, 
thank you, it seems like I botched it when rebasing the patch.