<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/tools/testing/selftests/bpf/trace_helpers.h, branch master</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=master</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2026-02-24T16:19:49Z</updated>
<entry>
<title>selftests/bpf: Refactor bpf_get_ksyms() trace helper</title>
<updated>2026-02-24T16:19:49Z</updated>
<author>
<name>Ihor Solodrai</name>
</author>
<published>2026-02-23T19:07:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a1a771bd649212ef32cf9b0bcc63213a762d354a'/>
<id>urn:sha1:a1a771bd649212ef32cf9b0bcc63213a762d354a</id>
<content type='text'>
ASAN reported a memory leak in bpf_get_ksyms(): it allocates a struct
ksyms internally and never frees it.

Move struct ksyms to trace_helpers.h and return it from the
bpf_get_ksyms(), giving ownership to the caller. Add filtered_syms and
filtered_cnt fields to the ksyms to hold the filtered array of
symbols, previously returned by bpf_get_ksyms().

Fixup the call sites: kprobe_multi_test and bench_trigger.

Signed-off-by: Ihor Solodrai &lt;ihor.solodrai@linux.dev&gt;
Acked-by: Eduard Zingerman &lt;eddyz87@gmail.com&gt;
Link: https://lore.kernel.org/r/20260223190736.649171-10-ihor.solodrai@linux.dev
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;

</content>
</entry>
<entry>
<title>selftests/bpf: Add test for bpf_override_return helper</title>
<updated>2026-01-16T00:15:26Z</updated>
<author>
<name>Jiri Olsa</name>
</author>
<published>2026-01-12T12:11:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=934d9746ed0206e93506a68c838fe82ef748576a'/>
<id>urn:sha1:934d9746ed0206e93506a68c838fe82ef748576a</id>
<content type='text'>
We do not actually test the bpf_override_return helper functionality
itself at the moment, only the bpf program being able to attach it.

Adding test that override prctl syscall return value on top of
kprobe and kprobe.multi.

Signed-off-by: Jiri Olsa &lt;jolsa@kernel.org&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Song Liu &lt;song@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20260112121157.854473-2-jolsa@kernel.org
</content>
</entry>
<entry>
<title>selftests/bpf: move get_ksyms and get_addrs to trace_helpers.c</title>
<updated>2025-09-04T16:00:25Z</updated>
<author>
<name>Menglong Dong</name>
</author>
<published>2025-09-04T02:10:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8bad31edf5490a38dc26163502cd7005a033ee05'/>
<id>urn:sha1:8bad31edf5490a38dc26163502cd7005a033ee05</id>
<content type='text'>
We need to get all the kernel function that can be traced sometimes, so we
move the get_syms() and get_addrs() in kprobe_multi_test.c to
trace_helpers.c and rename it to bpf_get_ksyms() and bpf_get_addrs().

Signed-off-by: Menglong Dong &lt;dongml2@chinatelecom.cn&gt;
Link: https://lore.kernel.org/r/20250904021011.14069-2-dongml2@chinatelecom.cn
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Add read_trace_pipe_iter function</title>
<updated>2024-04-12T16:25:21Z</updated>
<author>
<name>Jiri Olsa</name>
</author>
<published>2024-04-10T14:09:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4d4992ff587604455e8843a0e76dce0b99175319'/>
<id>urn:sha1:4d4992ff587604455e8843a0e76dce0b99175319</id>
<content type='text'>
We have two printk tests reading trace_pipe in non blocking way,
with the very same code. Moving that in new read_trace_pipe_iter
function.

Current read_trace_pipe is used from samples/bpf and needs to
do blocking read and printf of the trace_pipe data, using new
read_trace_pipe_iter to implement that.

Both printk tests do early checks for the number of found messages
and can bail earlier, but I did not find any speed difference w/o
that condition, so I did not complicate the change more for that.

Some of the samples/bpf programs use read_trace_pipe function,
so I kept that interface untouched. I did not see any issues with
affected samples/bpf programs other than there's slight change in
read_trace_pipe output. The current code uses puts that adds new
line after the printed string, so we would occasionally see extra
new line. With this patch we read output per lines, so there's no
need to use puts and we can use just printf instead without extra
new line.

Signed-off-by: Jiri Olsa &lt;jolsa@kernel.org&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Yonghong Song &lt;yonghong.song@linux.dev&gt;
Link: https://lore.kernel.org/bpf/20240410140952.292261-1-jolsa@kernel.org
</content>
</entry>
<entry>
<title>selftests/bpf: Add {load,search}_kallsyms_custom_local()</title>
<updated>2024-03-29T01:31:41Z</updated>
<author>
<name>Yonghong Song</name>
</author>
<published>2024-03-26T04:15:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d1f02581059e42d8daf944aae2a296254cc7a5d5'/>
<id>urn:sha1:d1f02581059e42d8daf944aae2a296254cc7a5d5</id>
<content type='text'>
These two functions allow selftests to do loading/searching
kallsyms based on their specific compare functions.

Signed-off-by: Yonghong Song &lt;yonghong.song@linux.dev&gt;
Link: https://lore.kernel.org/r/20240326041513.1199440-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Refactor trace helper func load_kallsyms_local()</title>
<updated>2024-03-29T01:31:41Z</updated>
<author>
<name>Yonghong Song</name>
</author>
<published>2024-03-26T04:15:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9475dacb75e0b5efae086dc904f4d27c31f15157'/>
<id>urn:sha1:9475dacb75e0b5efae086dc904f4d27c31f15157</id>
<content type='text'>
Refactor trace helper function load_kallsyms_local() such that
it invokes a common function with a compare function as input.
The common function will be used later for other local functions.

Signed-off-by: Yonghong Song &lt;yonghong.song@linux.dev&gt;
Link: https://lore.kernel.org/r/20240326041508.1199239-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: trace_helpers.c: Optimize kallsyms cache</title>
<updated>2023-09-08T23:22:41Z</updated>
<author>
<name>Rong Tao</name>
</author>
<published>2023-09-07T01:59:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c698eaebdf4759d297343f20e00172610207b754'/>
<id>urn:sha1:c698eaebdf4759d297343f20e00172610207b754</id>
<content type='text'>
Static ksyms often have problems because the number of symbols exceeds the
MAX_SYMS limit. Like changing the MAX_SYMS from 300000 to 400000 in
commit e76a014334a6("selftests/bpf: Bump and validate MAX_SYMS") solves
the problem somewhat, but it's not the perfect way.

This commit uses dynamic memory allocation, which completely solves the
problem caused by the limitation of the number of kallsyms. At the same
time, add APIs:

    load_kallsyms_local()
    ksym_search_local()
    ksym_get_addr_local()
    free_kallsyms_local()

There are used to solve the problem of selftests/bpf updating kallsyms
after attach new symbols during testmod testing.

Signed-off-by: Rong Tao &lt;rongtao@cestc.cn&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Jiri Olsa &lt;jolsa@kernel.org&gt;
Acked-by: Stanislav Fomichev &lt;sdf@google.com&gt;
Link: https://lore.kernel.org/bpf/tencent_C9BDA68F9221F21BE4081566A55D66A9700A@qq.com
</content>
</entry>
<entry>
<title>selftests/bpf: Add read_build_id function</title>
<updated>2023-03-31T16:40:16Z</updated>
<author>
<name>Jiri Olsa</name>
</author>
<published>2023-03-31T09:31:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=88dc8b3605b38a440fba45edcc53a6c7a98eee3b'/>
<id>urn:sha1:88dc8b3605b38a440fba45edcc53a6c7a98eee3b</id>
<content type='text'>
Adding read_build_id function that parses out build id from
specified binary.

It will replace extract_build_id and also be used in following
changes.

Signed-off-by: Jiri Olsa &lt;jolsa@kernel.org&gt;
Link: https://lore.kernel.org/r/20230331093157.1749137-3-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Add load_kallsyms_refresh function</title>
<updated>2022-10-25T17:14:51Z</updated>
<author>
<name>Jiri Olsa</name>
</author>
<published>2022-10-25T13:41:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=10705b2b7a8e4eb46ab5bf1b9ee354cb9a929428'/>
<id>urn:sha1:10705b2b7a8e4eb46ab5bf1b9ee354cb9a929428</id>
<content type='text'>
Adding load_kallsyms_refresh function to re-read symbols from
/proc/kallsyms file.

This will be needed to get proper functions addresses from
bpf_testmod.ko module, which is loaded/unloaded several times
during the tests run, so symbols might be already old when
we need to use them.

Acked-by: Song Liu &lt;song@kernel.org&gt;
Signed-off-by: Jiri Olsa &lt;jolsa@kernel.org&gt;
Link: https://lore.kernel.org/r/20221025134148.3300700-6-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: fix uprobe offset calculation in selftests</title>
<updated>2022-01-27T04:04:01Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2022-01-26T19:30:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ff943683f8a6dbf887c16275d0e80c1c5391b7bb'/>
<id>urn:sha1:ff943683f8a6dbf887c16275d0e80c1c5391b7bb</id>
<content type='text'>
Fix how selftests determine relative offset of a function that is
uprobed. Previously, there was an assumption that uprobed function is
always in the first executable region, which is not always the case
(libbpf CI hits this case now). So get_base_addr() approach in isolation
doesn't work anymore. So teach get_uprobe_offset() to determine correct
memory mapping and calculate uprobe offset correctly.

While at it, I merged together two implementations of
get_uprobe_offset() helper, moving powerpc64-specific logic inside (had
to add extra {} block to avoid unused variable error for insn).

Also ensured that uprobed functions are never inlined, but are still
static (and thus local to each selftest), by using a no-op asm volatile
block internally. I didn't want to keep them global __weak, because some
tests use uprobe's ref counter offset (to test USDT-like logic) which is
not compatible with non-refcounted uprobe. So it's nicer to have each
test uprobe target local to the file and guaranteed to not be inlined or
skipped by the compiler (which can happen with static functions,
especially if compiling selftests with -O2).

Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/r/20220126193058.3390292-1-andrii@kernel.org
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
</feed>
