bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
To: Eduard Zingerman <eddyz87@gmail.com>,
	bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
	daniel@iogearbox.net, kafai@meta.com, kernel-team@meta.com
Cc: Mykyta Yatsenko <yatsenko@meta.com>
Subject: Re: [PATCH bpf-next v3 2/3] selftests/bpf: support array presets in veristat
Date: Wed, 11 Jun 2025 12:38:41 +0100	[thread overview]
Message-ID: <c1cb9bd3-c99d-4af3-bbcc-2ff3c2250ca1@gmail.com> (raw)
In-Reply-To: <4ff2fafb99131f599901580eac96dca34ca20cc0.camel@gmail.com>

On 6/11/25 01:45, Eduard Zingerman wrote:
> On Tue, 2025-06-10 at 20:08 +0100, Mykyta Yatsenko wrote:
>> From: Mykyta Yatsenko <yatsenko@meta.com>
>>
>> Implement support for presetting values for array elements in
>> veristat.
>> For example:
>> ```
>> sudo ./veristat set_global_vars.bpf.o -G "arr[3] = 1"
>> ```
>> Arrays of structures and structure of arrays work, but each
>> individual
>> scalar value has to be set separately: `foo[1].bar[2] = value`.
>>
>> Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
>> ---
> A few nits regarding error reporting:
>
>    ./veristat -q -G ptr_arr[10]=0 set_global_vars.bpf.o
>    Unsupported array element type for variable ptr_arr. Only int, enum, struct, union are supported
>                                                                                                   ^^^
> 											 missing dot
>
>    ./veristat -G arr[[10]]=0 set_global_vars.bpf.o
>    Could not parse 'arr[[10]]'Failed to parse global variable presets: arr[[10]]=0
>    ^^^^^^^^^                ^^^                                                  ^^^
>    Can't ?		   dot or comma                                 missing dot
>
>    ./veristat -q -G "struct1[0] = 0" set_global_vars.bpf.o
>    Setting value for type Struct is not supported
>                                             ^^^^^^^^^
> 					   report full_name here?
>
> I applied a diff as in the attachment, to see what offsets are being assigned.
> Looks like this shows a bug:
>
>    ./veristat  -q -G "struct1[0].filler = 42" set_global_vars.bpf.o > /dev/null
>    setting struct1[0].filler: offset 54, kind int, value 42
>
> Shouldn't offset be 2 in this case?
>
> (maybe print such info in debug (-d) mode?)
>
> Unrelated to this patch, but still a bug:
>
>    # Catches range error:
>    ./veristat -q -G "struct1[0].filler2 = 100500" set_global_vars.bpf.o
>    Variable unsigned short value 100500 is out of range [0; 65535]
>    # Does not range error:
>    ./veristat -q -G "struct1[0].filler2 = -1" set_global_vars.bpf.o
Thanks for taking a look and checking few testcases.
I'll fix this one in the next patch, along with the error messages.
>    ... success ...
>
> [...]


  parent reply	other threads:[~2025-06-11 11:38 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 [this message]
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
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=c1cb9bd3-c99d-4af3-bbcc-2ff3c2250ca1@gmail.com \
    --to=mykyta.yatsenko5@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kafai@meta.com \
    --cc=kernel-team@meta.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).