2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

dpif-netdev: Replace port mutex by rwlock.

The port mutex protects the netdev mapping, that can be changed by port
addition or port deletion. HW offloads operations can be considered read
operations on the port mapping itself. Use a rwlock to differentiate
between read and write operations, allowing concurrent queries and
offload insertions.

Because offload queries, deletion, and reconfigure_datapath() calls are
all rdlock, the deadlock fixed by [1] is still avoided, as the rdlock
side is recursive as prescribed by the POSIX standard. Executing
'reconfigure_datapath()' only requires a rdlock taken, but it is sometimes
executed in contexts where wrlock is taken ('do_add_port()' and
'do_del_port()').

This means that the deadlock described in [2] is still valid and should
be mitigated. The rdlock is taken using 'tryrdlock()' during offload query,
keeping the current behavior.

[1]: 81e89d5c26 ("dpif-netdev: Make datapath port mutex recursive.")

[2]: 12d0edd75e ("dpif-netdev: Avoid deadlock with offloading during PMD
     thread deletion.").

Signed-off-by: Gaetan Rivet <grive@u256.net>
Reviewed-by: Eli Britstein <elibr@nvidia.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
Gaetan Rivet
2021-09-08 11:47:49 +02:00
committed by Ilya Maximets
parent d85b9230ac
commit 7daa503468
2 changed files with 75 additions and 74 deletions

View File

@@ -47,8 +47,8 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(600, 600);
* For example, simultaneous call of 'netdev_reconfigure()' for the same
* 'netdev' is forbidden.
*
* For current implementation all above restrictions could be fulfilled by
* taking the datapath 'port_mutex' in lib/dpif-netdev.c. */
* For current implementation all above restrictions are fulfilled by
* read-locking the datapath 'port_rwlock' in lib/dpif-netdev.c. */
/*
* A mapping from ufid to dpdk rte_flow.