[all-commits] [llvm/llvm-project] 1e45cd: [OpenMP][host runtime] Fix indirect lock table rac...

Jonathan Peyton via All-commits all-commits at lists.llvm.org
Mon Sep 20 11:02:18 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1e45cd75dfb1df61892c1a26654c8997d8aeef66
      https://github.com/llvm/llvm-project/commit/1e45cd75dfb1df61892c1a26654c8997d8aeef66
  Author: Peyton, Jonathan L <jonathan.l.peyton at intel.com>
  Date:   2021-09-20 (Mon, 20 Sep 2021)

  Changed paths:
    M openmp/runtime/src/kmp_lock.cpp
    M openmp/runtime/src/kmp_lock.h

  Log Message:
  -----------
  [OpenMP][host runtime] Fix indirect lock table race condition

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 preallocated 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. The indices stored in the user's locks take this
linked structure into account when finding the lock within the table.

Differential Revision: https://reviews.llvm.org/D109725




More information about the All-commits mailing list