[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMB2axMQsFLO-85q2tRNE==s8t_Y3A2iPaGTm0=NkjJ4wz0X=g@mail.gmail.com>
Date: Fri, 25 Apr 2025 15:51:40 -0700
From: Amery Hung <ameryhung@...il.com>
To: Tejun Heo <tj@...nel.org>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org, alexei.starovoitov@...il.com,
andrii@...nel.org, daniel@...earbox.net, martin.lau@...nel.org,
kernel-team@...a.com
Subject: Re: [PATCH RFC v3 2/2] selftests/bpf: Test basic workflow of task
local data
On Fri, Apr 25, 2025 at 3:12 PM Tejun Heo <tj@...nel.org> wrote:
>
> Hello,
>
> On Fri, Apr 25, 2025 at 02:40:34PM -0700, Amery Hung wrote:
> ...
> > +bpf_tld_key_type_var("test_basic_value3", int, value3);
> > +bpf_tld_key_type_var("test_basic_value4", struct test_struct, value4);
>
> I think it'd be fine to always require key string.
>
> > diff --git a/tools/testing/selftests/bpf/progs/test_task_local_data_basic.c b/tools/testing/selftests/bpf/progs/test_task_local_data_basic.c
> > new file mode 100644
> > index 000000000000..345d7c6e37de
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/progs/test_task_local_data_basic.c
> ...
> > + bpf_tld_init_var(&tld, test_basic_value3);
> > + bpf_tld_init_var(&tld, test_basic_value4);
>
> Would it make more sense to make the second parameter to be a string? The
> key names may contain tokens that are special to C and it becomes odd to
> escape naked strings.
>
Totally makes sense. I will only keep bpf_tld_key_type_var() that
requires a key string in the declaration.
I will also add the key string as the third argument to
bpf_tld_init_var() and rename it to bpf_tld_fetch_key(). I don't think
the symbol type argument that refers to one of the members of struct
task_local_data_offsets can be removed.
So it becomes:
bpf_tld_fetch_key(&tld, test_basic_value3, "something.test_basic_value3");
Later, bpf programs still do:
bpf_tld_lookup(&tls, test_basic_value3);
> Thanks.
>
> --
> tejun
Powered by blists - more mailing lists