On Thu, Jan 14, 2021 at 8:07 PM Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > On Thu, Jan 14, 2021 at 8:05 PM Stanislav Fomichev <sdf@xxxxxxxxxx> wrote: > > > > On Thu, Jan 14, 2021 at 7:57 PM Alexei Starovoitov > > <alexei.starovoitov@xxxxxxxxx> wrote: > > > > > > On Thu, Jan 14, 2021 at 7:40 PM Stanislav Fomichev <sdf@xxxxxxxxxx> wrote: > > > > > > > > On Thu, Jan 14, 2021 at 7:27 PM Alexei Starovoitov > > > > <alexei.starovoitov@xxxxxxxxx> wrote: > > > > > > > > > > On Wed, Jan 13, 2021 at 1:33 PM Stanislav Fomichev <sdf@xxxxxxxxxx> wrote: > > > > > > > > > > > > Add custom implementation of getsockopt hook for TCP_ZEROCOPY_RECEIVE. > > > > > > We skip generic hooks for TCP_ZEROCOPY_RECEIVE and have a custom > > > > > > call in do_tcp_getsockopt using the on-stack data. This removes > > > > > > 3% overhead for locking/unlocking the socket. > > > > > > > > > > > > Without this patch: > > > > > > 3.38% 0.07% tcp_mmap [kernel.kallsyms] [k] __cgroup_bpf_run_filter_getsockopt > > > > > > | > > > > > > --3.30%--__cgroup_bpf_run_filter_getsockopt > > > > > > | > > > > > > --0.81%--__kmalloc > > > > > > > > > > > > With the patch applied: > > > > > > 0.52% 0.12% tcp_mmap [kernel.kallsyms] [k] __cgroup_bpf_run_filter_getsockopt_kern > > > > > > > > > > > > Signed-off-by: Stanislav Fomichev <sdf@xxxxxxxxxx> > > > > > > Cc: Martin KaFai Lau <kafai@xxxxxx> > > > > > > Cc: Song Liu <songliubraving@xxxxxx> > > > > > > Cc: Eric Dumazet <edumazet@xxxxxxxxxx> > > > > > > Acked-by: Martin KaFai Lau <kafai@xxxxxx> > > > > > > > > > > Few issues in this patch and the patch 2 doesn't apply: > > > > > Switched to a new branch 'tmp' > > > > > Applying: bpf: Remove extra lock_sock for TCP_ZEROCOPY_RECEIVE > > > > > .git/rebase-apply/patch:295: trailing whitespace. > > > > > #endif > > > > > .git/rebase-apply/patch:306: trailing whitespace. > > > > > union tcp_word_hdr { > > > > > .git/rebase-apply/patch:309: trailing whitespace. > > > > > }; > > > > > .git/rebase-apply/patch:311: trailing whitespace. > > > > > #define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3]) > > > > > .git/rebase-apply/patch:313: trailing whitespace. > > > > > enum { > > > > > warning: squelched 1 whitespace error > > > > > warning: 6 lines add whitespace errors. > > > > > Applying: bpf: Try to avoid kzalloc in cgroup/{s,g}etsockopt > > > > > error: patch failed: kernel/bpf/cgroup.c:1390 > > > > > error: kernel/bpf/cgroup.c: patch does not apply > > > > > Patch failed at 0002 bpf: Try to avoid kzalloc in cgroup/{s,g}etsockopt > > > > Sorry, I mentioned in the cover letter that the series requires > > > > 4be34f3d0731 ("bpf: Don't leak memory in bpf getsockopt when optlen == 0") > > > > which is only in the bpf tree. No sure when bpf & bpf-next merge. > > > > Or are you trying to apply on top of that? > > > > > > hmm. It will take a while to wait for the trees to converge. > > > Ok. I've cherry-picked that bpf commit and applied 3 patches on top, > > > but the test failed to build: > > > > > > progs/sockopt_sk.c:60:47: error: use of undeclared identifier > > > 'TCP_ZEROCOPY_RECEIVE' > > > if (ctx->level == SOL_TCP && ctx->optname == TCP_ZEROCOPY_RECEIVE) { > > > ^ > > > progs/sockopt_sk.c:66:16: error: invalid application of 'sizeof' to an > > > incomplete type 'struct tcp_zerocopy_receive' > > > if (optval + sizeof(struct tcp_zerocopy_receive) > optval_end) > > > > > > Looks like copied uapi/tcp.h into tools/ wasn't in the include path. > > Interesting, let me try to understand where it comes on my system > > because it did work even without this uapi/tcp.h so I might > > have messed something up. Thank you! > > You probably have a newer glibc. Mine is old. I think our CI doesn't > use glibc and > is probably missing the newest tcp.h as well. Ah, it doesn't pick up my uapi/tcp.h because I include netinet/tcp.h in the test :-( Let me change that to linux/tcp.h and define SOL_TCP (because netinet/tcp.h used to provide it and linux/tcp.h isn't). I'll retest and resend tomorrow with a fresh head. Sorry for the noise.