Skip to content

Commit

Permalink
net: do not read sk_drops if application does not care
Browse files Browse the repository at this point in the history
sk_drops can be an often written field, do not read it unless
application showed interest.

Note that sk_drops can be read via inet_diag, so applications
can avoid getting this info from every received packet.

In the future, 'reading' sk_drops might require folding per node or per
cpu fields, and thus become even more expensive than today.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Dec 8, 2016
1 parent c8c8b12 commit 3665f38
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,8 @@ struct sock_skb_cb {
static inline void
sock_skb_set_dropcount(const struct sock *sk, struct sk_buff *skb)
{
SOCK_SKB_CB(skb)->dropcount = atomic_read(&sk->sk_drops);
SOCK_SKB_CB(skb)->dropcount = sock_flag(sk, SOCK_RXQ_OVFL) ?
atomic_read(&sk->sk_drops) : 0;
}

static inline void sk_drops_add(struct sock *sk, const struct sk_buff *skb)
Expand Down

0 comments on commit 3665f38

Please sign in to comment.