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

udp: use atomic_inc_not_zero_hint

UDP sockets refcount is usually 2, unless an incoming frame is going to
be queued in receive or backlog queue.

Using atomic_inc_not_zero_hint() permits to reduce latency, because
processor issues less memory transactions.
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 213b15ca
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
#include <linux/rculist_nulls.h> #include <linux/rculist_nulls.h>
#include <linux/poll.h> #include <linux/poll.h>
#include <asm/atomic.h> #include <linux/atomic.h>
#include <net/dst.h> #include <net/dst.h>
#include <net/checksum.h> #include <net/checksum.h>
......
...@@ -430,7 +430,7 @@ static struct sock *udp4_lib_lookup2(struct net *net, ...@@ -430,7 +430,7 @@ static struct sock *udp4_lib_lookup2(struct net *net,
if (result) { if (result) {
exact_match: exact_match:
if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt))) if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
result = NULL; result = NULL;
else if (unlikely(compute_score2(result, net, saddr, sport, else if (unlikely(compute_score2(result, net, saddr, sport,
daddr, hnum, dif) < badness)) { daddr, hnum, dif) < badness)) {
...@@ -500,7 +500,7 @@ static struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, ...@@ -500,7 +500,7 @@ static struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr,
goto begin; goto begin;
if (result) { if (result) {
if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt))) if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
result = NULL; result = NULL;
else if (unlikely(compute_score(result, net, saddr, hnum, sport, else if (unlikely(compute_score(result, net, saddr, hnum, sport,
daddr, dport, dif) < badness)) { daddr, dport, dif) < badness)) {
......
...@@ -227,7 +227,7 @@ static struct sock *udp6_lib_lookup2(struct net *net, ...@@ -227,7 +227,7 @@ static struct sock *udp6_lib_lookup2(struct net *net,
if (result) { if (result) {
exact_match: exact_match:
if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt))) if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
result = NULL; result = NULL;
else if (unlikely(compute_score2(result, net, saddr, sport, else if (unlikely(compute_score2(result, net, saddr, sport,
daddr, hnum, dif) < badness)) { daddr, hnum, dif) < badness)) {
...@@ -294,7 +294,7 @@ static struct sock *__udp6_lib_lookup(struct net *net, ...@@ -294,7 +294,7 @@ static struct sock *__udp6_lib_lookup(struct net *net,
goto begin; goto begin;
if (result) { if (result) {
if (unlikely(!atomic_inc_not_zero(&result->sk_refcnt))) if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
result = NULL; result = NULL;
else if (unlikely(compute_score(result, net, hnum, saddr, sport, else if (unlikely(compute_score(result, net, hnum, saddr, sport,
daddr, dport, dif) < badness)) { daddr, dport, dif) < badness)) {
......
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