Skip to content

Commit b5dd576

Browse files
committed
CI: attach new probes in BPF smoke test; broaden x86 guard
BPF() construction loads every function but does not attach kprobes, so a compiled-out or mis-named handler (e.g. if the arch guard around the *_x64 wrapper probes ever evaluated false) would pass CI and abort the tracer at startup instead. Attach the fsync de-dup pair, the pt_regs-unwrapping *_x64 wrapper probes, and the DIO direction probes in the smoke test, conditional on symbol availability. Also accept bpf_target_x86 (BCC helpers' canonical arch macro) alongside __x86_64__ in the wrapper-probe guards so a BCC switch to __TARGET_ARCH_* defines keeps the probes compiled. https://claude.ai/code/session_01S9qNz7CTGBd4dLLDFVVQky
1 parent 1f7edf9 commit b5dd576

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

.github/scripts/bpf_smoke.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,31 @@ def main():
5959
("kretprobe", "vfs_read", "trace_vfs_read_ret"),
6060
("kprobe", "vfs_write", "trace_vfs_write"),
6161
("kretprobe", "vfs_write", "trace_vfs_write_ret"),
62+
# fsync de-dup pair: the kretprobe clears the nested-call marker.
63+
("kprobe", "vfs_fsync", "trace_vfs_fsync"),
64+
("kretprobe", "vfs_fsync", "trace_vfs_fsync_ret"),
65+
("kprobe", "vfs_fsync_range", "trace_vfs_fsync_range"),
6266
]
67+
68+
# Symbol-conditional probes. These validate that the pt_regs-unwrapping
69+
# *_x64 variants and the DIO direction entry probes were compiled in and
70+
# attach — a guard mismatch would otherwise pass CI (BPF() load succeeds
71+
# without them) and abort the tracer at startup instead.
72+
conditional_probes = [
73+
(b"__x64_sys_mremap", [("kprobe", "__x64_sys_mremap", "trace_mremap_entry_x64"),
74+
("kretprobe", "__x64_sys_mremap", "trace_mremap_ret")]),
75+
(b"__x64_sys_openat", [("kprobe", "__x64_sys_openat", "trace_openat_entry_x64")]),
76+
(b"__x64_sys_io_uring_enter", [("kprobe", "__x64_sys_io_uring_enter", "trace_io_uring_enter_x64")]),
77+
(b"iomap_dio_rw", [("kprobe", "iomap_dio_rw", "trace_dio_entry_iomap"),
78+
("kretprobe", "iomap_dio_rw", "trace_dio_return")]),
79+
(b"__blockdev_direct_IO", [("kprobe", "__blockdev_direct_IO", "trace_dio_entry_blockdev")]),
80+
]
81+
for symbol, symbol_probes in conditional_probes:
82+
if BPF.get_kprobe_functions(symbol):
83+
probes.extend(symbol_probes)
84+
else:
85+
print(f"SKIP: {symbol.decode()} not present on this kernel")
86+
6387
for kind, event, fn in probes:
6488
if kind == "kprobe":
6589
b.attach_kprobe(event=event, fn_name=fn)

src/tracer/prober/prober.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ int trace_do_sys_openat2_entry(struct pt_regs *ctx) {
11581158
return 0;
11591159
}
11601160

1161-
#if defined(__x86_64__)
1161+
#if defined(__x86_64__) || defined(bpf_target_x86)
11621162
/**
11631163
* @brief Kprobe entry for the __x64_sys_openat syscall wrapper.
11641164
*
@@ -1622,7 +1622,7 @@ int trace_mremap_entry(struct pt_regs *ctx) {
16221622
return 0;
16231623
}
16241624

1625-
#if defined(__x86_64__)
1625+
#if defined(__x86_64__) || defined(bpf_target_x86)
16261626
/**
16271627
* @brief kprobe entry for the __x64_sys_mremap syscall wrapper.
16281628
*
@@ -3776,7 +3776,7 @@ int trace_io_uring_enter(struct pt_regs *ctx, unsigned int fd,
37763776
return emit_io_uring_enter(ctx, fd, to_submit, min_complete, flags);
37773777
}
37783778

3779-
#if defined(__x86_64__)
3779+
#if defined(__x86_64__) || defined(bpf_target_x86)
37803780
/**
37813781
* @brief Kprobe entry for the __x64_sys_io_uring_enter syscall wrapper.
37823782
*

0 commit comments

Comments
 (0)