From: John Fastabend <john.fastabend@gmail.com>
To: Andrii Nakryiko <andriin@fb.com>,
bpf@vger.kernel.org, netdev@vger.kernel.org, ast@fb.com,
daniel@iogearbox.net, john.fastabend@gmail.com
Cc: andrii.nakryiko@gmail.com, kernel-team@fb.com,
Andrii Nakryiko <andriin@fb.com>
Subject: RE: [PATCH v2 bpf-next 1/3] bpf: switch most helper return values from 32-bit int to 64-bit long
Date: Mon, 22 Jun 2020 19:18:28 -0700 [thread overview]
Message-ID: <5ef16674b315b_295f2ac8b51605b45d@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <20200623000905.3076979-1-andriin@fb.com>
Andrii Nakryiko wrote:
> Switch most of BPF helper definitions from returning int to long. These
> definitions are coming from comments in BPF UAPI header and are used to
> generate bpf_helper_defs.h (under libbpf) to be later included and used from
> BPF programs.
[...]
> There could be two variations with slightly different code generated: when len
> is 64-bit integer and when it is 32-bit integer. Both variations were analysed.
> BPF assembly instructions between two successive invocations of
> bpf_probe_read_kernel_str() were used to check code regressions. Results are
> below, followed by short analysis. Left side is using helpers with int return
> type, the right one is after the switch to long.
>
> ALU32 + INT ALU32 + LONG
> =========== ============
>
> 64-BIT (13 insns): 64-BIT (10 insns):
> ------------------------------------ ------------------------------------
> 17: call 115 17: call 115
> 18: if w0 > 256 goto +9 <LBB0_4> 18: if r0 > 256 goto +6 <LBB0_4>
> 19: w1 = w0 19: r1 = 0 ll
> 20: r1 <<= 32 21: *(u64 *)(r1 + 0) = r0
> 21: r1 s>>= 32 22: r6 = 0 ll
If you roll a v3 for Alexei's comment might be worth mentioning that
above <<=,s>> is a result of the >256 test if you do this as a more
standard <0 test the 'w1 = w0' assignment should be enough.
> 22: r2 = 0 ll 24: r6 += r0
> 24: *(u64 *)(r2 + 0) = r1 00000000000000c8 <LBB0_4>:
> 25: r6 = 0 ll 25: r1 = r6
> 27: r6 += r1 26: w2 = 256
> 00000000000000e0 <LBB0_4>: 27: r3 = 0 ll
> 28: r1 = r6 29: call 115
> 29: w2 = 256
> 30: r3 = 0 ll
> 32: call 115
>
Thanks,
John
prev parent reply other threads:[~2020-06-23 2:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 0:09 [PATCH v2 bpf-next 1/3] bpf: switch most helper return values from 32-bit int to 64-bit long Andrii Nakryiko
2020-06-23 0:09 ` [PATCH v2 bpf-next 2/3] selftests/bpf: add variable-length data concatenation pattern test Andrii Nakryiko
2020-06-23 0:09 ` [PATCH v2 bpf-next 3/3] selftests/bpf: add variable-length data concat pattern less than test Andrii Nakryiko
2020-06-23 0:31 ` Alexei Starovoitov
2020-06-23 2:28 ` Andrii Nakryiko
2020-06-23 2:18 ` John Fastabend [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5ef16674b315b_295f2ac8b51605b45d@john-XPS-13-9370.notmuch \
--to=john.fastabend@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.