[igt-dev] [PATCH i-g-t v2 3/7] lib/igt_core: add prefix to logging
Kamil Konieczny
kamil.konieczny at linux.intel.com
Tue Dec 6 11:20:29 UTC 2022
Allow to store prefix for logs and print it before any message.
This will allow to diagnose on wich GPU occurred problems when
tested on multi-GPU machines.
Cc: Petri Latvala <petri.latvala at intel.com>
Signed-off-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab at kernel.org>
---
lib/igt_core.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 68ae7289..65b7be64 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -348,6 +348,8 @@ static struct {
uint8_t start, end;
} log_buffer;
static pthread_mutex_t log_buffer_mutex = PTHREAD_MUTEX_INITIALIZER;
+#define LOG_PREFIX_SIZE 32
+char log_prefix[LOG_PREFIX_SIZE] = { 0 };
GKeyFile *igt_key_file;
@@ -3105,8 +3107,12 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format,
program_name = command_str;
#endif
- if (asprintf(&thread_id, "[thread:%d] ", gettid()) == -1)
- thread_id = NULL;
+ if (igt_thread_is_main()) {
+ thread_id = strdup(log_prefix);
+ } else {
+ if (asprintf(&thread_id, "%s[thread:%d] ", log_prefix, gettid()) == -1)
+ thread_id = NULL;
+ }
if (!thread_id)
return;
--
2.34.1
More information about the igt-dev
mailing list