OSDN Git Service

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)
committerDavid S. Miller <davem@davemloft.net>
Thu, 25 Jun 2020 23:24:05 +0000 (16:24 -0700)
commit9208d2863ac689a563b92f2161d8d1e7127d0add
tree34ae27978c1e350b801b99aa7b81bf8238a62d06
parent1ae71d997a672739b22572cbe72d61a0eed8c42c
sch_cake: don't try to reallocate or unshare skb unconditionally

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>
net/sched/sch_cake.c