From: Jiong Wang <jiong.wang@netronome.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
Networking <netdev@vger.kernel.org>,
bpf@vger.kernel.org,
Jakub Kicinski <jakub.kicinski@netronome.com>,
"oss-drivers\@netronome.com" <oss-drivers@netronome.com>
Subject: Re: 32-bit zext JIT efficiency (Was Re: [PATCH bpf-next] selftests/bpf: two scale tests)
Date: Fri, 03 May 2019 18:12:02 +0100 [thread overview]
Message-ID: <871s1fsbrx.fsf@netronome.com> (raw)
In-Reply-To: <CAMsOgNDumbU7EWmOpwUoXdM5QWZ8h=W5nG3_JTFU5Tju-ofg_A@mail.gmail.com>
Jiong Wang writes:
>> > if you can craft a test that shows patch_insn issue before your set,
>> > then it's ok to hack bpf_fill_scale1 to use alu64.
>>
>> As described above, does the test_verifier 732 + jit blinding looks convincing?
>>
>> > I would also prefer to go with option 2 (new zext insn) for JITs.
>>
>> Got it.
>
> I followed option 2 and have sent out v5 with latests changes/fixes:
Had done second look at various back-ends, now noticed one new issue,
some arches are not consistent on implicit zext. For example, for s390,
alu32 move could be JITed using single instruction "llgfr" which will do
implicit zext, but alu32 move on PowerPC needs explicit zext. Then for
riscv, all BPF_ALU | BPF_K needs zext but not for some of BPF_ALU | BPF_X.
So, while these arches are generally better off after verifier zext
insertion enabled, but there do have unnecessary zext inserted by verifier
for them case by case.
Also, for 64-bit arches like PowerPC, S390 etc, they normally has zero
extended load, so narrowed load doesn't need extra zext insn, but for
32-bit arches like arm, narrowed load always need explicit zext.
All these differences are because of BPF_ALU32 or BPF_LDX + B | H | W
will be eventually mapped to diversified back-ends which do not have
consistent ISA semantics.
Given all these, looks like pass down the analysis info to back-ends
and let them do the decision become the choice again?
Regards,
Jiong
> The major changes are:
> - introduced BPF_ZEXT, even though it doesn't resolve insn patch in-efficient,
> but could let JIT back-ends do optimal code-gen, and the change is small,
> so perhap just better to support it in this set.
> - while look insn patch code, I feel patched-insn need to be conservatiely
> marked if any insn inside patch buffer define sub-register.
> - Also fixed helper function return value handling bug. I am thinking helper
> function should have accurate return value type description, otherwise
> there could be bug. For example arm32 back-end just executes the native
> helper functions and doesn't do anything special on the return value. So
> a function returns u32 would only set native reg r0, not r1 in the pair.
> Then if the outside eBPF insn is casting it into u64, there needs to be
> zext.
> - adjusted test_verifier to make sure it could pass on hosts w and w/o hw
> zext.
>
> For more info, please see the cover letter and patch description at v5.
>
> Thanks.
> Regards,
> Jiong
prev parent reply other threads:[~2019-05-03 17:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-12 21:41 [PATCH bpf-next] selftests/bpf: two scale tests Alexei Starovoitov
2019-04-12 23:24 ` Song Liu
2019-04-12 23:32 ` Alexei Starovoitov
2019-04-15 5:59 ` Song Liu
2019-04-16 8:30 ` Daniel Borkmann
2019-04-24 23:07 ` 32-bit zext time complexity (Was Re: [PATCH bpf-next] selftests/bpf: two scale tests) Jiong Wang
2019-04-25 4:33 ` Alexei Starovoitov
2019-04-25 7:25 ` Jiong Wang
2019-04-25 9:49 ` Jiong Wang
2019-04-25 22:10 ` Alexei Starovoitov
2019-04-26 13:06 ` Jiong Wang
2019-04-26 14:50 ` Edward Cree
2019-04-27 3:11 ` Alexei Starovoitov
2019-04-29 10:43 ` Edward Cree
2019-04-27 3:05 ` Alexei Starovoitov
2019-04-28 22:11 ` Jiong Wang
2019-05-01 14:59 ` Jiong Wang
2019-05-03 17:12 ` Jiong Wang [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=871s1fsbrx.fsf@netronome.com \
--to=jiong.wang@netronome.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jakub.kicinski@netronome.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).