Skip to content

Commit cabff72

Browse files
AsphalttKernel Patches Daemon
authored andcommitted
bpf: Support fentry/fexit for functions with union args
Currently, functions with 'union' arguments cannot be traced with fentry/fexit: bpftrace -e 'fentry:release_pages { exit(); }' -v AST node count: 6 Attaching 1 probe... ERROR: Error loading BPF program for fentry_vmlinux_release_pages_1. Kernel error log: The function release_pages arg0 type UNION is unsupported. processed 0 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0 ERROR: Loading BPF object(s) failed. The type of the 'release_pages' argument is defined as: typedef union { struct page **pages; struct folio **folios; struct encoded_page **encoded_pages; } release_pages_arg __attribute__ ((__transparent_union__)); This patch relaxes the restriction by allowing function arguments of type 'union' to be traced. Signed-off-by: Leon Hwang <[email protected]>
1 parent ba991b7 commit cabff72

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/bpf/btf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6762,7 +6762,7 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type,
67626762
/* skip modifiers */
67636763
while (btf_type_is_modifier(t))
67646764
t = btf_type_by_id(btf, t->type);
6765-
if (btf_type_is_small_int(t) || btf_is_any_enum(t) || __btf_type_is_struct(t))
6765+
if (btf_type_is_small_int(t) || btf_is_any_enum(t) || btf_type_is_struct(t))
67666766
/* accessing a scalar */
67676767
return true;
67686768
if (!btf_type_is_ptr(t)) {
@@ -7334,7 +7334,7 @@ static int __get_type_size(struct btf *btf, u32 btf_id,
73347334
if (btf_type_is_ptr(t))
73357335
/* kernel size of pointer. Not BPF's size of pointer*/
73367336
return sizeof(void *);
7337-
if (btf_type_is_int(t) || btf_is_any_enum(t) || __btf_type_is_struct(t))
7337+
if (btf_type_is_int(t) || btf_is_any_enum(t) || btf_type_is_struct(t))
73387338
return t->size;
73397339
return -EINVAL;
73407340
}

0 commit comments

Comments
 (0)