diff options
author | Tariq Toukan <tariqt@nvidia.com> | 2022-07-27 12:43:41 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-07-28 21:50:54 -0700 |
commit | 113671b255ee3b9f5585a6d496ef0e675e698698 (patch) | |
tree | 792c7a6c73684c1e2bafc1dfefecd50f9fecb317 /net | |
parent | 8fd1e151779285b211e7184e9237bba69bd74386 (diff) | |
download | linux-stable-113671b255ee3b9f5585a6d496ef0e675e698698.tar.gz linux-stable-113671b255ee3b9f5585a6d496ef0e675e698698.tar.bz2 linux-stable-113671b255ee3b9f5585a6d496ef0e675e698698.zip |
net/tls: Perform immediate device ctx cleanup when possible
TLS context destructor can be run in atomic context. Cleanup operations
for device-offloaded contexts could require access and interaction with
the device callbacks, which might sleep. Hence, the cleanup of such
contexts must be deferred and completed inside an async work.
For all others, this is not necessary, as cleanup is atomic. Invoke
cleanup immediately for them, avoiding queueing redundant gc work.
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Maxim Mikityanskiy <maximmi@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/tls/tls_device.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index b3e2a30041c6..5150b3939b1f 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -96,19 +96,29 @@ static void tls_device_gc_task(struct work_struct *work) static void tls_device_queue_ctx_destruction(struct tls_context *ctx) { unsigned long flags; + bool async_cleanup; spin_lock_irqsave(&tls_device_lock, flags); - if (unlikely(!refcount_dec_and_test(&ctx->refcount))) - goto unlock; + if (unlikely(!refcount_dec_and_test(&ctx->refcount))) { + spin_unlock_irqrestore(&tls_device_lock, flags); + return; + } - list_move_tail(&ctx->list, &tls_device_gc_list); + async_cleanup = ctx->netdev && ctx->tx_conf == TLS_HW; + if (async_cleanup) { + list_move_tail(&ctx->list, &tls_device_gc_list); - /* schedule_work inside the spinlock - * to make sure tls_device_down waits for that work. - */ - schedule_work(&tls_device_gc_work); -unlock: + /* schedule_work inside the spinlock + * to make sure tls_device_down waits for that work. + */ + schedule_work(&tls_device_gc_work); + } else { + list_del(&ctx->list); + } spin_unlock_irqrestore(&tls_device_lock, flags); + + if (!async_cleanup) + tls_device_free_ctx(ctx); } /* We assume that the socket is already connected */ |