Bug 98532

Summary: [ivb] meta mutex deadlock
Product: Mesa Reporter: Chris Wilson <chris>
Component: Drivers/DRI/i965Assignee: Ian Romanick <idr>
Status: RESOLVED DUPLICATE QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: kenneth
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Chris Wilson 2016-11-01 16:30:59 UTC
Running "piglit run gpu" stalls in a sea of mutex deadlocks on Ivybridge:

#0  __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
#1  0x00007f0ede892bc5 in __GI___pthread_mutex_lock (mutex=0x562520431208) at ../nptl/pthread_mutex_lock.c:80
#2  0x00007f0edd667a73 in mtx_lock (mtx=<optimized out>) at ../../include/c11/threads_posix.h:227
#3  _mesa_lock_context_textures (ctx=ctx@entry=0x7f0ee3a44038) at main/texobj.c:2017
#4  0x00007f0edd634419 in _mesa_update_state (ctx=ctx@entry=0x7f0ee3a44038) at main/state.c:496
#5  0x00007f0edd7771ed in _mesa_meta_pbo_TexSubImage (ctx=ctx@entry=0x7f0ee3a44038, dims=dims@entry=2, tex_image=tex_image@entry=0x562520879350, xoffset=xoffset@entry=0, 
    yoffset=yoffset@entry=0, zoffset=<optimized out>, zoffset@entry=0, width=256, height=256, depth=1, format=6408, type=5121, pixels=0x5625207543f0, create_pbo=true, 
    packing=0x7f0ee3a5f2a8) at drivers/common/meta_tex_subimage.c:269
#6  0x00007f0edd9a163d in intelTexSubImage (ctx=0x7f0ee3a44038, dims=2, texImage=0x562520879350, xoffset=0, yoffset=0, zoffset=0, width=256, height=256, depth=1, format=6408, 
    type=5121, pixels=0x5625207543f0, packing=0x7f0ee3a5f2a8) at intel_tex_subimage.c:202
#7  0x00007f0edd65af0a in _mesa_texture_sub_image (dsa=false, pixels=0x5625207543f0, type=5121, format=6408, depth=1, height=256, width=256, zoffset=0, yoffset=0, 
    xoffset=<optimized out>, level=0, target=34037, texImage=0x562520879350, texObj=0x562520877c50, dims=2, ctx=0x7f0ee3a44038) at main/teximage.c:3239
#8  texsubimage (callerName=0x7f0eddb1d6a1 "glTexSubImage2D", pixels=0x5625207543f0, type=5121, format=6408, depth=1, height=256, width=256, zoffset=0, yoffset=0, xoffset=0, 
    level=0, target=34037, dims=2, ctx=0x7f0ee3a44038) at main/teximage.c:3297
#9  _mesa_TexSubImage2D (target=34037, level=level@entry=0, xoffset=xoffset@entry=0, yoffset=yoffset@entry=0, width=width@entry=256, height=height@entry=256, format=6408, 
    type=5121, pixels=0x5625207543f0) at main/teximage.c:3438
#10 0x00007f0edd77b951 in _mesa_meta_setup_drawpix_texture (ctx=ctx@entry=0x7f0ee3a44038, tex=tex@entry=0x5625206f98d4, newTex=newTex@entry=0 '\000', width=width@entry=256, 
    height=height@entry=256, format=format@entry=6408, type=5121, pixels=0x5625207543f0) at drivers/common/meta.c:1450
#11 0x00007f0edd77c9b3 in _mesa_meta_DrawPixels (ctx=ctx@entry=0x7f0ee3a44038, x=x@entry=0, y=y@entry=0, width=width@entry=256, height=height@entry=256, format=format@entry=6408, 
    type=5121, unpack=0x7f0ee3a5f2a8, pixels=0x5625207543f0) at drivers/common/meta.c:2294
#12 0x00007f0edd99be37 in intelDrawPixels (ctx=0x7f0ee3a44038, x=0, y=0, width=256, height=256, format=6408, type=5121, unpack=0x7f0ee3a5f2a8, pixels=0x5625207543f0)
    at intel_pixel_draw.c:174
#13 0x00007f0edd4ed932 in _mesa_DrawPixels (width=256, height=256, format=6408, type=5121, pixels=0x5625207543f0) at main/drawpix.c:163
#14 0x0000562520203d09 in test_mipmap_copypixels (srcIntFormat=6408, dstIntFormat=6408, doPixelTransfer=0 '\000', useReadDrawPix=1 '\001')
    at /usr/src/piglit/tests/fbo/fbo-mipmap-copypix.c:172
#15 0x00005625202040ad in piglit_display () at /usr/src/piglit/tests/fbo/fbo-mipmap-copypix.c:265
#16 0x00007f0ee35ab18b in run_test (gl_fw=0x562520417c20, argc=1, argv=0x7ffd3f607d98) at /usr/src/piglit/tests/util/piglit-framework-gl/piglit_fbo_framework.c:52
#17 0x00007f0ee35915cc in piglit_gl_test_run (argc=1, argv=0x7ffd3f607d98, config=0x7ffd3f607c60) at /usr/src/piglit/tests/util/piglit-framework-gl.c:203
#18 0x0000562520203860 in main (argc=1, argv=0x7ffd3f607d98) at /usr/src/piglit/tests/fbo/fbo-mipmap-copypix.c:42


Another:

#0  __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
#1  0x00007fcabbab6bc5 in __GI___pthread_mutex_lock (mutex=0x556a56782208) at ../nptl/pthread_mutex_lock.c:80
#2  0x00007fcaba88ba73 in mtx_lock (mtx=<optimized out>) at ../../include/c11/threads_posix.h:227
#3  _mesa_lock_context_textures (ctx=ctx@entry=0x7fcac0c68038) at main/texobj.c:2017
#4  0x00007fcaba858419 in _mesa_update_state (ctx=ctx@entry=0x7fcac0c68038) at main/state.c:496
#5  0x00007fcaba99b64f in _mesa_meta_pbo_GetTexSubImage (ctx=ctx@entry=0x7fcac0c68038, dims=dims@entry=3, tex_image=tex_image@entry=0x556a56a58f10, xoffset=xoffset@entry=0, 
    yoffset=yoffset@entry=0, zoffset=zoffset@entry=0, width=32, height=1, depth=1, format=6408, type=5121, pixels=0x0, packing=0x7fcac0c83270)
    at drivers/common/meta_tex_subimage.c:432
#6  0x00007fcababc44cc in intel_get_tex_sub_image (ctx=0x7fcac0c68038, xoffset=0, yoffset=0, zoffset=0, width=32, height=1, depth=1, format=6408, type=5121, pixels=0x0, 
    texImage=0x556a56a58f10) at intel_tex_image.c:555
#7  0x00007fcaba875a21 in get_texture_image (ctx=ctx@entry=0x7fcac0c68038, texObj=texObj@entry=0x556a56a58ac0, target=target@entry=3552, level=level@entry=0, 
    xoffset=xoffset@entry=0, yoffset=yoffset@entry=0, zoffset=0, width=32, height=1, depth=1, format=6408, type=5121, pixels=0x0, caller=<optimized out>) at main/texgetimage.c:1344
#8  0x00007fcaba877c37 in _mesa_GetTexImage (target=3552, level=0, format=6408, type=5121, pixels=0x0) at main/texgetimage.c:1412
#9  0x00007fcac0756359 in stub_glGetTexImage (target=3552, level=0, format=6408, type=5121, pixels=0x0) at /usr/src/piglit/tests/util/piglit-dispatch-gen.c:26454
#10 0x0000556a56554c0c in getTexImage (doPBO=true, target=3552, data=0x7fff8dce4d50, internalformat=32856, tolerance=0) at /usr/src/piglit/tests/texturing/getteximage-targets.c:196
#11 0x0000556a565550f4 in piglit_init (argc=2, argv=0x7fff8dcf6f28) at /usr/src/piglit/tests/texturing/getteximage-targets.c:318
#12 0x00007fcac07cf16e in run_test (gl_fw=0x556a56768c20, argc=2, argv=0x7fff8dcf6f28) at /usr/src/piglit/tests/util/piglit-framework-gl/piglit_fbo_framework.c:50
#13 0x00007fcac07b55cc in piglit_gl_test_run (argc=2, argv=0x7fff8dcf6f28, config=0x7fff8dcf6df0) at /usr/src/piglit/tests/util/piglit-framework-gl.c:203
#14 0x0000556a56554430 in main (argc=2, argv=0x7fff8dcf6f28) at /usr/src/piglit/tests/texturing/getteximage-targets.c:33
Comment 1 Chris Wilson 2016-11-02 11:01:29 UTC
Very, very strange. Something seems to be wrong with how it is linking to pthreads (or something like that). This "fixes" it:

iff --git a/include/c11/threads_posix.h b/include/c11/threads_posix.h
index 43e803e..ada1ff4 100644
--- a/include/c11/threads_posix.h
+++ b/include/c11/threads_posix.h
@@ -212,10 +212,14 @@ mtx_init(mtx_t *mtx, int type)
         return thrd_success;
     }
 
+#if 0
     pthread_mutexattr_init(&attr);
     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
     pthread_mutex_init(mtx, &attr);
     pthread_mutexattr_destroy(&attr);
+#else
+    *mtx = (pthread_mutex_t)PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+#endif
     return thrd_success;
 }
Comment 2 Kenneth Graunke 2016-11-02 18:47:55 UTC
See https://bugs.freedesktop.org/show_bug.cgi?id=98048
Comment 3 Chris Wilson 2016-11-02 20:27:04 UTC
Indeed, that is the problem I ran into.

*** This bug has been marked as a duplicate of bug 98048 ***

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.