From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, alexander.duyck@gmail.com,
Willem de Bruijn <willemb@google.com>
Subject: [PATCH net-next v2 04/11] udp: better wmem accounting on gso
Date: Thu, 26 Apr 2018 13:42:18 -0400 [thread overview]
Message-ID: <20180426174225.246388-5-willemdebruijn.kernel@gmail.com> (raw)
In-Reply-To: <20180426174225.246388-1-willemdebruijn.kernel@gmail.com>
From: Willem de Bruijn <willemb@google.com>
skb_segment by default transfers allocated wmem from the gso skb
to the tail of the segment list. This underreports real truesize
of the list, especially if the tail might be dropped.
Similar to tcp_gso_segment, update wmem_alloc with the aggregate
list truesize and make each segment responsible for its own
share by setting skb->destructor.
Clear gso_skb->destructor prior to calling skb_segment to skip
the default assignment to tail.
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
net/ipv4/udp_offload.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 6b09220ca407..d806529b9b3d 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -191,6 +191,8 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
netdev_features_t features,
unsigned int mss, __sum16 check)
{
+ struct sock *sk = gso_skb->sk;
+ unsigned int sum_truesize = 0;
struct sk_buff *segs, *seg;
unsigned int hdrlen;
struct udphdr *uh;
@@ -201,9 +203,15 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
hdrlen = gso_skb->data - skb_mac_header(gso_skb);
skb_pull(gso_skb, sizeof(*uh));
+ /* clear destructor to avoid skb_segment assigning it to tail */
+ WARN_ON_ONCE(gso_skb->destructor != sock_wfree);
+ gso_skb->destructor = NULL;
+
segs = skb_segment(gso_skb, features);
- if (unlikely(IS_ERR_OR_NULL(segs)))
+ if (unlikely(IS_ERR_OR_NULL(segs))) {
+ gso_skb->destructor = sock_wfree;
return segs;
+ }
for (seg = segs; seg; seg = seg->next) {
uh = udp_hdr(seg);
@@ -214,8 +222,14 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
if (!seg->next)
csum_replace2(&uh->check, htons(mss),
htons(seg->len - hdrlen - sizeof(*uh)));
+
+ seg->destructor = sock_wfree;
+ seg->sk = sk;
+ sum_truesize += seg->truesize;
}
+ refcount_add(sum_truesize - gso_skb->truesize, &sk->sk_wmem_alloc);
+
return segs;
}
--
2.17.0.484.g0c8726318c-goog
next prev parent reply other threads:[~2018-04-26 17:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-26 17:42 [PATCH net-next v2 00/11] udp gso Willem de Bruijn
2018-04-26 17:42 ` [PATCH net-next v2 01/11] udp: expose inet cork to udp Willem de Bruijn
2018-04-26 17:42 ` [PATCH net-next v2 02/11] udp: add udp gso Willem de Bruijn
2018-04-26 17:42 ` [PATCH net-next v2 03/11] udp: generate gso with UDP_SEGMENT Willem de Bruijn
2018-04-26 17:42 ` Willem de Bruijn [this message]
2018-04-26 17:42 ` [PATCH net-next v2 05/11] udp: paged allocation with gso Willem de Bruijn
2018-04-26 17:42 ` [PATCH net-next v2 06/11] udp: add gso segment cmsg Willem de Bruijn
2018-04-26 17:42 ` [PATCH net-next v2 07/11] udp: add gso support to virtual devices Willem de Bruijn
2018-04-26 17:42 ` [PATCH net-next v2 08/11] selftests: udp gso Willem de Bruijn
2018-04-26 17:42 ` [PATCH net-next v2 09/11] selftests: udp gso with connected sockets Willem de Bruijn
2018-04-26 17:42 ` [PATCH net-next v2 10/11] selftests: udp gso with corking Willem de Bruijn
2018-04-26 17:42 ` [PATCH net-next v2 11/11] selftests: udp gso benchmark Willem de Bruijn
2018-04-26 19:23 ` [PATCH net-next v2 00/11] udp gso David Miller
2018-04-26 19:46 ` Willem de Bruijn
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=20180426174225.246388-5-willemdebruijn.kernel@gmail.com \
--to=willemdebruijn.kernel@gmail.com \
--cc=alexander.duyck@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).