Bug 109442

Summary: "make check" test anv_block_pool_no_free fails intermittently
Product: Mesa Reporter: Ian Romanick <idr>
Component: Drivers/Vulkan/intelAssignee: Intel 3D Bugs Mailing List <intel-3d-bugs>
Status: RESOLVED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: jason
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Ian Romanick 2019-01-23 19:55:57 UTC
When the test fails, it fails with:

block_pool_no_free: src/intel/vulkan/tests/block_pool_no_free.c:65: alloc_blocks: Assertion `*data == block' failed.

Sometimes I have to run it 5 or 8 times in a row to get it to fail.

I ran in valgrind (with --trace-children=yes), and it only produced a bunch of warnings about "invalid file descriptor -1 in syscall close()".  I don't think that's related.
Comment 1 Rafael Antognolli 2019-01-25 01:44:03 UTC
Should be fixed with this:

commit f2ece26601adda221ce5ae69c984f8b79a9cb0d0
Author: Rafael Antognolli <rafael.antognolli@intel.com>
Date:   Wed Jan 23 12:36:39 2019 -0800

    anv/allocator: Avoid race condition in anv_block_pool_map.
Comment 2 Denis 2019-02-07 12:57:40 UTC
From what I see, issue was really fixed and ticket can be closed. Below my test results:
______________________________________________________________________
c1efa240c91e78385e8e433af134289b006016d0 - commit exactly before fix:
______________________________________________________________________

den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
Segmentation fault (core dumped)
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
block_pool_no_free: ../src/intel/vulkan/tests/block_pool_no_free.c:65: alloc_blocks: Assertion `*data == block' failed.
Aborted (core dumped)
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
block_pool_no_free: ../src/intel/vulkan/tests/block_pool_no_free.c:65: alloc_blocks: Assertion `*data == block' failed.
Aborted (core dumped)
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
block_pool_no_free: ../src/intel/vulkan/tests/block_pool_no_free.c:65: alloc_blocks: Assertion `*data == block' failed.
Aborted (core dumped)
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
block_pool_no_free: ../src/intel/vulkan/tests/block_pool_no_free.c:65: alloc_blocks: Assertion `*data == block' failed.
Aborted (core dumped)
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
block_pool_no_free: ../src/intel/vulkan/tests/block_pool_no_free.c:69: alloc_blocks: Assertion `*data == block' failed.
Aborted (core dumped)
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
block_pool_no_free: ../src/intel/vulkan/tests/block_pool_no_free.c:65: alloc_blocks: Assertion `*data == block' failed.
Aborted (core dumped)
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
block_pool_no_free: ../src/intel/vulkan/tests/block_pool_no_free.c:69: alloc_blocks: Assertion `*data == block' failed.
Aborted (core dumped)
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64_1/src/intel/vulkan$ ./block_pool_no_free
block_pool_no_free: ../src/intel/vulkan/tests/block_pool_no_free.c:65: alloc_blocks: Assertion `*data == block' failed.
Aborted (core dumped)


___________________________________________________________
latest commit from git master (included specified commit)
___________________________________________________________

den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
den@den-HP-ZBook-14u-G4:~/repositories/mesa/mbuild_v64/src/intel/vulkan$ ./block_pool_no_free
Comment 3 Jason Ekstrand 2019-02-07 15:35:34 UTC
Yup, It was fixed by

commit f2ece26601adda221ce5ae69c984f8b79a9cb0d0
Author: Rafael Antognolli <rafael.antognolli@intel.com>
Date:   Wed Jan 23 12:36:39 2019 -0800

    anv/allocator: Avoid race condition in anv_block_pool_map.
    
    Accessing bo->map and then pool->center_bo_offset without a lock is
    racy. One way of avoiding such race condition is to store the bo->map +
    center_bo_offset into pool->map at the time the block pool is growing,
    which happens within a lock.
    
    v2: Only set pool->map if not using softpin (Jason).
    v3: Move things around and only update center_bo_offset if not using
    softpin too (Jason).
    
    Cc: Jason Ekstrand <jason@jlekstrand.net>
    Reported-by: Ian Romanick <idr@freedesktop.org>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109442
    Fixes: fc3f58832015cbb177179e7f3420d3611479b4a9
    Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>

We just forgot to close the bug.

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.