BPF List
 help / color / mirror / Atom feed
From: dthaler1968@googlemail.com
To: "'Alexei Starovoitov'" <alexei.starovoitov@gmail.com>,
	"'Christoph Hellwig'" <hch@infradead.org>
Cc: "'David Vernet'" <void@manifault.com>, <bpf@ietf.org>,
	"'bpf'" <bpf@vger.kernel.org>,
	"'Jakub Kicinski'" <kuba@kernel.org>
Subject: RE: [Bpf] BPF ISA conformance groups
Date: Tue, 19 Dec 2023 10:10:07 -0800	[thread overview]
Message-ID: <09dc01da32a6$99c97e50$cd5c7af0$@gmail.com> (raw)
In-Reply-To: <CAADnVQ+ExRC_RavN_sbuOmuwyP6+HKnV9bFjJOseORBaVw0Jcg@mail.gmail.com>

> -----Original Message-----
> From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
> Sent: Monday, December 18, 2023 5:15 PM
> To: Christoph Hellwig <hch@infradead.org>
> Cc: David Vernet <void@manifault.com>; Dave Thaler
> <dthaler1968@googlemail.com>; bpf@ietf.org; bpf <bpf@vger.kernel.org>;
> Jakub Kicinski <kuba@kernel.org>
> Subject: Re: [Bpf] BPF ISA conformance groups
> 
> On Thu, Dec 14, 2023 at 9:29 PM Christoph Hellwig <hch@infradead.org>
> wrote:
> >
> > We need the concept in the spec just to allow future extensability.
> 
> Completely agree that the concept of the groups is necessary.
> 
> I'm arguing that what was proposed:
> 1. "basic": all instructions not covered by another group below.
> 2. "atomic": all Atomic operations.
> 3. "divide": all division and modulo operations.
> 4. "legacy": all legacy packet access instructions (deprecated).
> 5. "map": 64-bit immediate instructions that deal with map fds or map
> indices.
> 6. "code": 64-bit immediate instruction that has a "code pointer" type.
> 7. "func": program-local functions.
> 
> logically makes sense, but might not work for HW (based on the history of nfp
> offload).
> imo "basic" and "legacy" won't work either.
> So it's a lesser evil.
> 
> Anyway, let's look at:
> 
>    | BPF_CALL | 0x8   | 0x0 | call helper         | see Helper        |
>    |          |       |     | function by address | functions         |
>    |          |       |     |                     | (Section 3.3.1)   |
>    +----------+-------+-----+---------------------+-------------------+
>    | BPF_CALL | 0x8   | 0x1 | call PC += imm      | see Program-local |
>    |          |       |     |                     | functions         |
>    |          |       |     |                     | (Section 3.3.2)   |
>    +----------+-------+-----+---------------------+-------------------+
>    | BPF_CALL | 0x8   | 0x2 | call helper         | see Helper        |
>    |          |       |     | function by BTF ID  | functions         |
>    |          |       |     |                     | (Section 3.3.
> 
> Having separate category 7 for single insn BPF_CALL 0x8 0x1 while keeping 0x8
> 0x0 and 0x8 0x2 in "basic" seems just as logical as having atomic_add insn in
> "basic" instead of "atomic".

If a platform exposes no helper functions, then 0x8 0x0 and 0x8 0x2 have no
meaning and in my view don't need a separate conformance group since a
program using them would fail the verifier anyway.

0x8 0x1 on the other hand wouldn't be invalid just due to the imm value,
and so tools (compiler, verifier, whatever) need some other way to know whether
it's supported, hence the conformance group.

> Then we have several kinds of ld_imm64. Sounds like the idea is to split 0x18
> 0x4 into "code" and the rest into "map" group?
> Is it logical or not?

I don't know of another easy way for a tool like a compiler (LLVM, gcc, rust compiler,
etc.) to know whether map instructions are legal or not.  

That said, I think map_val() is problematic for a cross-platform compiler...
https://elixir.bootlin.com/linux/latest/source/Documentation/bpf/linux-notes.rst says
"Linux only supports the 'map_val(map)' operation on array maps with a single element."
Now if one platform supports it on one type of map and another platform doesn't, then
the compiler has to magically know whether to allow this optimization (compared to
requiring using a helper function to access the map value) or not.

> Maybe we should do risc-v like group instead?
> Just these 4:
> - Base Integer Instruction Set, 32-bit
> - Base Integer Instruction Set, 64-bit

If there's platforms that would support one of the above and not the other
(are there?) then I agree splitting them would make sense.

> - Integer Multiplication and Division
> - Atomic Instructions
> 
> And that's it. The rest of risc-v groups have no equivalent in bpf isa.

Dave


WARNING: multiple messages have this Message-ID (diff)
From: dthaler1968=40googlemail.com@dmarc.ietf.org
To: "'Alexei Starovoitov'" <alexei.starovoitov@gmail.com>,
	"'Christoph Hellwig'" <hch@infradead.org>
Cc: "'David Vernet'" <void@manifault.com>, <bpf@ietf.org>,
	"'bpf'" <bpf@vger.kernel.org>,
	"'Jakub Kicinski'" <kuba@kernel.org>
Subject: Re: [Bpf] BPF ISA conformance groups
Date: Tue, 19 Dec 2023 10:10:07 -0800	[thread overview]
Message-ID: <09dc01da32a6$99c97e50$cd5c7af0$@gmail.com> (raw)
Message-ID: <20231219181007.XJLVo_JoQ6Fwu6XUudEDRqhS4MWKQz8nJb0AHBsKY64@z> (raw)
In-Reply-To: <CAADnVQ+ExRC_RavN_sbuOmuwyP6+HKnV9bFjJOseORBaVw0Jcg@mail.gmail.com>

> -----Original Message-----
> From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
> Sent: Monday, December 18, 2023 5:15 PM
> To: Christoph Hellwig <hch@infradead.org>
> Cc: David Vernet <void@manifault.com>; Dave Thaler
> <dthaler1968@googlemail.com>; bpf@ietf.org; bpf <bpf@vger.kernel.org>;
> Jakub Kicinski <kuba@kernel.org>
> Subject: Re: [Bpf] BPF ISA conformance groups
> 
> On Thu, Dec 14, 2023 at 9:29 PM Christoph Hellwig <hch@infradead.org>
> wrote:
> >
> > We need the concept in the spec just to allow future extensability.
> 
> Completely agree that the concept of the groups is necessary.
> 
> I'm arguing that what was proposed:
> 1. "basic": all instructions not covered by another group below.
> 2. "atomic": all Atomic operations.
> 3. "divide": all division and modulo operations.
> 4. "legacy": all legacy packet access instructions (deprecated).
> 5. "map": 64-bit immediate instructions that deal with map fds or map
> indices.
> 6. "code": 64-bit immediate instruction that has a "code pointer" type.
> 7. "func": program-local functions.
> 
> logically makes sense, but might not work for HW (based on the history of nfp
> offload).
> imo "basic" and "legacy" won't work either.
> So it's a lesser evil.
> 
> Anyway, let's look at:
> 
>    | BPF_CALL | 0x8   | 0x0 | call helper         | see Helper        |
>    |          |       |     | function by address | functions         |
>    |          |       |     |                     | (Section 3.3.1)   |
>    +----------+-------+-----+---------------------+-------------------+
>    | BPF_CALL | 0x8   | 0x1 | call PC += imm      | see Program-local |
>    |          |       |     |                     | functions         |
>    |          |       |     |                     | (Section 3.3.2)   |
>    +----------+-------+-----+---------------------+-------------------+
>    | BPF_CALL | 0x8   | 0x2 | call helper         | see Helper        |
>    |          |       |     | function by BTF ID  | functions         |
>    |          |       |     |                     | (Section 3.3.
> 
> Having separate category 7 for single insn BPF_CALL 0x8 0x1 while keeping 0x8
> 0x0 and 0x8 0x2 in "basic" seems just as logical as having atomic_add insn in
> "basic" instead of "atomic".

If a platform exposes no helper functions, then 0x8 0x0 and 0x8 0x2 have no
meaning and in my view don't need a separate conformance group since a
program using them would fail the verifier anyway.

0x8 0x1 on the other hand wouldn't be invalid just due to the imm value,
and so tools (compiler, verifier, whatever) need some other way to know whether
it's supported, hence the conformance group.

> Then we have several kinds of ld_imm64. Sounds like the idea is to split 0x18
> 0x4 into "code" and the rest into "map" group?
> Is it logical or not?

I don't know of another easy way for a tool like a compiler (LLVM, gcc, rust compiler,
etc.) to know whether map instructions are legal or not.  

That said, I think map_val() is problematic for a cross-platform compiler...
https://elixir.bootlin.com/linux/latest/source/Documentation/bpf/linux-notes.rst says
"Linux only supports the 'map_val(map)' operation on array maps with a single element."
Now if one platform supports it on one type of map and another platform doesn't, then
the compiler has to magically know whether to allow this optimization (compared to
requiring using a helper function to access the map value) or not.

> Maybe we should do risc-v like group instead?
> Just these 4:
> - Base Integer Instruction Set, 32-bit
> - Base Integer Instruction Set, 64-bit

If there's platforms that would support one of the above and not the other
(are there?) then I agree splitting them would make sense.

> - Integer Multiplication and Division
> - Atomic Instructions
> 
> And that's it. The rest of risc-v groups have no equivalent in bpf isa.

Dave

-- 
Bpf mailing list
Bpf@ietf.org
https://www.ietf.org/mailman/listinfo/bpf

  parent reply	other threads:[~2023-12-19 18:10 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-27 20:18 IETF 118 BPF WG summary David Vernet
2023-11-27 20:18 ` [Bpf] " David Vernet
2023-11-28  9:43 ` Michael Richardson
2023-11-28  9:43   ` Michael Richardson
2023-12-02 19:51 ` BPF ISA conformance groups dthaler1968
2023-12-02 19:51   ` [Bpf] " dthaler1968=40googlemail.com
2023-12-07 21:51   ` David Vernet
2023-12-07 21:51     ` David Vernet
2023-12-10  3:10     ` Alexei Starovoitov
2023-12-10  3:10       ` Alexei Starovoitov
2023-12-10 21:13       ` Watson Ladd
2023-12-10 21:13         ` Watson Ladd
2023-12-12 21:45       ` David Vernet
2023-12-12 21:45         ` David Vernet
2023-12-12 22:01         ` dthaler1968
2023-12-12 22:01           ` dthaler1968=40googlemail.com
2023-12-12 22:55           ` Alexei Starovoitov
2023-12-12 22:55             ` Alexei Starovoitov
2023-12-12 23:35             ` David Vernet
2023-12-12 23:35               ` David Vernet
2023-12-13  1:32               ` Alexei Starovoitov
2023-12-13  1:32                 ` Alexei Starovoitov
2023-12-13 18:56                 ` David Vernet
2023-12-13 18:56                   ` David Vernet
2023-12-14  0:12                   ` Alexei Starovoitov
2023-12-14  0:12                     ` Alexei Starovoitov
2023-12-14 17:44                     ` David Vernet
2023-12-14 17:44                       ` David Vernet
2023-12-15  5:29                       ` Christoph Hellwig
2023-12-15  5:29                         ` Christoph Hellwig
2023-12-19  1:15                         ` Alexei Starovoitov
2023-12-19  1:15                           ` Alexei Starovoitov
2023-12-19 18:10                           ` dthaler1968 [this message]
2023-12-19 18:10                             ` dthaler1968=40googlemail.com
2023-12-20  3:28                             ` Alexei Starovoitov
2023-12-20  3:28                               ` Alexei Starovoitov
2023-12-21  7:00                               ` Christoph Hellwig
2023-12-21  7:00                                 ` Christoph Hellwig
2024-01-05 22:07                                 ` David Vernet
2024-01-05 22:07                                   ` David Vernet
2024-01-08 16:00                                   ` Christoph Hellwig
2024-01-08 21:51                                     ` Alexei Starovoitov
2024-01-08 21:51                                       ` Alexei Starovoitov
2024-01-09 11:35                                       ` Jose E. Marchesi
2024-01-09 11:35                                         ` Jose E. Marchesi
2024-01-23 21:39                                         ` David Vernet
2024-01-23 21:39                                           ` David Vernet
2024-01-23 23:29                                           ` dthaler1968
2024-01-23 23:29                                             ` dthaler1968=40googlemail.com
2024-01-25  2:55                                             ` Alexei Starovoitov
2024-01-25  2:55                                               ` Alexei Starovoitov
2024-01-09 15:26                                       ` Christoph Hellwig
2023-12-19 18:15                 ` dthaler1968
2023-12-19 18:15                   ` dthaler1968=40googlemail.com
2023-12-13 16:59         ` Christoph Hellwig
2023-12-13 16:59           ` Christoph Hellwig

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='09dc01da32a6$99c97e50$cd5c7af0$@gmail.com' \
    --to=dthaler1968@googlemail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@ietf.org \
    --cc=bpf@vger.kernel.org \
    --cc=hch@infradead.org \
    --cc=kuba@kernel.org \
    --cc=void@manifault.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