linux-stable/net/core
Xiaoyan Li 593ef60c74 net-zerocopy: Reduce compound page head access
When compound pages are enabled, although the mm layer still
returns an array of page pointers, a subset (or all) of them
may have the same page head since a max 180kb skb can span 2
hugepages if it is on the boundary, be a mix of pages and 1 hugepage,
or fit completely in a hugepage. Instead of referencing page head
on all page pointers, use page length arithmetic to only call page
head when referencing a known different page head to avoid touching
a cold cacheline.

Tested:
See next patch with changes to tcp_mmap

Correntess:
On a pair of separate hosts as send with MSG_ZEROCOPY will
force a copy on tx if using loopback alone, check that the SHA
on the message sent is equivalent to checksum on the message received,
since the current program already checks for the length.

echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
./tcp_mmap -s -z
./tcp_mmap -H $DADDR -z

SHA256 is correct
received 2 MB (100 % mmap'ed) in 0.005914 s, 2.83686 Gbit
  cpu usage user:0.001984 sys:0.000963, 1473.5 usec per MB, 10 c-switches

Performance:
Run neper between adjacent hosts with the same config
tcp_stream -Z --skip-rx-copy -6 -T 20 -F 1000 --stime-use-proc --test-length=30

Before patch: stime_end=37.670000
After patch: stime_end=30.310000

Signed-off-by: Coco Li <lixiaoyan@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20230321081202.2370275-1-lixiaoyan@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2023-03-22 15:34:31 +01:00
..
bpf_sk_storage.c bpf, net: bpf_local_storage memory usage 2023-03-07 09:33:43 -08:00
datagram.c net-zerocopy: Reduce compound page head access 2023-03-22 15:34:31 +01:00
dev.c net: remove enum skb_free_reason 2023-03-07 23:57:19 -08:00
dev.h net-sysctl: factor-out rpm mask manipulation helpers 2023-02-09 17:45:55 -08:00
dev_addr_lists.c
dev_addr_lists_test.c kunit: Use KUNIT_EXPECT_MEMEQ macro 2022-10-27 02:40:14 -06:00
dev_ioctl.c net: dev: Convert sa_data to flexible array in struct sockaddr 2022-10-25 11:44:20 -07:00
drop_monitor.c genetlink: introduce split op representation 2022-11-07 12:30:16 +00:00
dst.c ipv6: remove max_size check inline with ipv4 2023-01-13 20:59:14 -08:00
dst_cache.c
failover.c net: failover: use IFF_NO_ADDRCONF flag to prevent ipv6 addrconf 2022-12-12 15:18:25 -08:00
fib_notifier.c
fib_rules.c
filter.c neighbour: switch to standard rcu, instead of rcu_bh 2023-03-21 21:32:18 -07:00
flow_dissector.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-11-29 13:04:52 -08:00
flow_offload.c net: flow_offload: add support for ARP frame matching 2022-11-14 11:24:16 +00:00
gen_estimator.c treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
gen_stats.c net: Remove the obsolte u64_stats_fetch_*_irq() users (net). 2022-10-28 20:13:54 -07:00
gro.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-02-02 14:49:55 -08:00
gro_cells.c net: drop the weight argument from netif_napi_add 2022-09-28 18:57:14 -07:00
hwbm.c
link_watch.c net: linkwatch: only report IF_OPER_LOWERLAYERDOWN if iflink is actually down 2022-11-16 09:45:00 +00:00
lwt_bpf.c
lwtunnel.c xfrm: lwtunnel: squelch kernel warning in case XFRM encap type is not available 2022-10-12 10:45:51 +02:00
Makefile netdev-genl: create a simple family for netdev stuff 2023-02-02 20:48:23 -08:00
neighbour.c neighbour: switch to standard rcu, instead of rcu_bh 2023-03-21 21:32:18 -07:00
net-procfs.c net-sysfs: display two backlog queue len separately 2023-03-22 12:03:52 +01:00
net-sysfs.c net: make default_rps_mask a per netns attribute 2023-02-20 11:22:54 +00:00
net-sysfs.h
net-traces.c net: bridge: Add a tracepoint for MDB overflows 2023-02-06 08:48:25 +00:00
net_namespace.c net: initialize net->notrefcnt_tracker earlier 2023-02-09 22:49:25 -08:00
netclassid_cgroup.c core: Variable type completion 2022-08-31 09:40:34 +01:00
netdev-genl-gen.c tools: ynl: skip the explicit op array size when not needed 2023-03-21 21:45:31 -07:00
netdev-genl-gen.h ynl: broaden the license even more 2023-03-16 21:20:32 -07:00
netdev-genl.c netdev-genl: create a simple family for netdev stuff 2023-02-02 20:48:23 -08:00
netevent.c
netpoll.c netpoll: Remove 4s sleep during carrier detection 2023-01-27 23:24:07 -08:00
netprio_cgroup.c
of_net.c of: net: export of_get_mac_address_nvmem() 2022-11-29 10:45:53 +01:00
page_pool.c net: page_pool: use in_softirq() instead 2023-02-06 09:15:22 +00:00
pktgen.c treewide: use get_random_u32_inclusive() when possible 2022-11-18 02:18:02 +01:00
ptp_classifier.c
request_sock.c
rtnetlink.c rtnetlink: bridge: mcast: Relax group address validation in common code 2023-03-17 08:05:49 +00:00
scm.c scm: add user copy checks to put_cmsg() 2023-02-20 11:39:59 +00:00
secure_seq.c tcp: Fix data-races around sysctl knobs related to SYN option. 2022-07-20 10:14:49 +01:00
selftests.c
skbuff.c skbuff: Add likely to skb pointer in build_skb() 2023-03-10 16:49:21 -08:00
skmsg.c net/sock: Introduce trace_sk_data_ready() 2023-01-23 11:26:50 +00:00
sock.c net: use indirect calls helpers for sk_exit_memory_pressure() 2023-03-02 11:35:06 +01:00
sock_destructor.h
sock_diag.c net: fix __sock_gen_cookie() 2022-11-21 20:36:30 -08:00
sock_map.c bpf, net: sock_map memory usage 2023-03-07 09:33:43 -08:00
sock_reuseport.c soreuseport: Fix socket selection for SO_INCOMING_CPU. 2022-10-25 11:35:16 +02:00
stream.c net: Remove WARN_ON_ONCE(sk->sk_forward_alloc) from sk_stream_kill_queues(). 2023-02-10 19:53:42 -08:00
sysctl_net_core.c net: make default_rps_mask a per netns attribute 2023-02-20 11:22:54 +00:00
timestamping.c
tso.c net: tso: inline tso_count_descs() 2022-12-12 15:04:39 -08:00
utils.c net: core: inet[46]_pton strlen len types 2022-11-01 21:14:39 -07:00
xdp.c net: xdp: don't call notifiers during driver init 2023-03-16 21:33:08 -07:00