[igt-dev] [PATCH i-g-t] lib/igt_core: Reinitialize print mutex in child process

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Sep 29 07:53:05 UTC 2020


On Mon, Sep 28, 2020 at 06:29:20PM +0300, Petri Latvala wrote:
> On Mon, Sep 28, 2020 at 03:15:02PM +0200, Zbigniew Kempczyński wrote:
> > 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.
> > 
> > Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> > Cc: Petri Latvala <petri.latvala at intel.com>
> > ---
> 
> 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lib-igt_core-Expose-deadlock-in-igt-logging.patch
Type: text/x-diff
Size: 4578 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/igt-dev/attachments/20200929/4fcf2611/attachment.patch>


More information about the igt-dev mailing list