Thread View: linux.kernel.netdev
5 messages
5 total messages
Started by Eric Dumazet
Wed, 18 Nov 2026 22:47
[PATCH net-next] tls: wait for a single RCU grace period in tls_device_down()
Author: Eric Dumazet
Date: Wed, 18 Nov 2026 22:47
Date: Wed, 18 Nov 2026 22:47
64 lines
9739 bytes
9739 bytes
tls_device_down() calls synchronize_net() for each offloaded context
bound to the device going down. As this runs from the NETDEV_DOWN
notifier, a device with N offloaded sockets waits for N RCU grace
periods while RTNL is held.
Split the loop:
- First stop the offload for all contexts: switch to the software
fallback, clear ctx->netdev and set TLS_RX_DEV_DEGRADED.
- Then call synchronize_net() once, if there is at least one context.
- Finally release the driver state and drop the reference of each
context, as before.
The contexts are on a private list with a reference held, and the
first step only writes to fields of each context. The only change in
behavior is that all contexts stop being offloaded before the driver
state of the first one is released.
Compile tested only, with CONFIG_TLS_DEVICE=y.
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
---
net/tls/tls_device.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index 4cdfbb57ecff0a0ad5589fca4ab6599ab695c913..9c2f57312d14062f453d8b8e316404a3d1b20e0f 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -1349,7 +1349,7 @@ static int tls_device_down(struct net_device *netdev)
}
spin_unlock_irqrestore(&tls_device_lock, flags);
- list_for_each_entry_safe(ctx, tmp, &list, list) {
+ list_for_each_entry(ctx, &list, list) {
/* Stop offloaded TX and switch to the fallback.
* tls_is_skb_tx_device_offloaded will return false.
*/
@@ -1362,13 +1362,16 @@ static int tls_device_down(struct net_device *netdev)
/* Start skipping the RX resync logic completely. */
set_bit(TLS_RX_DEV_DEGRADED, &ctx->flags);
+ }
- /* Sync with inflight packets. After this point:
- * TX: no non-encrypted packets will be passed to the driver.
- * RX: resync requests from the driver will be ignored.
- */
+ /* Sync with inflight packets, once for all contexts. After this point:
+ * TX: no non-encrypted packets will be passed to the driver.
+ * RX: resync requests from the driver will be ignored.
+ */
+ if (!list_empty(&list))
synchronize_net();
+ list_for_each_entry_safe(ctx, tmp, &list, list) {
/* Release the offload context on the driver side. */
if (ctx->tx_conf == TLS_HW)
netdev->tlsdev_ops->tls_dev_del(netdev, ctx,
--
2.53.0
Re: [PATCH net-next] tls: wait for a single RCU grace period in tls_device_down()
Author: Jiayuan Chen
Date: Thu, 19 Nov 2026 04:08
Date: Thu, 19 Nov 2026 04:08
82 lines
11175 bytes
11175 bytes
On 11/19/26 6:47 AM, Eric Dumazet wrote:
> tls_device_down() calls synchronize_net() for each offloaded context
> bound to the device going down. As this runs from the NETDEV_DOWN
> notifier, a device with N offloaded sockets waits for N RCU grace
> periods while RTNL is held.
>
> Split the loop:
>
> - First stop the offload for all contexts: switch to the software
> fallback, clear ctx->netdev and set TLS_RX_DEV_DEGRADED.
>
> - Then call synchronize_net() once, if there is at least one context.
>
> - Finally release the driver state and drop the reference of each
> context, as before.
>
> The contexts are on a private list with a reference held, and the
> first step only writes to fields of each context. The only change in
> behavior is that all contexts stop being offloaded before the driver
> state of the first one is released.
>
> Compile tested only, with CONFIG_TLS_DEVICE=y.
I tested this with the netdevsim TLS offload emulation [1] (changed a little locally): N sockets with
TX and RX offloaded on one port, then "ip link set down" on it.
sockets  before  after
  100  12.7 ms  8.6 ms
  1000  39.1 ms  11.5 ms
  5000 160.8 ms  19.2 ms
 20000 577.2 ms  44.1 ms
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
[1] https://lore.kernel.org/netdev/20261117140642.4008-1-jiayuan.chen@linux.dev/
>
> Signed-off-by: Eric Dumazet <edumazet@kernel.org>
> ---
> net/tls/tls_device.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
> index 4cdfbb57ecff0a0ad5589fca4ab6599ab695c913..9c2f57312d14062f453d8b8e316404a3d1b20e0f 100644
> --- a/net/tls/tls_device.c
> +++ b/net/tls/tls_device.c
> @@ -1349,7 +1349,7 @@ static int tls_device_down(struct net_device *netdev)
> }
> spin_unlock_irqrestore(&tls_device_lock, flags);
>
> - list_for_each_entry_safe(ctx, tmp, &list, list) {
> + list_for_each_entry(ctx, &list, list) {
> /* Stop offloaded TX and switch to the fallback.
> * tls_is_skb_tx_device_offloaded will return false.
> */
> @@ -1362,13 +1362,16 @@ static int tls_device_down(struct net_device *netdev)
>
> /* Start skipping the RX resync logic completely. */
> set_bit(TLS_RX_DEV_DEGRADED, &ctx->flags);
> + }
>
> - /* Sync with inflight packets. After this point:
> - * TX: no non-encrypted packets will be passed to the driver.
> - * RX: resync requests from the driver will be ignored.
> - */
> + /* Sync with inflight packets, once for all contexts. After this point:
> + * TX: no non-encrypted packets will be passed to the driver.
> + * RX: resync requests from the driver will be ignored.
> + */
> + if (!list_empty(&list))
> synchronize_net();
>
> + list_for_each_entry_safe(ctx, tmp, &list, list) {
> /* Release the offload context on the driver side. */
> if (ctx->tx_conf == TLS_HW)
> netdev->tlsdev_ops->tls_dev_del(netdev, ctx,
Re: [PATCH net-next] tls: wait for a single RCU grace period in tls_device_down()
Author: Jakub Kicinski
Date: Sat, 21 Nov 2026 01:54
Date: Sat, 21 Nov 2026 01:54
9 lines
7983 bytes
7983 bytes
On Wed, 18 Nov 2026 23:47:58 +0100 Eric Dumazet wrote: > tls_device_down() calls synchronize_net() for each offloaded context > bound to the device going down. As this runs from the NETDEV_DOWN > notifier, a device with N offloaded sockets waits for N RCU grace > periods while RTNL is held. Looks like this needs a respin, conflicts with a fix that came in via net.
Re: [PATCH net-next] tls: wait for a single RCU grace period in tls_device_down()
Author: Eric Dumazet
Date: Mon, 23 Nov 2026 09:17
Date: Mon, 23 Nov 2026 09:17
49 lines
10387 bytes
10387 bytes
Le jeu. 19 nov. 2026 à 05:08, Jiayuan Chen <jiayuan.chen@linux.dev> a écrit : > > > On 11/19/26 6:47 AM, Eric Dumazet wrote: > > tls_device_down() calls synchronize_net() for each offloaded context > > bound to the device going down. As this runs from the NETDEV_DOWN > > notifier, a device with N offloaded sockets waits for N RCU grace > > periods while RTNL is held. > > > > Split the loop: > > > > - First stop the offload for all contexts: switch to the software > > fallback, clear ctx->netdev and set TLS_RX_DEV_DEGRADED. > > > > - Then call synchronize_net() once, if there is at least one context. > > > > - Finally release the driver state and drop the reference of each > > context, as before. > > > > The contexts are on a private list with a reference held, and the > > first step only writes to fields of each context. The only change in > > behavior is that all contexts stop being offloaded before the driver > > state of the first one is released. > > > > Compile tested only, with CONFIG_TLS_DEVICE=y. > > > > I tested this with the netdevsim TLS offload emulation [1] (changed a little locally): N sockets with > TX and RX offloaded on one port, then "ip link set down" on it. > Thanks for testing ! > sockets before after > 100 12.7 ms 8.6 ms > 1000 39.1 ms 11.5 ms > 5000 160.8 ms 19.2 ms > 20000 577.2 ms 44.1 ms > > > Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev> > > [1] https://lore.kernel.org/netdev/20261117140642.4008-1-jiayuan.chen@linux.dev/ >
Re: [PATCH net-next] tls: wait for a single RCU grace period in tls_device_down()
Author: Eric Dumazet
Date: Mon, 23 Nov 2026 09:23
Date: Mon, 23 Nov 2026 09:23
16 lines
9297 bytes
9297 bytes
Le sam. 21 nov. 2026 à 02:54, Jakub Kicinski <kuba@kernel.org> a écrit : > > On Wed, 18 Nov 2026 23:47:58 +0100 Eric Dumazet wrote: > > tls_device_down() calls synchronize_net() for each offloaded context > > bound to the device going down. As this runs from the NETDEV_DOWN > > notifier, a device with N offloaded sockets waits for N RCU grace > > periods while RTNL is held. > > Looks like this needs a respin, conflicts with a fix that came in via > net. Sure, I am adding Jiayuan Chen tests in v2. pw-bot: cr
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads