From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>,
Mykyta Yatsenko <yatsenko@meta.com>, Tejun Heo <tj@kernel.org>,
Alan Maguire <alan.maguire@oracle.com>,
Benjamin Tissoires <bentiss@kernel.org>,
Jiri Kosina <jikos@kernel.org>,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-input@vger.kernel.org, sched-ext@lists.linux.dev
Subject: Re: [PATCH bpf-next v1 04/10] resolve_btfids: Support for KF_IMPLICIT_ARGS
Date: Mon, 12 Jan 2026 17:49:14 -0800 [thread overview]
Message-ID: <5bcd3bb1-6ed0-4ad8-9de8-46385de908cb@linux.dev> (raw)
In-Reply-To: <CAEf4BzYuchyyw9M6eQo0Gou=09PcM-o_Ay7D8DM1gDitiG6Tbg@mail.gmail.com>
On 1/12/26 8:51 AM, Andrii Nakryiko wrote:
> On Fri, Jan 9, 2026 at 5:15 PM Ihor Solodrai <ihor.solodrai@linux.dev> wrote:
>>
>> [...]
>>>>
>>>> diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c
>>>> index df39982f51df..b361e726fa36 100644
>>>> --- a/tools/bpf/resolve_btfids/main.c
>>>> +++ b/tools/bpf/resolve_btfids/main.c
>>>> @@ -152,6 +152,18 @@ struct object {
>>>> int nr_typedefs;
>>>> };
>>>>
>>>> +#define KF_IMPLICIT_ARGS (1 << 16)
>>>> +#define KF_IMPL_SUFFIX "_impl"
>>>> +#define MAX_BPF_FUNC_REG_ARGS 5
>>>> +#define MAX_KFUNCS 256
>>>> +#define MAX_DECL_TAGS (MAX_KFUNCS * 4)
>>>
>>> can't we get that from include/linux/bpf.h? seems like
>>> resolve_btfids's main.c include internal headers just fine, so why
>>> duplicate definitions?
>>
>> Hi Andrii, thank you for a quick review.
>>
>> Including internal include/linux/btf.h directly doesn't work, which is
>> probably expected.
>>
>> resolve_btfids is currently built with:
>>
>> HOSTCFLAGS_resolve_btfids += -g \
>> -I$(srctree)/tools/include \
>> -I$(srctree)/tools/include/uapi \
>
> so I don't know if that will solve the issue, but I don't think it
> makes sense to build resolve_btfids using tools' version of includes.
> tools/include is mostly for perf's benefit (maybe so that they don't
> accidentally take some kernel-internal dependency, not sure). But
> resolve_btfids is built for the kernel during the kernel build, we
> should have access to full kernel headers. Try changing this and see
> if build errors go away?
>
>> -I$(LIBBPF_INCLUDE) \
>> -I$(SUBCMD_INCLUDE) \
>> $(LIBELF_FLAGS) \
>> -Wall -Werror
>>
>> If I add -I$(srctree)/include option and then
>>
>> #include <linux/btf.h>
>>
>> A bunch of build errors happen.
>>
>> AFAIU we'd have to create a stripped copy of relevant headers in
>> tools/include first. Is that what you're suggesting?
>
> see above, the opposite -- just use -I$(srctree)/include directly
Andrii,
I made a low-effort attempt to switch away from tools/include and it
looks like too much trouble. See a sample splat below.
I think the issue is that resolve_btfids uses a couple of inherently
user-space things (stdlib, libelf), which themselves may include
system headers. And there is actually a difference between the kernel
and tools/include headers. For example, check
./include/linux/rbtree.h
vs
./tools/include/linux/rbtree.h
Maybe we can make it work (with our own local tools/include?), but it
doesn't look worth it for just a couple of constant #define-s.
Let me know if I am missing something.
$ make
INSTALL libsubcmd_headers
HOSTCC /home/isolodrai/workspace/prog-aux/linux/tools/bpf/resolve_btfids/main.o
In file included from /home/isolodrai/workspace/prog-aux/linux/include/uapi/linux/stat.h:5,
from /home/isolodrai/workspace/prog-aux/linux/include/linux/stat.h:7,
from main.c:70:
/home/isolodrai/workspace/prog-aux/linux/include/linux/types.h:20:33: error: conflicting types for ‘fd_set’; have ‘__kernel_fd_set’
20 | typedef __kernel_fd_set fd_set;
| ^~~~~~
In file included from /usr/include/sys/types.h:179,
from /usr/include/stdlib.h:394,
from main.c:67:
/usr/include/sys/select.h:70:5: note: previous declaration of ‘fd_set’ with type ‘fd_set’
70 | } fd_set;
| ^~~~~~
In file included from /home/isolodrai/workspace/prog-aux/linux/include/uapi/linux/stat.h:5,
from /home/isolodrai/workspace/prog-aux/linux/include/linux/stat.h:7,
from main.c:70:
/home/isolodrai/workspace/prog-aux/linux/include/linux/types.h:21:33: error: conflicting types for ‘dev_t’; have ‘__kernel_dev_t’ {aka ‘unsigned int’}
21 | typedef __kernel_dev_t dev_t;
| ^~~~~
In file included from /usr/include/stdlib.h:394,
from main.c:67:
/usr/include/sys/types.h:59:17: note: previous declaration of ‘dev_t’ with type ‘dev_t’ {aka ‘long unsigned int’}
59 | typedef __dev_t dev_t;
| ^~~~~
In file included from /home/isolodrai/workspace/prog-aux/linux/include/uapi/linux/stat.h:5,
from /home/isolodrai/workspace/prog-aux/linux/include/linux/stat.h:7,
from main.c:70:
/home/isolodrai/workspace/prog-aux/linux/include/linux/types.h:25:33: error: conflicting types for ‘nlink_t’; have ‘u32’ {aka ‘unsigned int’}
25 | typedef u32 nlink_t;
| ^~~~~~~
In file included from /usr/include/stdlib.h:394,
from main.c:67:
/usr/include/sys/types.h:74:19: note: previous declaration of ‘nlink_t’ with type ‘nlink_t’ {aka ‘long unsigned int’}
74 | typedef __nlink_t nlink_t;
| ^~~~~~~
In file included from /home/isolodrai/workspace/prog-aux/linux/include/uapi/linux/stat.h:5,
from /home/isolodrai/workspace/prog-aux/linux/include/linux/stat.h:7,
from main.c:70:
/home/isolodrai/workspace/prog-aux/linux/include/linux/types.h:31:33: error: conflicting types for ‘timer_t’; have ‘__kernel_timer_t’ {aka ‘int’}
31 | typedef __kernel_timer_t timer_t;
| ^~~~~~~
In file included from /usr/include/sys/types.h:130,
from /usr/include/stdlib.h:394,
from main.c:67:
/usr/include/bits/types/timer_t.h:7:19: note: previous declaration of ‘timer_t’ with type ‘timer_t’ {aka ‘void *’}
7 | typedef __timer_t timer_t;
| ^~~~~~~
In file included from /home/isolodrai/workspace/prog-aux/linux/include/uapi/linux/stat.h:5,
from /home/isolodrai/workspace/prog-aux/linux/include/linux/stat.h:7,
from main.c:70:
/home/isolodrai/workspace/prog-aux/linux/include/linux/types.h:52:33: error: conflicting types for ‘loff_t’; have ‘__kernel_loff_t’ {aka ‘long long int’}
52 | typedef __kernel_loff_t loff_t;
| ^~~~~~
In file included from /usr/include/stdlib.h:394,
from main.c:67:
/usr/include/sys/types.h:42:18: note: previous declaration of ‘loff_t’ with type ‘loff_t’ {aka ‘long int’}
42 | typedef __loff_t loff_t;
| ^~~~~~
In file included from /home/isolodrai/workspace/prog-aux/linux/include/uapi/linux/stat.h:5,
from /home/isolodrai/workspace/prog-aux/linux/include/linux/stat.h:7,
from main.c:70:
/home/isolodrai/workspace/prog-aux/linux/include/linux/types.h:53:9: error: unknown type name ‘__kernel_uoff_t’
53 | typedef __kernel_uoff_t uoff_t;
| ^~~~~~~~~~~~~~~
/home/isolodrai/workspace/prog-aux/linux/include/linux/types.h:115:33: error: conflicting types for ‘uint64_t’; have ‘u64’ {aka ‘long long unsigned int’}
115 | typedef u64 uint64_t;
| ^~~~~~~~
In file included from /usr/include/stdint.h:37,
from /usr/lib/gcc/x86_64-redhat-linux/11/include/stdint.h:9,
from /usr/include/libelf.h:32,
from main.c:68:
/usr/include/bits/stdint-uintn.h:27:20: note: previous declaration of ‘uint64_t’ with type ‘uint64_t’ {aka ‘long unsigned int’}
27 | typedef __uint64_t uint64_t;
| ^~~~~~~~
In file included from /home/isolodrai/workspace/prog-aux/linux/include/uapi/linux/stat.h:5,
from /home/isolodrai/workspace/prog-aux/linux/include/linux/stat.h:7,
from main.c:70:
/home/isolodrai/workspace/prog-aux/linux/include/linux/types.h:116:33: error: conflicting types for ‘u_int64_t’; have ‘u64’ {aka ‘long long unsigned int’}
116 | typedef u64 u_int64_t;
| ^~~~~~~~~
In file included from /usr/include/stdlib.h:394,
from main.c:67:
/usr/include/sys/types.h:161:20: note: previous declaration of ‘u_int64_t’ with type ‘u_int64_t’ {aka ‘long unsigned int’}
161 | typedef __uint64_t u_int64_t;
| ^~~~~~~~~
In file included from /home/isolodrai/workspace/prog-aux/linux/include/uapi/linux/stat.h:5,
from /home/isolodrai/workspace/prog-aux/linux/include/linux/stat.h:7,
from main.c:70:
/home/isolodrai/workspace/prog-aux/linux/include/linux/types.h:117:33: error: conflicting types for ‘int64_t’; have ‘s64’ {aka ‘long long int’}
117 | typedef s64 int64_t;
| ^~~~~~~
In file included from /usr/include/sys/types.h:155,
from /usr/include/stdlib.h:394,
from main.c:67:
/usr/include/bits/stdint-intn.h:27:19: note: previous declaration of ‘int64_t’ with type ‘int64_t’ {aka ‘long int’}
27 | typedef __int64_t int64_t;
| ^~~~~~~
In file included from /home/isolodrai/workspace/prog-aux/linux/include/uapi/linux/stat.h:5,
from /home/isolodrai/workspace/prog-aux/linux/include/linux/stat.h:7,
from main.c:70:
/home/isolodrai/workspace/prog-aux/linux/include/linux/types.h:138:13: error: conflicting types for ‘blkcnt_t’; have ‘u64’ {aka ‘long long unsigned int’}
138 | typedef u64 blkcnt_t;
| ^~~~~~~~
In file included from /usr/include/stdlib.h:394,
from main.c:67:
/usr/include/sys/types.h:192:20: note: previous declaration of ‘blkcnt_t’ with type ‘blkcnt_t’ {aka ‘long int’}
192 | typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */
| ^~~~~~~~
In file included from /home/isolodrai/workspace/prog-aux/linux/include/uapi/linux/stat.h:5,
from /home/isolodrai/workspace/prog-aux/linux/include/linux/stat.h:7,
from main.c:70:
/home/isolodrai/workspace/prog-aux/linux/include/linux/types.h:266:34: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘*’ token
266 | struct task_struct __rcu *task;
| ^
In file included from /home/isolodrai/workspace/prog-aux/linux/include/linux/cache.h:6,
from /home/isolodrai/workspace/prog-aux/linux/include/linux/time.h:5,
from /home/isolodrai/workspace/prog-aux/linux/include/linux/stat.h:19,
from main.c:70:
/home/isolodrai/workspace/prog-aux/linux/include/vdso/cache.h:5:10: fatal error: asm/cache.h: No such file or directory
5 | #include <asm/cache.h>
| ^~~~~~~~~~~~~
compilation terminated.
make[1]: *** [/home/isolodrai/workspace/prog-aux/linux/tools/build/Makefile.build:86: /home/isolodrai/workspace/prog-aux/linux/tools/bpf/resolve_btfids/main.o] Error 1
make: *** [Makefile:81: /home/isolodrai/workspace/prog-aux/linux/tools/bpf/resolve_btfids//resolve_btfids-in.o] Error 2
>
> [...]
>
next prev parent reply other threads:[~2026-01-13 1:49 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 18:48 [PATCH bpf-next v1 00/10] bpf: Kernel functions with KF_IMPLICIT_ARGS Ihor Solodrai
2026-01-09 18:48 ` [PATCH bpf-next v1 01/10] bpf: Refactor btf_kfunc_id_set_contains Ihor Solodrai
2026-01-13 21:43 ` Eduard Zingerman
2026-01-09 18:48 ` [PATCH bpf-next v1 02/10] bpf: Introduce struct bpf_kfunc_meta Ihor Solodrai
2026-01-13 21:46 ` Eduard Zingerman
2026-01-09 18:48 ` [PATCH bpf-next v1 03/10] bpf: Verifier support for KF_IMPLICIT_ARGS Ihor Solodrai
2026-01-09 19:54 ` Alexei Starovoitov
2026-01-09 23:25 ` Andrii Nakryiko
2026-01-13 20:39 ` Eduard Zingerman
2026-01-13 22:03 ` Ihor Solodrai
2026-01-13 23:48 ` Ihor Solodrai
2026-01-14 0:55 ` Alexei Starovoitov
2026-01-14 3:57 ` Ihor Solodrai
2026-01-14 1:35 ` Eduard Zingerman
2026-01-13 21:59 ` Eduard Zingerman
2026-01-14 0:03 ` Ihor Solodrai
2026-01-14 1:06 ` Eduard Zingerman
2026-01-14 4:08 ` Ihor Solodrai
2026-01-09 18:48 ` [PATCH bpf-next v1 04/10] resolve_btfids: Support " Ihor Solodrai
2026-01-09 19:15 ` bot+bpf-ci
2026-01-09 19:34 ` Ihor Solodrai
2026-01-09 23:25 ` Andrii Nakryiko
2026-01-10 1:15 ` Ihor Solodrai
2026-01-12 16:51 ` Andrii Nakryiko
2026-01-13 1:49 ` Ihor Solodrai [this message]
2026-01-13 16:55 ` Andrii Nakryiko
2026-01-09 18:48 ` [PATCH bpf-next v1 05/10] selftests/bpf: Add tests " Ihor Solodrai
2026-01-09 23:25 ` Andrii Nakryiko
2026-01-10 1:29 ` Ihor Solodrai
2026-01-12 16:55 ` Andrii Nakryiko
2026-01-09 18:48 ` [PATCH bpf-next v1 06/10] bpf: Add bpf_wq_set_callback kfunc with KF_IMPLICIT_ARGS Ihor Solodrai
2026-01-09 18:48 ` [PATCH bpf-next v1 07/10] HID: Use bpf_wq_set_callback kernel function Ihor Solodrai
2026-01-09 21:34 ` Benjamin Tissoires
2026-01-09 18:48 ` [PATCH bpf-next v1 08/10] bpf: Add bpf_task_work_schedule_* kfuncs with KF_IMPLICIT_ARGS Ihor Solodrai
2026-01-09 19:58 ` Alexei Starovoitov
2026-01-09 20:02 ` Ihor Solodrai
2026-01-09 20:47 ` Alexei Starovoitov
2026-01-09 21:39 ` Ihor Solodrai
2026-01-09 21:49 ` Alexei Starovoitov
2026-01-09 21:56 ` Ihor Solodrai
2026-01-12 18:53 ` Ihor Solodrai
2026-01-12 22:43 ` Andrii Nakryiko
2026-01-09 18:48 ` [PATCH bpf-next v1 09/10] bpf: Add bpf_stream_vprintk " Ihor Solodrai
2026-01-09 18:48 ` [PATCH bpf-next v1 10/10] bpf,docs: Document KF_IMPLICIT_ARGS flag Ihor Solodrai
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=5bcd3bb1-6ed0-4ad8-9de8-46385de908cb@linux.dev \
--to=ihor.solodrai@linux.dev \
--cc=alan.maguire@oracle.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bentiss@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=sched-ext@lists.linux.dev \
--cc=tj@kernel.org \
--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