Skip to content

Commit 3d97379

Browse files
edumazetdavem330
authored andcommitted
tcp: move sk_mark_napi_id() at the right place
sk_mark_napi_id() is used to record for a flow napi id of incoming packets for busypoll sake. We should do this only on established flows, not on listeners. This was 'working' by virtue of the socket cloning, but doing this on SYN packets in unecessary cache line dirtying. Even if we move sk_napi_id in the same cache line than sk_lock, we are working to make SYN processing lockless, so it is desirable to set sk_napi_id only for established flows. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2e1af7d commit 3d97379

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎net/ipv4/tcp_ipv4.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
14291429
struct dst_entry *dst = sk->sk_rx_dst;
14301430

14311431
sock_rps_save_rxhash(sk, skb);
1432+
sk_mark_napi_id(sk, skb);
14321433
if (dst) {
14331434
if (inet_sk(sk)->rx_dst_ifindex != skb->skb_iif ||
14341435
dst->ops->check(dst, 0) == NULL) {
@@ -1450,6 +1451,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
14501451

14511452
if (nsk != sk) {
14521453
sock_rps_save_rxhash(nsk, skb);
1454+
sk_mark_napi_id(sk, skb);
14531455
if (tcp_child_process(sk, nsk, skb)) {
14541456
rsk = nsk;
14551457
goto reset;
@@ -1661,7 +1663,6 @@ int tcp_v4_rcv(struct sk_buff *skb)
16611663
if (sk_filter(sk, skb))
16621664
goto discard_and_relse;
16631665

1664-
sk_mark_napi_id(sk, skb);
16651666
skb->dev = NULL;
16661667

16671668
bh_lock_sock_nested(sk);

‎net/ipv6/tcp_ipv6.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
12931293
struct dst_entry *dst = sk->sk_rx_dst;
12941294

12951295
sock_rps_save_rxhash(sk, skb);
1296+
sk_mark_napi_id(sk, skb);
12961297
if (dst) {
12971298
if (inet_sk(sk)->rx_dst_ifindex != skb->skb_iif ||
12981299
dst->ops->check(dst, np->rx_dst_cookie) == NULL) {
@@ -1322,6 +1323,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
13221323
*/
13231324
if (nsk != sk) {
13241325
sock_rps_save_rxhash(nsk, skb);
1326+
sk_mark_napi_id(sk, skb);
13251327
if (tcp_child_process(sk, nsk, skb))
13261328
goto reset;
13271329
if (opt_skb)
@@ -1454,7 +1456,6 @@ static int tcp_v6_rcv(struct sk_buff *skb)
14541456
if (sk_filter(sk, skb))
14551457
goto discard_and_relse;
14561458

1457-
sk_mark_napi_id(sk, skb);
14581459
skb->dev = NULL;
14591460

14601461
bh_lock_sock_nested(sk);

0 commit comments

Comments
 (0)