From: Li RongQing <lirongqing@baidu.com>
To: netdev@vger.kernel.org
Subject: [PATCH][RFC] udp: cache sock to avoid searching it twice
Date: Fri, 9 Nov 2018 14:21:19 +0800 [thread overview]
Message-ID: <1541744479-12810-1-git-send-email-lirongqing@baidu.com> (raw)
GRO for UDP needs to lookup socket twice, first is in gro receive,
second is gro complete, so if store sock to skb to avoid looking up
twice, this can give small performance boost
netperf -t UDP_RR -l 10
Before:
Rate per sec: 28746.01
After:
Rate per sec: 29401.67
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
net/ipv4/udp_offload.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 0646d61f4fa8..429570112a33 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -408,6 +408,11 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb,
if (udp_sk(sk)->gro_enabled) {
pp = call_gro_receive(udp_gro_receive_segment, head, skb);
+
+ if (!IS_ERR(pp) && NAPI_GRO_CB(pp)->count > 1) {
+ sock_hold(sk);
+ pp->sk = sk;
+ }
rcu_read_unlock();
return pp;
}
@@ -444,6 +449,10 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb,
skb_gro_postpull_rcsum(skb, uh, sizeof(struct udphdr));
pp = call_gro_receive_sk(udp_sk(sk)->gro_receive, sk, head, skb);
+ if (!IS_ERR(pp) && NAPI_GRO_CB(pp)->count > 1) {
+ sock_hold(sk);
+ pp->sk = sk;
+ }
out_unlock:
rcu_read_unlock();
skb_gro_flush_final(skb, pp, flush);
@@ -502,7 +511,9 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff,
uh->len = newlen;
rcu_read_lock();
- sk = (*lookup)(skb, uh->source, uh->dest);
+ sk = skb->sk;
+ if (!sk)
+ sk = (*lookup)(skb, uh->source, uh->dest);
if (sk && udp_sk(sk)->gro_enabled) {
err = udp_gro_complete_segment(skb);
} else if (sk && udp_sk(sk)->gro_complete) {
@@ -516,6 +527,11 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff,
err = udp_sk(sk)->gro_complete(sk, skb,
nhoff + sizeof(struct udphdr));
}
+
+ if (skb->sk) {
+ sock_put(skb->sk);
+ skb->sk = NULL;
+ }
rcu_read_unlock();
if (skb->remcsum_offload)
--
2.16.2
next reply other threads:[~2018-11-09 16:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-09 6:21 Li RongQing [this message]
2018-11-09 13:41 ` [PATCH][RFC] udp: cache sock to avoid searching it twice Paolo Abeni
2018-11-12 5:46 ` 答复: " Li,Rongqing
2018-11-09 17:25 ` Eric Dumazet
2018-11-12 5:39 ` 答复: " Li,Rongqing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1541744479-12810-1-git-send-email-lirongqing@baidu.com \
--to=lirongqing@baidu.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.