[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <7bd211f1-e970-0ad2-8346-69849f0347c4@kernel.org>
Date: Wed, 16 Nov 2022 17:05:46 -0700
From: David Ahern <dsahern@...nel.org>
To: Eric Dumazet <edumazet@...gle.com>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: netdev@...r.kernel.org, eric.dumazet@...il.com
Subject: Re: [PATCH net-next 2/6] ipv6: fib6_new_sernum() optimization
On 11/15/22 2:10 AM, Eric Dumazet wrote:
> Adopt atomic_try_cmpxchg() which is slightly more efficient.
>
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> Cc: David Ahern <dsahern@...nel.org>
> ---
> net/ipv6/ip6_fib.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
> index 413f66781e50de62d6b20042d84798e7da59165a..2438da5ff6da810d9f612fc66df4d28510f50f10 100644
> --- a/net/ipv6/ip6_fib.c
> +++ b/net/ipv6/ip6_fib.c
> @@ -91,13 +91,12 @@ static void fib6_walker_unlink(struct net *net, struct fib6_walker *w)
>
> static int fib6_new_sernum(struct net *net)
> {
> - int new, old;
> + int new, old = atomic_read(&net->ipv6.fib6_sernum);
>
> do {
> - old = atomic_read(&net->ipv6.fib6_sernum);
> new = old < INT_MAX ? old + 1 : 1;
> - } while (atomic_cmpxchg(&net->ipv6.fib6_sernum,
> - old, new) != old);
> + } while (!atomic_try_cmpxchg(&net->ipv6.fib6_sernum, &old, new));
> +
> return new;
> }
>
Reviewed-by: David Ahern <dsahern@...nel.org>
Powered by blists - more mailing lists