[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20241216021410.GA129445@j66a10360.sqa.eu95>
Date: Mon, 16 Dec 2024 10:14:10 +0800
From: "D. Wythe" <alibuda@...ux.alibaba.com >
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: "D. Wythe" <alibuda@...ux.alibaba.com>, kgraul@...ux.ibm.com,
wenjia@...ux.ibm.com, jaka@...ux.ibm.com, ast@...nel.org,
daniel@...earbox.net, andrii@...nel.org, martin.lau@...ux.dev,
pabeni@...hat.com, song@...nel.org, sdf@...gle.com,
haoluo@...gle.com, yhs@...com, edumazet@...gle.com,
john.fastabend@...il.com, kpsingh@...nel.org, jolsa@...nel.org,
guwen@...ux.alibaba.com, kuba@...nel.org, davem@...emloft.net,
netdev@...r.kernel.org, linux-s390@...r.kernel.org,
linux-rdma@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH bpf-next v2 4/5] libbpf: fix error when st-prefix_ops and
ops from differ btf
On Thu, Dec 12, 2024 at 02:24:46PM -0800, Andrii Nakryiko wrote:
> On Mon, Dec 9, 2024 at 8:04 PM D. Wythe <alibuda@...ux.alibaba.com> wrote:
> >
> > When a struct_ops named xxx_ops was registered by a module, and
> > it will be used in both built-in modules and the module itself,
> > so that the btf_type of xxx_ops will be present in btf_vmlinux
>
> instead of using find_btf_by_prefix_kind, let's have:
>
> 1) snprintf(STRUCT_OPS_VALUE_PREFIX, tname) right here in this
> function, so we have expected type constructed and ready to be used
> and reused, if necessary
> 2) call btf__find_by_name_kind() instead of find_btf_by_prefix_kind()
> 3) if (kern_vtype_id < 0 && !*mod_btf)
> kern_vtype_id = find_ksym_btf_id(...)
> 4) if (kern_vtype_id < 0) /* now emit error and error out */
Got it. This looks more concise, I will modify it in the next version in
this way.
Thanks,
D. Wythe
>
> > if (kern_vtype_id < 0) {
> > - pr_warn("struct_ops init_kern: struct %s%s is not found in kernel BTF\n",
> > - STRUCT_OPS_VALUE_PREFIX, tname);
> > - return kern_vtype_id;
> > + if (kern_vtype_id == -ENOENT && !*mod_btf)
> > + kern_vtype_id =
> > + find_ksym_btf_id_by_prefix_kind(obj, STRUCT_OPS_VALUE_PREFIX,
> > + tname, BTF_KIND_STRUCT, &btf,
> > + mod_btf);
> > + if (kern_vtype_id < 0) {
> > + pr_warn("struct_ops init_kern: struct %s%s is not found in kernel BTF\n",
> > + STRUCT_OPS_VALUE_PREFIX, tname);
> > + return kern_vtype_id;
> > + }
> > }
> > kern_vtype = btf__type_by_id(btf, kern_vtype_id);
> >
> > --
> > 2.45.0
> >
Powered by blists - more mailing lists