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

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
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -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;
}