mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-28 14:44:10 +08:00
net: net_{enable|disable}_timestamp() optimizations
Adopting atomic_try_cmpxchg() makes the code cleaner. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
30189806fb
commit
6af645a5b2
@ -2073,13 +2073,10 @@ static DECLARE_WORK(netstamp_work, netstamp_clear);
|
||||
void net_enable_timestamp(void)
|
||||
{
|
||||
#ifdef CONFIG_JUMP_LABEL
|
||||
int wanted;
|
||||
int wanted = atomic_read(&netstamp_wanted);
|
||||
|
||||
while (1) {
|
||||
wanted = atomic_read(&netstamp_wanted);
|
||||
if (wanted <= 0)
|
||||
break;
|
||||
if (atomic_cmpxchg(&netstamp_wanted, wanted, wanted + 1) == wanted)
|
||||
while (wanted > 0) {
|
||||
if (atomic_try_cmpxchg(&netstamp_wanted, &wanted, wanted + 1))
|
||||
return;
|
||||
}
|
||||
atomic_inc(&netstamp_needed_deferred);
|
||||
@ -2093,13 +2090,10 @@ EXPORT_SYMBOL(net_enable_timestamp);
|
||||
void net_disable_timestamp(void)
|
||||
{
|
||||
#ifdef CONFIG_JUMP_LABEL
|
||||
int wanted;
|
||||
int wanted = atomic_read(&netstamp_wanted);
|
||||
|
||||
while (1) {
|
||||
wanted = atomic_read(&netstamp_wanted);
|
||||
if (wanted <= 1)
|
||||
break;
|
||||
if (atomic_cmpxchg(&netstamp_wanted, wanted, wanted - 1) == wanted)
|
||||
while (wanted > 1) {
|
||||
if (atomic_try_cmpxchg(&netstamp_wanted, &wanted, wanted - 1))
|
||||
return;
|
||||
}
|
||||
atomic_dec(&netstamp_needed_deferred);
|
||||
|
Loading…
Reference in New Issue
Block a user