From: Kui-Feng Lee <sinquersw@gmail.com>
To: Martin KaFai Lau <martin.lau@linux.dev>, thinker.li@gmail.com
Cc: kuifeng@meta.com, bpf@vger.kernel.org, ast@kernel.org,
song@kernel.org, kernel-team@meta.com, andrii@kernel.org,
drosen@google.com
Subject: Re: [PATCH bpf-next v5 7/9] libbpf: Find correct module BTFs for struct_ops maps and progs.
Date: Thu, 19 Oct 2023 09:31:32 -0700 [thread overview]
Message-ID: <dbae9006-563d-4d1d-8957-aa098bbb122b@gmail.com> (raw)
In-Reply-To: <74e172ec-6884-0de9-d8b9-3aa443bb5922@linux.dev>
On 10/18/23 19:43, Martin KaFai Lau wrote:
> On 10/17/23 9:23 AM, thinker.li@gmail.com wrote:
>> -static int find_ksym_btf_id(struct bpf_object *obj, const char
>> *ksym_name,
>> - __u16 kind, struct btf **res_btf,
>> - struct module_btf **res_mod_btf)
>> +static int find_module_btf_id(struct bpf_object *obj, const char
>> *kern_name,
>> + __u16 kind, struct btf **res_btf,
>> + struct module_btf **res_mod_btf)
>> {
>> struct module_btf *mod_btf;
>> struct btf *btf;
>> @@ -7710,7 +7728,7 @@ static int find_ksym_btf_id(struct bpf_object
>> *obj, const char *ksym_name,
>> btf = obj->btf_vmlinux;
>> mod_btf = NULL;
>> - id = btf__find_by_name_kind(btf, ksym_name, kind);
>> + id = btf__find_by_name_kind(btf, kern_name, kind);
>> if (id == -ENOENT) {
>> err = load_module_btfs(obj);
>> @@ -7721,7 +7739,7 @@ static int find_ksym_btf_id(struct bpf_object
>> *obj, const char *ksym_name,
>> /* we assume module_btf's BTF FD is always >0 */
>> mod_btf = &obj->btf_modules[i];
>> btf = mod_btf->btf;
>> - id = btf__find_by_name_kind_own(btf, ksym_name, kind);
>> + id = btf__find_by_name_kind_own(btf, kern_name, kind);
>> if (id != -ENOENT)
>> break;
>> }
>> @@ -7744,7 +7762,7 @@ static int
>> bpf_object__resolve_ksym_var_btf_id(struct bpf_object *obj,
>> struct btf *btf = NULL;
>> int id, err;
>> - id = find_ksym_btf_id(obj, ext->name, BTF_KIND_VAR, &btf, &mod_btf);
>> + id = find_module_btf_id(obj, ext->name, BTF_KIND_VAR, &btf,
>> &mod_btf);
>> if (id < 0) {
>> if (id == -ESRCH && ext->is_weak)
>> return 0;
>> @@ -7798,8 +7816,8 @@ static int
>> bpf_object__resolve_ksym_func_btf_id(struct bpf_object *obj,
>> local_func_proto_id = ext->ksym.type_id;
>> - kfunc_id = find_ksym_btf_id(obj, ext->essent_name ?: ext->name,
>> BTF_KIND_FUNC, &kern_btf,
>> - &mod_btf);
>> + kfunc_id = find_module_btf_id(obj, ext->essent_name ?: ext->name,
>> BTF_KIND_FUNC, &kern_btf,
>> + &mod_btf);
>> if (kfunc_id < 0) {
>> if (kfunc_id == -ESRCH && ext->is_weak)
>> return 0;
>> @@ -9464,9 +9482,9 @@ static int libbpf_find_prog_btf_id(const char
>> *name, __u32 attach_prog_fd)
>> return err;
>> }
>> -static int find_kernel_btf_id(struct bpf_object *obj, const char
>> *attach_name,
>> - enum bpf_attach_type attach_type,
>> - int *btf_obj_fd, int *btf_type_id)
>> +static int find_kernel_attach_btf_id(struct bpf_object *obj, const
>> char *attach_name,
>> + enum bpf_attach_type attach_type,
>> + int *btf_obj_fd, int *btf_type_id)
>> {
>> int ret, i;
>> @@ -9531,7 +9549,9 @@ static int libbpf_find_attach_btf_id(struct
>> bpf_program *prog, const char *attac
>> *btf_obj_fd = 0;
>> *btf_type_id = 1;
>> } else {
>> - err = find_kernel_btf_id(prog->obj, attach_name, attach_type,
>> btf_obj_fd, btf_type_id);
>> + err = find_kernel_attach_btf_id(prog->obj, attach_name,
>> + attach_type, btf_obj_fd,
>> + btf_type_id);
>> }
>> if (err) {
>> pr_warn("prog '%s': failed to find kernel BTF type ID of
>> '%s': %d\n",
>> @@ -12945,9 +12965,9 @@ int bpf_program__set_attach_target(struct
>> bpf_program *prog,
>> err = bpf_object__load_vmlinux_btf(prog->obj, true);
>> if (err)
>> return libbpf_err(err);
>> - err = find_kernel_btf_id(prog->obj, attach_func_name,
>> - prog->expected_attach_type,
>> - &btf_obj_fd, &btf_id);
>> + err = find_kernel_attach_btf_id(prog->obj, attach_func_name,
>> + prog->expected_attach_type,
>> + &btf_obj_fd, &btf_id);
>
> Please avoid mixing this level of name changes with the main changes. It
> is quite confusing for the reviewer and it is not mentioned in the
> commit message either.
Got it! Sorry confusing.
next prev parent reply other threads:[~2023-10-19 16:31 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 16:22 [PATCH bpf-next v5 0/9] Registrating struct_ops types from modules thinker.li
2023-10-17 16:22 ` [PATCH bpf-next v5 1/9] bpf: refactory struct_ops type initialization to a function thinker.li
2023-10-17 16:22 ` [PATCH bpf-next v5 2/9] bpf: add struct_ops_tab to btf thinker.li
2023-10-19 0:00 ` Martin KaFai Lau
2023-10-19 0:33 ` Kui-Feng Lee
2023-10-19 2:28 ` Martin KaFai Lau
2023-10-19 16:15 ` Kui-Feng Lee
2023-10-17 16:23 ` [PATCH bpf-next v5 3/9] bpf: hold module for bpf_struct_ops_map thinker.li
2023-10-19 0:36 ` Martin KaFai Lau
2023-10-19 16:29 ` Kui-Feng Lee
2023-10-20 5:07 ` Kui-Feng Lee
2023-10-20 21:37 ` Martin KaFai Lau
2023-10-20 22:28 ` Kui-Feng Lee
2023-10-17 16:23 ` [PATCH bpf-next v5 4/9] bpf: validate value_type thinker.li
2023-10-17 16:23 ` [PATCH bpf-next v5 5/9] bpf: pass attached BTF to the bpf_struct_ops subsystem thinker.li
2023-10-17 16:23 ` [PATCH bpf-next v5 6/9] bpf, net: switch to dynamic registration thinker.li
2023-10-19 1:49 ` Martin KaFai Lau
2023-10-20 15:12 ` Kui-Feng Lee
2023-10-20 17:53 ` Kui-Feng Lee
2023-10-17 16:23 ` [PATCH bpf-next v5 7/9] libbpf: Find correct module BTFs for struct_ops maps and progs thinker.li
2023-10-17 21:49 ` Andrii Nakryiko
2023-10-18 2:25 ` Kui-Feng Lee
2023-10-19 2:43 ` Martin KaFai Lau
2023-10-19 16:31 ` Kui-Feng Lee [this message]
2023-10-17 16:23 ` [PATCH bpf-next v5 8/9] bpf: export btf_ctx_access to modules thinker.li
2023-10-17 16:23 ` [PATCH bpf-next v5 9/9] selftests/bpf: test case for register_bpf_struct_ops() thinker.li
2023-10-17 18:03 ` kernel test robot
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=dbae9006-563d-4d1d-8957-aa098bbb122b@gmail.com \
--to=sinquersw@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=drosen@google.com \
--cc=kernel-team@meta.com \
--cc=kuifeng@meta.com \
--cc=martin.lau@linux.dev \
--cc=song@kernel.org \
--cc=thinker.li@gmail.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