From: Eduard Zingerman <eddyz87@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>,
bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, kafai@meta.com, kernel-team@meta.com,
Mykyta Yatsenko <yatsenko@meta.com>
Subject: Re: [PATCH bpf-next v3 2/3] selftests/bpf: support array presets in veristat
Date: Fri, 13 Jun 2025 09:48:38 -0700 [thread overview]
Message-ID: <cb96c155c563cd8998fb8c8683a4b53497b373cf.camel@gmail.com> (raw)
In-Reply-To: <CAEf4BzahEMFWhFX_1AzYeKHY5FkVQiD5J8x69PrRUGhqNHyu6A@mail.gmail.com>
On Fri, 2025-06-13 at 09:34 -0700, Andrii Nakryiko wrote:
> On Wed, Jun 11, 2025 at 5:21 AM Eduard Zingerman <eddyz87@gmail.com> wrote:
> >
> > What do you think about a more recursive representation for presets?
> > E.g. as follows:
> >
> > struct rvalue {
> > long long i; /* use find_enum_value() at parse time to avoid union */
> > };
> >
> > struct lvalue {
> > enum { VAR, FIELD, ARRAY } type;
> > union {
> > struct {
> > char *name;
> > } var;
> > struct {
> > struct lvalue *base;
> > char *name;
> > } field;
> > struct {
> > struct lvalue *base;
> > struct rvalue index;
> > } array;
> > };
> > };
> >
> > struct preset {
> > struct lvalue *lv;
> > struct rvalue rv;
> > };
> >
> > It can handle matrices ("a[2][3]") and offset/type computation would
> > be a simple recursive function.
> >
>
> Why do we need recursion, though? All we should need is an array specs
> of one of the following types:
>
> a) field access by name
> a.1) we might want to distinguish array field vs non-array field
> to better catch unintended user errors
> b) indexing by immediate integer
> c) indexing by symbolic enum name (or we can combine b and c,
> whatever works better).
>
> And that's all. And it will support multi-dimensional arrays.
>
> We then process this array one at a time. Each *step* itself might be
> recursive: finding a field by name in C struct is necessarily
> recursive due to anonymous embedded struct/union fields. But other
> than that, it's a simple sequential operation.
>
> So unless I'm missing something, let's not add data recursion if it's
> not needed.
Recursive representation I simpler in a sense that you need only one
data type. W/o recursion you need to distinguish between container
data type that links to each constituent.
Plus in a computation function you need to distinguish first step from
all others. Recursive organization simplifies both data types and
computation function.
next prev parent reply other threads:[~2025-06-13 16:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 19:08 [PATCH bpf-next v3 0/3] Support array presets in veristat Mykyta Yatsenko
2025-06-10 19:08 ` [PATCH bpf-next v3 1/3] selftests/bpf: separate var preset parsing " Mykyta Yatsenko
2025-06-10 19:08 ` [PATCH bpf-next v3 2/3] selftests/bpf: support array presets " Mykyta Yatsenko
2025-06-11 0:45 ` Eduard Zingerman
2025-06-11 5:23 ` Eduard Zingerman
2025-06-11 11:38 ` Mykyta Yatsenko
2025-06-11 12:21 ` Eduard Zingerman
2025-06-11 13:32 ` Mykyta Yatsenko
2025-06-11 16:55 ` Eduard Zingerman
2025-06-13 16:34 ` Andrii Nakryiko
2025-06-13 16:48 ` Eduard Zingerman [this message]
2025-06-13 16:59 ` Andrii Nakryiko
2025-06-13 17:10 ` Eduard Zingerman
2025-06-13 17:21 ` Andrii Nakryiko
2025-06-10 19:08 ` [PATCH bpf-next v3 3/3] selftests/bpf: test " Mykyta Yatsenko
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=cb96c155c563cd8998fb8c8683a4b53497b373cf.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kafai@meta.com \
--cc=kernel-team@meta.com \
--cc=mykyta.yatsenko5@gmail.com \
--cc=yatsenko@meta.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).