Commit 30189806 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

ipv6: fib6_new_sernum() optimization

Adopt atomic_try_cmpxchg() which is slightly more efficient.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: David Ahern <dsahern@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 57fc05e8
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment