Reland "Reland "[Jobs API]: Use worker_lock in JobTaskSource.""
This is a reland of fb56fbc5 Issue: Trace event under lock cause PostTask and lock inversion. Fix: Move trace event outside of lock (to both callsites of WaitForParticipationOpportunity), this should give us mostly the same information but scope is a bit bigger. See patchset 2 Original change's description: > 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} Change-Id: I0b08ee9fb7efd6b5cfdf9d171f2a280ccbb1fa5d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2309572Reviewed-by:Gabriel Charette <gab@chromium.org> Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org> Cr-Commit-Position: refs/heads/master@{#790489}
Showing
This diff is collapsed.
Please register or sign in to comment