Thread (10 messages) 10 messages, 2 authors, 2021-01-15

Re: [PATCH bpf-next v8 1/3] bpf: remove extra lock_sock for TCP_ZEROCOPY_RECEIVE

From: Alexei Starovoitov <hidden>
Date: 2021-01-15 04:08:15
Also in: netdev

On Thu, Jan 14, 2021 at 8:05 PM Stanislav Fomichev [off-list ref] wrote:
On Thu, Jan 14, 2021 at 7:57 PM Alexei Starovoitov
[off-list ref] wrote:
quoted
On Thu, Jan 14, 2021 at 7:40 PM Stanislav Fomichev [off-list ref] wrote:
quoted
On Thu, Jan 14, 2021 at 7:27 PM Alexei Starovoitov
[off-list ref] wrote:
quoted
On Wed, Jan 13, 2021 at 1:33 PM Stanislav Fomichev [off-list ref] wrote:
quoted
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 <redacted>
Cc: Martin KaFai Lau <redacted>
Cc: Song Liu <redacted>
Cc: Eric Dumazet <edumazet@google.com>
Acked-by: Martin KaFai Lau <redacted>
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help