Skip to content

Commit 270acef

Browse files
Eric Dumazetdavem330
authored andcommitted
net: sk_free_datagram() should use sk_mem_reclaim_partial()
I noticed a contention on udp_memory_allocated on regular UDP applications. While tcp_memory_allocated is seldom used, it appears each incoming UDP frame is currently touching udp_memory_allocated when queued, and when received by application. One possible solution is to use sk_mem_reclaim_partial() instead of sk_mem_reclaim(), so that we keep a small reserve (less than one page) of memory for each UDP socket. We did something very similar on TCP side in commit 9993e7d ([TCP]: Do not purge sk_forward_alloc entirely in tcp_delack_timer()) A more complex solution would need to convert prot->memory_allocated to use a percpu_counter with batches of 64 or 128 pages. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d99a7bd commit 270acef

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

net/core/datagram.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
209209
void skb_free_datagram(struct sock *sk, struct sk_buff *skb)
210210
{
211211
kfree_skb(skb);
212-
sk_mem_reclaim(sk);
212+
sk_mem_reclaim_partial(sk);
213213
}
214214

215215
/**
@@ -248,8 +248,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
248248
spin_unlock_bh(&sk->sk_receive_queue.lock);
249249
}
250250

251-
kfree_skb(skb);
252-
sk_mem_reclaim(sk);
251+
skb_free_datagram(sk, skb);
253252
return err;
254253
}
255254

0 commit comments

Comments
 (0)