Re: [PATCH v1 bpf-next 18/18] bpftool: List and show fmod_ret targets

From: bot+bpf-ci

Date: Fri Nov 06 2026 - 16:37:49 EST


> bpftool: List and show fmod_ret targets

TL;DR: Nit only: in bpftool fmodret.c collect_targets(), the
TAG_FMODRET_RETVAL lookup may be unneeded, since the only caller's list path
doesn't appear to read ->retval.

> diff --git a/tools/bpf/bpftool/fmodret.c b/tools/bpf/bpftool/fmodret.c
> new file mode 100644
> index 000000000000..0d2714ef861e
> --- /dev/null
> +++ b/tools/bpf/bpftool/fmodret.c

[ ... ]

> +/* Return the fmod_ret targets of BTF, sorted by BTF ID */
> +static int collect_targets(const struct btf *btf, struct fmodret_entry **targets,
> + size_t *target_cnt)
> +{

[ ... ]

> + /* The other tags mark functions which are already targets */
> + for (id = start_id; cnt && id < nr_types; id++) {
> + const struct btf_type *t = btf__type_by_id(btf, id);
> + struct fmodret_entry key = {};
> +
> + key.btf_id = tag_func(btf, t, TAG_FMODRET_SLEEPABLE);
> + if (key.btf_id) {
> + entry = bsearch(&key, entries, cnt, sizeof(*entries), cmp_entry);
> + if (entry)
> + entry->sleepable = true;
> + continue;
> + }
> + key.btf_id = tag_func(btf, t, TAG_FMODRET_RETVAL);
> + if (key.btf_id) {
> + entry = bsearch(&key, entries, cnt, sizeof(*entries), cmp_entry);
> + if (entry)
> + entry->retval = btf__name_by_offset(btf, t->name_off) +
> + strlen(TAG_FMODRET_RETVAL);
> + }
> + }

This isn't a bug, but is the TAG_FMODRET_RETVAL lookup in collect_targets()
needed?

collect_targets() has a single caller, list_btf(), and list_target() does
not seem to read ->retval or ->target from the entries. It looks like the
second loop would only need to handle the TAG_FMODRET_SLEEPABLE tag.


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/42294987431