Thread (37 messages) read the whole thread 37 messages, 6 authors, 2025-05-30

Re: [PATCHv2 perf/core 15/22] selftests/bpf: Add hit/attach/detach race optimized uprobe test

From: Jiri Olsa <hidden>
Date: 2025-05-16 07:48:32
Also in: bpf, lkml

On Thu, May 15, 2025 at 10:31:28AM -0700, Andrii Nakryiko wrote:

SNIP
quoted
+static void test_uprobe_race(void)
+{
+       int err, i, nr_threads;
+       pthread_t *threads;
+
+       nr_threads = libbpf_num_possible_cpus();
+       if (!ASSERT_GT(nr_threads, 0, "libbpf_num_possible_cpus"))
+               return;
+       nr_threads = max(2, nr_threads);
+
+       threads = malloc(sizeof(*threads) * nr_threads);
leaking this? maybe just use `pthread_t thread[nr_threads];`? or alloca()?
ugh.. will fix
quoted
+       if (!ASSERT_OK_PTR(threads, "malloc"))
+               return;
+
+       for (i = 0; i < nr_threads; i++) {
+               err = pthread_create(&threads[i], NULL, i % 2 ? worker_trigger : worker_attach,
+                                    NULL);
+               if (!ASSERT_OK(err, "pthread_create"))
+                       goto cleanup;
+       }
+
+       sleep(4);
4 seconds... can we make it much shorter and allow to define the
actual runtime with envvar? So for thorough testing you'll define
something multi-second, but once things land and settle we can run it
for 100ms at most and not slow down CI significantly? All these slow
tests do add up :(
ok, makes sense

thanks,
jirka
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help