* Re: [PATCH] sched_ext/selftests: Fix bpf_link leak on assertion failure
[not found] <20260317174402.48082-1-devnexen@gmail.com>
@ 2026-03-17 18:09 ` Tejun Heo
0 siblings, 0 replies; only message in thread
From: Tejun Heo @ 2026-03-17 18:09 UTC (permalink / raw)
To: David Carlier
Cc: David Vernet, Andrea Righi, linux-kernel, Emil Tsalapatis,
sched-ext
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 829 bytes --]
Hello,
In numa.c and rt_stall.c, the assertions check for SCX_EXIT_NONE — i.e.
the scheduler ran without error. bpf_link__destroy() triggers unregistration
which changes uei.kind to SCX_EXIT_UNREG, so moving it before the assertions
would make them always fail. Did you run the selftests after this patch?
A simpler approach would be using __attribute__((cleanup())) to auto-destroy
the link on any return path:
static inline void autolink_destroy(struct bpf_link **linkp)
{
if (*linkp)
bpf_link__destroy(*linkp);
}
#define __autolink __attribute__((cleanup(autolink_destroy)))
Then each test just does:
struct bpf_link *link __autolink = bpf_map__attach_struct_ops(...);
No reordering needed — the link auto-destroys on any return, including
early returns from assertion failures.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-17 18:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260317174402.48082-1-devnexen@gmail.com>
2026-03-17 18:09 ` [PATCH] sched_ext/selftests: Fix bpf_link leak on assertion failure Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox