Reland "[Jobs API]: Use worker_lock in JobTaskSource."
This is a reland of 6eb566d2 Reason for revert: Cause failure in CheckedLockImpl::Acquire crbug.com/1099649 Mark worker_released_condition_ declare_only_used_while_idle to prevent priority queue from being acquired in ScopedBlockingCall. Original change's description: > [Jobs API]: Use worker_lock in JobTaskSource. > > Possible race when Join(): > - thread A: Join: worker_released_condition_->Wait() > - thread C: WillRunTask: > GetMaxConcurrency() returns > 0 > - thread B: already running, finishes all the work > GetMaxConcurrency() goes 0 > - thread B: DidProcessTask: > worker_released_condition_->Signal(), > - thread A: Join returns (GetMaxConcurrency() is 0) > - thread C: TryIncrementWorkerCountFromWorkerRelease > worker count goes 1 > - thread C: runs worker_task after Join > > To fix race when Joining, all writes to |state_| are protected by > |worker_lock|. Memory ordering is no longer necessary. > > Alternative: cancel before Join returns with a compare and swap and > loop again if new workers. > > Change-Id: I4e478ffae2bdaec56386739f78de089d0e74e42c > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2248159 > Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org> > Reviewed-by: Gabriel Charette <gab@chromium.org> > Cr-Commit-Position: refs/heads/master@{#781453} Change-Id: I1c7c0054a52b9b12dd6d0edd049ab2a7912df361 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2272942 Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org> Reviewed-by:Gabriel Charette <gab@chromium.org> Cr-Commit-Position: refs/heads/master@{#789526}
Showing
This diff is collapsed.
Please register or sign in to comment