ipv6: fib6_new_sernum() optimization
Adopt atomic_try_cmpxchg() which is slightly more efficient. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
57fc05e8e8
commit
30189806fb
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user