sch_cake: don't try to reallocate or unshare skb unconditionally
authorIlya Ponetayev <i.ponetaev@ndmsystems.com>
Thu, 25 Jun 2020 20:12:07 +0000 (22:12 +0200)
committerSasha Levin <sashal@kernel.org>
Tue, 30 Jun 2020 19:36:46 +0000 (15:36 -0400)
commitea2628dd586d23e1412baced76b519a2f1c66d1c
tree885d73b2fbebbf1b95bc46d840beb9abca8520f1
parent3c6208267218d4e04692c9af2501570eaec28e2a
sch_cake: don't try to reallocate or unshare skb unconditionally

[ Upstream commit 9208d2863ac689a563b92f2161d8d1e7127d0add ]

cake_handle_diffserv() tries to linearize mac and network header parts of
skb and to make it writable unconditionally. In some cases it leads to full
skb reallocation, which reduces throughput and increases CPU load. Some
measurements of IPv4 forward + NAPT on MIPS router with 580 MHz single-core
CPU was conducted. It appears that on kernel 4.9 skb_try_make_writable()
reallocates skb, if skb was allocated in ethernet driver via so-called
'build skb' method from page cache (it was discovered by strange increase
of kmalloc-2048 slab at first).

Obtain DSCP value via read-only skb_header_pointer() call, and leave
linearization only for DSCP bleaching or ECN CE setting. And, as an
additional optimisation, skip diffserv parsing entirely if it is not needed
by the current configuration.

Fixes: c87b4ecdbe8d ("sch_cake: Make sure we can write the IP header before changing DSCP bits")
Signed-off-by: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
[ fix a few style issues, reflow commit message ]
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sched/sch_cake.c