lib/igt_core: Reinitialize print mutex in child process
Subsystems (2)
PATCH 1/1 lib/igt_core: Reinitialize print mutex in child process
IGT are prone to deadlock in igt_log() in following scenario:
1. Parent process creates additional thread which for example is doing endless loop
2. Thread sometimes is logging to console using igt_info(). This locks and unlocks print_mutex.
3. If in the meantime parent process will spawn it can be spawned with print_mutex locked. If in the child process it will do igt_info() it will deadlock.
We should reinitialize print_mutex in child process to avoid use inherited value.
--- lib/igt_core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
lib/igt_core.c +5 -3
@@ -2271,6 +2271,8 @@ static void children_exit_handler(int sig) ; } +static pthread_mutex_t print_mutex =PTHREAD_MUTEX_INITIALIZER ; +bool __igt_fork (void ) { internal_assert(!test_with_subtests || in_subtest,
@@ -2300,6 +2302,7 @@ bool __igt_fork(void)igt_assert (0 );case 0 : test_child = true; +pthread_mutex_init (&print_mutex,NULL ); exit_handler_count =0 ;reset_helper_process_list ();oom_adjust_for_doom ();
@@ -2737,8 +2740,6 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format, "NONE" }; -static pthread_mutex_t print_mutex =PTHREAD_MUTEX_INITIALIZER ; -assert (format);#ifdef __GLIBC__
@@ -2747,7 +2748,6 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format, program_name = command_str;#endif -if (igt_thread_is_main ()) { thread_id =strdup ("" ); }else {
@@ -2823,6 +2823,8 @@ out:free (line); } + +static const char *timeout_op;static void __attribute__((noreturn))igt_alarm_handler (int signal) {
Signature · 6 lines
2.26.0 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.BAT: failure for lib/igt_core: Reinitialize print mutex in child process
== Series Details ==
== Series Details ==
Series: lib/igt_core: Reinitialize print mutex in child process
URL : https://patchwork.freedesktop.org/series/82154/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_9063 -> IGTPW_5014
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with IGTPW_5014 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in IGTPW_5014, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5014/index.html
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in IGTPW_5014:
### IGT changes ###
#### Possible regressions ####
* igt@i915_selftest@live@gt_contexts:
- fi-ilk-650: [PASS][1] -> [DMESG-FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9063/fi-ilk-650/igt@i915_selftest@live@gt_contexts.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5014/fi-ilk-650/igt@i915_selftest@live@gt_contexts.html
Known issues
------------
Here are the changes found in IGTPW_5014 that come from known issues:
### IGT changes ###
#### Possible fixes ####
* igt@i915_module_load@reload:
- {fi-ehl-1}: [DMESG-WARN][3] ([i915#1982]) -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9063/fi-ehl-1/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5014/fi-ehl-1/igt@[email protected]
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- {fi-kbl-7560u}: [DMESG-WARN][5] ([i915#1982]) -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9063/fi-kbl-7560u/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5014/fi-kbl-7560u/igt@[email protected]
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- fi-icl-u2: [DMESG-WARN][7] ([i915#1982]) -> [PASS][8] +1 similar issue
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9063/fi-icl-u2/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5014/fi-icl-u2/igt@[email protected]
* igt@vgem_basic@unload:
- fi-skl-guc: [DMESG-WARN][9] ([i915#2203]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9063/fi-skl-guc/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5014/fi-skl-guc/igt@[email protected]
#### Warnings ####
* igt@kms_cursor_legacy@basic-flip-before-cursor-varying-size:
- fi-kbl-x1275: [DMESG-WARN][11] ([i915#62] / [i915#92]) -> [DMESG-WARN][12] ([i915#62] / [i915#92] / [i915#95]) +1 similar issue
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9063/fi-kbl-x1275/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5014/fi-kbl-x1275/igt@[email protected]
* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-c:
- fi-kbl-x1275: [DMESG-WARN][13] ([i915#62] / [i915#92] / [i915#95]) -> [DMESG-WARN][14] ([i915#62] / [i915#92]) +4 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9063/fi-kbl-x1275/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5014/fi-kbl-x1275/igt@[email protected]
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
- fi-kbl-x1275: [DMESG-WARN][15] ([i915#62] / [i915#92]) -> [DMESG-WARN][16] ([i915#1982] / [i915#62] / [i915#92])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9063/fi-kbl-x1275/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5014/fi-kbl-x1275/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#2203]: https://gitlab.freedesktop.org/drm/intel/issues/2203
[i915#62]: https://gitlab.freedesktop.org/drm/intel/issues/62
[i915#92]: https://gitlab.freedesktop.org/drm/intel/issues/92
[i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95
Participating hosts (46 -> 39)
------------------------------
Missing (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper fi-bdw-samus
Build changes
-------------
* CI: CI-20190529 -> None
* IGT: IGT_5790 -> IGTPW_5014
CI-20190529: 20190529
CI_DRM_9063: f5f96fda9af776f800f55d9631d1dea056d06d5f @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_5014: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5014/index.html
IGT_5790: 722a3eb9734f04030508d244df9dff55c5ab686c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_5014/index.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoted 10 lines · Zbigniew Kempczyński
IGT are prone to deadlock in
igt_log()in following scenario:1. Parent process creates additional thread which for example is doing endless loop
2. Thread sometimes is logging to console usingigt_info(). This locks and unlocksprint_mutex.
3. If in the meantime parent process will spawn it can be spawned withprint_mutexlocked. If in the child process it will doigt_info()it will deadlock.
Quoted 6 lines
We should reinitialize
print_mutexin child process to avoid use inherited value.Signed-off-by Zbigniew Kempczyński <[email protected]>Cc Petri Latvala <[email protected]>---
Are you able to type up a unit test in lib/tests/ that reproduces this deadlock?
Code LGTM, Arek, do you spot anything amiss with this?
Signature · 1 line
Petri Latvala
Quoted 53 lines
lib/igt_core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)lib/igt_core.c +5
-3@@ -2271,6 +2271,8 @@ static void children_exit_handler(int sig) ; } +static pthread_mutex_t print_mutex =PTHREAD_MUTEX_INITIALIZER ; +bool __igt_fork (void ) { internal_assert(!test_with_subtests || in_subtest,@@ -2300,6 +2302,7 @@ bool __igt_fork(void)igt_assert (0 );case 0 : test_child = true; +pthread_mutex_init (&print_mutex,NULL ); exit_handler_count =0 ;reset_helper_process_list ();oom_adjust_for_doom ();@@ -2737,8 +2740,6 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format, "NONE" }; -static pthread_mutex_t print_mutex =PTHREAD_MUTEX_INITIALIZER ; -assert (format);#ifdef __GLIBC__@@ -2747,7 +2748,6 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format, program_name = command_str;#endif -if (igt_thread_is_main ()) { thread_id =strdup ("" ); }else {@@ -2823,6 +2823,8 @@ out:free (line); } + +static const char *timeout_op;static void __attribute__((noreturn))igt_alarm_handler (int signal) {Signature · 1 line
2.26.0
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoted 14 lines · Petri Latvala
Quoted 13 lines · Zbigniew Kempczyński
IGT are prone to deadlock in
igt_log()in following scenario:1. Parent process creates additional thread which for example is doing endless loop
2. Thread sometimes is logging to console usingigt_info(). This locks and unlocksprint_mutex.
3. If in the meantime parent process will spawn it can be spawned withprint_mutexlocked. If in the child process it will doigt_info()it will deadlock.We should reinitialize
print_mutexin child process to avoid use inherited value.
Quoted 8 lines
Quoted 3 lines
Signed-off-by Zbigniew Kempczyński <[email protected]>Cc Petri Latvala <[email protected]>---
Are you able to type up a unit test in
lib/tests/that reproduces this deadlock?Code LGTM, Arek, do you spot anything amiss with this?
Other than the random whitespace changes the patch looks good. Thanks!
Mixing threading and forking is always 'fun' and people rarely think about it upfront. I won't be surprised if we will find more things like this :-)
Signature · 6 lines
Cheers, Arek _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoted 19 lines · Arkadiusz Hiler
Quoted 18 lines · Petri Latvala
Quoted 16 lines · Zbigniew Kempczyński
IGT are prone to deadlock in
igt_log()in following scenario:1. Parent process creates additional thread which for example is doing endless loop
2. Thread sometimes is logging to console usingigt_info(). This locks and unlocksprint_mutex.
3. If in the meantime parent process will spawn it can be spawned withprint_mutexlocked. If in the child process it will doigt_info()it will deadlock.We should reinitialize
print_mutexin child process to avoid use inherited value.Signed-off-by Zbigniew Kempczyński <[email protected]>Cc Petri Latvala <[email protected]>---
Quoted 6 lines
Quoted 4 lines
Are you able to type up a unit test in
lib/tests/that reproduces this deadlock?Code LGTM, Arek, do you spot anything amiss with this?
Other than the random whitespace changes the patch looks good. Thanks!
I'm sorry, I've transplanted that from code I'm working on and that was not aware something got caught up.
--
Zbigniew
Quoted 8 lines
Mixing threading and forking is always 'fun' and people rarely think about it upfront. I won't be surprised if we will find more things like this :-)
Signature · 2 lines
Cheers, Arek
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoted 14 lines · Petri Latvala
Quoted 13 lines · Zbigniew Kempczyński
IGT are prone to deadlock in
igt_log()in following scenario:1. Parent process creates additional thread which for example is doing endless loop
2. Thread sometimes is logging to console usingigt_info(). This locks and unlocksprint_mutex.
3. If in the meantime parent process will spawn it can be spawned withprint_mutexlocked. If in the child process it will doigt_info()it will deadlock.We should reinitialize
print_mutexin child process to avoid use inherited value.
Quoted 6 lines
Quoted 3 lines
Signed-off-by Zbigniew Kempczyński <[email protected]>Cc Petri Latvala <[email protected]>---
Are you able to type up a unit test in
lib/tests/that reproduces this deadlock?
Sure, shouldn't take much time.
--
Zbigniew
Quoted 62 lines
Code LGTM, Arek, do you spot anything amiss with this?
Signature · 1 line
Petri LatvalaQuoted 53 lines
lib/igt_core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)lib/igt_core.c +5
-3@@ -2271,6 +2271,8 @@ static void children_exit_handler(int sig) ; } +static pthread_mutex_t print_mutex =PTHREAD_MUTEX_INITIALIZER ; +bool __igt_fork (void ) { internal_assert(!test_with_subtests || in_subtest,@@ -2300,6 +2302,7 @@ bool __igt_fork(void)igt_assert (0 );case 0 : test_child = true; +pthread_mutex_init (&print_mutex,NULL ); exit_handler_count =0 ;reset_helper_process_list ();oom_adjust_for_doom ();@@ -2737,8 +2740,6 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format, "NONE" }; -static pthread_mutex_t print_mutex =PTHREAD_MUTEX_INITIALIZER ; -assert (format);#ifdef __GLIBC__@@ -2747,7 +2748,6 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format, program_name = command_str;#endif -if (igt_thread_is_main ()) { thread_id =strdup ("" ); }else {@@ -2823,6 +2823,8 @@ out:free (line); } + +static const char *timeout_op;static void __attribute__((noreturn))igt_alarm_handler (int signal) {Signature · 1 line
2.26.0
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoted 14 lines · Petri Latvala
Quoted 13 lines · Zbigniew Kempczyński
IGT are prone to deadlock in
igt_log()in following scenario:1. Parent process creates additional thread which for example is doing endless loop
2. Thread sometimes is logging to console usingigt_info(). This locks and unlocksprint_mutex.
3. If in the meantime parent process will spawn it can be spawned withprint_mutexlocked. If in the child process it will doigt_info()it will deadlock.We should reinitialize
print_mutexin child process to avoid use inherited value.
Quoted 6 lines
Quoted 3 lines
Signed-off-by Zbigniew Kempczyński <[email protected]>Cc Petri Latvala <[email protected]>---
Are you able to type up a unit test in
lib/tests/that reproduces this deadlock?
I've attached patch which exposes the deadlock. Unfortunately I don't think the test which produces thousands of log lines is much usable in the future. In the patch I intentionally increased critical section time to 1 second to spot the problem. In my opinion patch I've sent yesterday should work and I don't know should we add additional test to verify this scenario in the future.
--
Zbigniew
From 998d15a647091c5db0ddee8ad52804cbbff2bd7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20Kempczy=C5=84ski?=
<[email protected]>
Date: Tue, 29 Sep 2020 09:43:14 +0200
Subject: [PATCH i-g-t] lib/igt_core: Expose deadlock in igt logging
Just for expose.
--- lib/igt_core.c | 13 +++++++-- tests/Makefile.sources | 1 + tests/core_logging.c | 66 ++++++++++++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 4 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 tests/core_logging.c
lib/igt_core.c +11 -2
@@ -2271,8 +2271,12 @@ static void children_exit_handler(int sig) ; } +static pthread_mutex_t print_mutex =PTHREAD_MUTEX_INITIALIZER ; +bool __igt_fork (void ) { +int ret; +internal_assert (!test_with_subtests || in_subtest,"forking is only allowed in subtests or igt_simple_main\n" ); internal_assert(!test_child,
@@ -2300,6 +2304,11 @@ bool __igt_fork(void)igt_assert (0 );case 0 : test_child = true; +/* Below fixes issue */ +//pthread_mutex_init(&print_mutex, NULL); + ret =pthread_mutex_trylock (&print_mutex); +internal_assert (ret ==0 ,"Mutex was locked during fork\n" ); +pthread_mutex_unlock (&print_mutex); exit_handler_count =0 ;reset_helper_process_list ();oom_adjust_for_doom ();
@@ -2737,8 +2746,6 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format, "NONE" }; -static pthread_mutex_t print_mutex =PTHREAD_MUTEX_INITIALIZER ; -assert (format);#ifdef __GLIBC__
@@ -2816,6 +2823,8 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format,fwrite (line,sizeof (char ),strlen (line), file); } +/* Extend critical section time */ +sleep (1 );pthread_mutex_unlock (&print_mutex); out:
tests/Makefile.sources +1 -0
@@ -19,6 +19,7 @@ TESTS_progs = \ core_getstats \ core_getversion \ core_hotunplug \ + core_logging \ core_setmaster \ core_setmaster_vs_auth \ debugfs_test \
tests/core_logging.c new file +66 -0
66 lines not on this page · raw message
tests/meson.build +1 -0
@@ -4,6 +4,7 @@ test_progs = [ 'core_getstats', 'core_getversion', 'core_hotunplug', + 'core_logging', 'core_setmaster', 'core_setmaster_vs_auth', 'debugfs_test',
Signature · 1 line
2.26.0
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoted 22 lines · Zbigniew Kempczyński
Quoted 14 lines · Petri Latvala
Quoted 13 lines · Zbigniew Kempczyński
IGT are prone to deadlock in
igt_log()in following scenario:1. Parent process creates additional thread which for example is doing endless loop
2. Thread sometimes is logging to console usingigt_info(). This locks and unlocksprint_mutex.
3. If in the meantime parent process will spawn it can be spawned withprint_mutexlocked. If in the child process it will doigt_info()it will deadlock.We should reinitialize
print_mutexin child process to avoid use inherited value.Quoted 6 lines
Quoted 3 lines
Signed-off-by Zbigniew Kempczyński <[email protected]>Cc Petri Latvala <[email protected]>---
Are you able to type up a unit test in
lib/tests/that reproduces this deadlock?
Quoted 6 lines
I've attached patch which exposes the deadlock. Unfortunately I don't think the test which produces thousands of log lines is much usable in the future. In the patch I intentionally increased critical section time to 1 second to spot the problem. In my opinion patch I've sent yesterday should work and I don't know should we add additional test to verify this scenario in the future.
No no, I meant _lib_/tests/. tests/ contains tests that check whether kernel works correctly, lib/tests/ contains tests that check whether IGT infrastructure works correctly.
The structure of the tests in lib/tests can be a bit awkward since you need to do a lot of the test framework stuff manually, but there should be plenty of examples.
Signature · 1 line
Petri Latvala
Quoted 166 lines
--
ZbigniewFrom
998d15a647091c5db0ddee8ad52804cbbff2bd7fMon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20Kempczy=C5=84ski?=
<[email protected]>
Date: Tue, 29 Sep 2020 09:43:14 +0200
Subject: [PATCH i-g-t]lib/igt_core: Expose deadlock in igt loggingJust for expose.
--- lib/igt_core.c | 13 +++++++-- tests/Makefile.sources | 1 + tests/core_logging.c | 66 ++++++++++++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 4 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 tests/core_logging.clib/igt_core.c +11
-2@@ -2271,8 +2271,12 @@ static void children_exit_handler(int sig) ; } +static pthread_mutex_t print_mutex =PTHREAD_MUTEX_INITIALIZER ; +bool __igt_fork (void ) { +int ret; +internal_assert (!test_with_subtests || in_subtest,"forking is only allowed in subtests or igt_simple_main\n" ); internal_assert(!test_child,@@ -2300,6 +2304,11 @@ bool __igt_fork(void)igt_assert (0 );case 0 : test_child = true; +/* Below fixes issue */ +//pthread_mutex_init(&print_mutex, NULL); + ret =pthread_mutex_trylock (&print_mutex); +internal_assert (ret ==0 ,"Mutex was locked during fork\n" ); +pthread_mutex_unlock (&print_mutex); exit_handler_count =0 ;reset_helper_process_list ();oom_adjust_for_doom ();@@ -2737,8 +2746,6 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format, "NONE" }; -static pthread_mutex_t print_mutex =PTHREAD_MUTEX_INITIALIZER ; -assert (format);#ifdef __GLIBC__@@ -2816,6 +2823,8 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format,fwrite (line,sizeof (char ),strlen (line), file); } +/* Extend critical section time */ +sleep (1 );pthread_mutex_unlock (&print_mutex); out:tests/Makefile.sources +1
-0@@ -19,6 +19,7 @@ TESTS_progs = \ core_getstats \ core_getversion \ core_hotunplug \ + core_logging \ core_setmaster \ core_setmaster_vs_auth \ debugfs_test \tests/core_logging.c new file +66
-0@@ -0,0 +1,66 @@ +/* +* Copyright © 2020 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +* +*/ + +#include "igt.h" +#include <pthread.h> +#include <string.h> +#include <sys/ioctl.h> + +IGT_TEST_DESCRIPTION ("Tests is IGT logging prone to deadlock" ); + +#define TIMEOUT 10 + +static void *thread_loop (void *data) +{ +int cnt =0 ; + +igt_until_timeout (TIMEOUT ) { +igt_info ("... %d\n" , cnt++); + } + +return NULL ; +} + +static void test_deadlock (void ) +{ +pthread_t thread; + +pthread_create (&thread,NULL , thread_loop,NULL ); + +igt_until_timeout (TIMEOUT ) { + igt_fork(child, 1) { +igt_info ("child [%d]\n" ,getpid ()); + } +//igt_waitchildren_timeout(1, "deadlock found"); +igt_waitchildren (); + } + +pthread_join (thread,NULL ); +} + +igt_main +{ + igt_subtest("test-deadlock") +test_deadlock (); +}tests/meson.build +1
-0@@ -4,6 +4,7 @@ test_progs = [ 'core_getstats', 'core_getversion', 'core_hotunplug', + 'core_logging', 'core_setmaster', 'core_setmaster_vs_auth', 'debugfs_test',Signature · 1 line
2.26.0
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoted 30 lines · Petri Latvala
Quoted 22 lines · Zbigniew Kempczyński
Quoted 14 lines · Petri Latvala
Quoted 13 lines · Zbigniew Kempczyński
IGT are prone to deadlock in
igt_log()in following scenario:1. Parent process creates additional thread which for example is doing endless loop
2. Thread sometimes is logging to console usingigt_info(). This locks and unlocksprint_mutex.
3. If in the meantime parent process will spawn it can be spawned withprint_mutexlocked. If in the child process it will doigt_info()it will deadlock.We should reinitialize
print_mutexin child process to avoid use inherited value.Quoted 6 lines
Quoted 3 lines
Signed-off-by Zbigniew Kempczyński <[email protected]>Cc Petri Latvala <[email protected]>---
Are you able to type up a unit test in
lib/tests/that reproduces this deadlock?Quoted 6 lines
I've attached patch which exposes the deadlock. Unfortunately I don't think the test which produces thousands of log lines is much usable in the future. In the patch I intentionally increased critical section time to 1 second to spot the problem. In my opinion patch I've sent yesterday should work and I don't know should we add additional test to verify this scenario in the future.
Quoted 8 lines
No no, I meant _lib_/tests/. tests/ contains tests that check whether kernel works correctly,
lib/tests/contains tests that check whether IGT infrastructure works correctly.The structure of the tests in lib/tests can be a bit awkward since you need to do a lot of the test framework stuff manually, but there should be plenty of examples.
I don't have currently much time to work on test version you likely expect. I think we know what's the root cause of not proper IGT logging behavior in multithreading/multiprocessing environmant and fix is quite obvious. I don't think we need test which will test that lock verification. Especially to reproduce I have to do atomic bomb of igt_info() which completely dominate in output and produces have thousaunds of lines before deadlock occurs.
Anyway, I needed such logging during my development so in final version of patches they will disappear. So decision of incorporation of my fix or not I left to you.
--
Zbigniew
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Petri Latvala
Reviewed-byQuoted 48 lines · Zbigniew Kempczyński
Quoted 30 lines · Petri Latvala
Quoted 22 lines · Zbigniew Kempczyński
Quoted 14 lines · Petri Latvala
Quoted 13 lines · Zbigniew Kempczyński
IGT are prone to deadlock in
igt_log()in following scenario:1. Parent process creates additional thread which for example is doing endless loop
2. Thread sometimes is logging to console usingigt_info(). This locks and unlocksprint_mutex.
3. If in the meantime parent process will spawn it can be spawned withprint_mutexlocked. If in the child process it will doigt_info()it will deadlock.We should reinitialize
print_mutexin child process to avoid use inherited value.Quoted 6 lines
Quoted 3 lines
Signed-off-by Zbigniew Kempczyński <[email protected]>Cc Petri Latvala <[email protected]>---
Are you able to type up a unit test in
lib/tests/that reproduces this deadlock?Quoted 6 lines
I've attached patch which exposes the deadlock. Unfortunately I don't think the test which produces thousands of log lines is much usable in the future. In the patch I intentionally increased critical section time to 1 second to spot the problem. In my opinion patch I've sent yesterday should work and I don't know should we add additional test to verify this scenario in the future.
Quoted 8 lines
No no, I meant _lib_/tests/. tests/ contains tests that check whether kernel works correctly,
lib/tests/contains tests that check whether IGT infrastructure works correctly.The structure of the tests in lib/tests can be a bit awkward since you need to do a lot of the test framework stuff manually, but there should be plenty of examples.
I don't have currently much time to work on test version you likely expect. I think we know what's the root cause of not proper IGT logging behavior in multithreading/multiprocessing environmant and fix is quite obvious. I don't think we need test which will test that lock verification. Especially to reproduce I have to do atomic bomb of
igt_info()which completely dominate in output and produces have thousaunds of lines before deadlock occurs.
Quoted 3 lines
Anyway, I needed such logging during my development so in final version of patches they will disappear. So decision of incorporation of my fix or not I left to you.
Yeah, fair enough.
Do you have a version without the spurious whitespace changes? Slap a
on it.
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.BUILD: failure for lib/igt_core: Reinitialize print mutex in child process (rev2)
In reply to Zbigniew Kempczyński== Series Details ==
== Series Details ==
Series: lib/igt_core: Reinitialize print mutex in child process (rev2)
URL : https://patchwork.freedesktop.org/series/82154/
State : failure
== Summary ==
Applying: lib/igt_core: Reinitialize print mutex in child process Patch failed at 0001 lib/igt_core: Reinitialize print mutex in child process When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev