[igt-dev] [PATCH i-g-t v28 04/36] lib/igt_core: Track child process pid and tid
From: Zbigniew Kempczyński <hidden>
Date: 2021-03-22 12:38:09
Subsystem:
library code, the rest · Maintainers:
Andrew Morton, Linus Torvalds
Introduce variables which can decrease number of getpid()/gettid() calls, especially for allocator which must be aware of method acquiring addresses. When child is spawned using igt_fork() we can control its initialization and prepare child_pid implicitly. Tracking child_tid requires our intervention in the code and do something like this: if (child_tid == -1) child_tid = gettid() Variable was created for using in TLS so each thread is created with variable set to -1. This will give each thread it's own "copy" and there's no risk to use other thread tid. For each forked child we reassign -1 to child_tid to avoid using already set variable. Signed-off-by: Zbigniew Kempczyński <redacted> Cc: Dominik Grzegorzek <redacted> Cc: Chris Wilson <redacted> Cc: Petri Latvala <redacted> Acked-by: Arjun Melkaveri <redacted> Acked-by: Daniel Vetter <redacted> --- lib/igt_core.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/lib/igt_core.c b/lib/igt_core.c
index f9dfaa0dd..2b4182f16 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c@@ -306,6 +306,10 @@ int num_test_children; int test_children_sz; bool test_child; +/* For allocator purposes */ +pid_t child_pid = -1; +__thread pid_t child_tid = -1; + enum { /* * Let the first values be used by individual tests so options don't
@@ -2302,6 +2306,8 @@ bool __igt_fork(void) case 0: test_child = true; pthread_mutex_init(&print_mutex, NULL); + child_pid = getpid(); + child_tid = -1; exit_handler_count = 0; reset_helper_process_list(); oom_adjust_for_doom();
--
2.26.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev