[Openmp-commits] [PATCH] D109725: [OpenMP][host runtime] Fix indirect lock table race condition
Jonathan Peyton via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Mon Sep 13 14:42:08 PDT 2021
jlpeyton created this revision.
jlpeyton added reviewers: hbae, AndreyChurbanov, JonChesterfield, ronlieb.
jlpeyton added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
jlpeyton requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
The indirect lock table can exhibit a race condition during initializing and setting/unsetting locks.
This occurs if the lock table is resized by one thread (during an `omp_init_lock`) and accessed (during an
`omp_set|unset_lock`) by another thread.
The test `runtime/test/lock/omp_init_lock.c` test exposed this issue and
will fail if run enough times.
This patch restructures the lock table so pointer/iterator validity is
always kept. Instead of reallocating a single table to a larger size, the
lock table begins pre-allocated to accommodate 8K locks. Each row of the
table is allocated as needed with each row allowing 1K locks. If the 8K
limit is reached for the initial table, then another table, capable of
holding double the number of locks, is allocated and linked
as the next table. This double+linking process continues as needed. The indices
stored in the user's lock take this linked structure into account when
finding the lock within the table later on.
rG LLVM Github Monorepo
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 9382 bytes
Desc: not available
More information about the Openmp-commits