[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220801124239.067573de@kernel.org>
Date: Mon, 1 Aug 2022 12:42:39 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Maxim Mikityanskiy <maximmi@...dia.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>,
Boris Pismenny <borisp@...dia.com>,
Saeed Mahameed <saeedm@...dia.com>,
Tariq Toukan <tariqt@...dia.com>,
John Fastabend <john.fastabend@...il.com>,
Gal Pressman <gal@...dia.com>, <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next] net/tls: Use RCU API to access tls_ctx->netdev
On Mon, 1 Aug 2022 11:00:53 +0300 Maxim Mikityanskiy wrote:
> @@ -1329,7 +1345,11 @@ static int tls_device_down(struct net_device *netdev)
>
> spin_lock_irqsave(&tls_device_lock, flags);
> list_for_each_entry_safe(ctx, tmp, &tls_device_list, list) {
> - if (ctx->netdev != netdev ||
> + struct net_device *ctx_netdev =
> + rcu_dereference_protected(ctx->netdev,
> + lockdep_is_held(&device_offload_lock));
> +
> + if (ctx_netdev != netdev ||
> !refcount_inc_not_zero(&ctx->refcount))
> continue;
For cases like this where we don't actually hold onto the object, just
take a peek at the address of it we can save a handful of LoC by using
rcu_access_pointer().
Powered by blists - more mailing lists