|
|
Chromium Code Reviews
DescriptionMove postGC out of CrossThreadPersistentRegion::LockScope
Some finalizers/prefinalizers acquire locks, causing a dead lock when CrossThreadPersistent tries to acquire the CrossThreadPersistentRegion lock.
This CL moves the postGC step outside of the CrossThreadPersistentRegion::LockScope. This should be okay as the CrossThreadPersistentRegion::LockScope only exists to avoid add/deletetion of CrossThreadPersistentNodes during marking.
BUG=684856, 685624, 685624
Review-Url: https://codereview.chromium.org/2686533003
Cr-Commit-Position: refs/heads/master@{#450251}
Committed: https://chromium.googlesource.com/chromium/src/+/52b19c8f68c222c08944af937a01f3ff7e46705c
Patch Set 1 #Patch Set 2 : fix #Patch Set 3 : fix #Patch Set 4 : fix #Patch Set 5 : fix #Patch Set 6 : fix #Patch Set 7 : fix #
Total comments: 2
Patch Set 8 : fix #
Messages
Total messages: 47 (36 generated)
The CQ bit was checked by keishi@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by keishi@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== Move postGC BUG= ========== to ========== Move postGC out of CrossThreadPersistentRegion::LockScope Some finalizers/prefinalizers acquire locks, causing a dead lock when CrossThreadPersistent tries to acquire the CrossThreadPersistentRegion lock. This CL moves the postGC step outside of the CrossThreadPersistentRegion::LockScope. This should be okay as the CrossThreadPersistentRegion::LockScope only exists to avoid add/deletetion of CrossThreadPersistentNodes during marking. BUG= ==========
Description was changed from ========== Move postGC out of CrossThreadPersistentRegion::LockScope Some finalizers/prefinalizers acquire locks, causing a dead lock when CrossThreadPersistent tries to acquire the CrossThreadPersistentRegion lock. This CL moves the postGC step outside of the CrossThreadPersistentRegion::LockScope. This should be okay as the CrossThreadPersistentRegion::LockScope only exists to avoid add/deletetion of CrossThreadPersistentNodes during marking. BUG= ========== to ========== Move postGC out of CrossThreadPersistentRegion::LockScope Some finalizers/prefinalizers acquire locks, causing a dead lock when CrossThreadPersistent tries to acquire the CrossThreadPersistentRegion lock. This CL moves the postGC step outside of the CrossThreadPersistentRegion::LockScope. This should be okay as the CrossThreadPersistentRegion::LockScope only exists to avoid add/deletetion of CrossThreadPersistentNodes during marking. BUG=684856 ==========
Description was changed from ========== Move postGC out of CrossThreadPersistentRegion::LockScope Some finalizers/prefinalizers acquire locks, causing a dead lock when CrossThreadPersistent tries to acquire the CrossThreadPersistentRegion lock. This CL moves the postGC step outside of the CrossThreadPersistentRegion::LockScope. This should be okay as the CrossThreadPersistentRegion::LockScope only exists to avoid add/deletetion of CrossThreadPersistentNodes during marking. BUG=684856 ========== to ========== Move postGC out of CrossThreadPersistentRegion::LockScope Some finalizers/prefinalizers acquire locks, causing a dead lock when CrossThreadPersistent tries to acquire the CrossThreadPersistentRegion lock. This CL moves the postGC step outside of the CrossThreadPersistentRegion::LockScope. This should be okay as the CrossThreadPersistentRegion::LockScope only exists to avoid add/deletetion of CrossThreadPersistentNodes during marking. BUG=684856,685624,685624 ==========
keishi@chromium.org changed reviewers: + haraken@chromium.org, oilpan-reviews@chromium.org
I tried removing the lock from the AudioNode prefinalizer, but I think the way it works, it is impossible. We definitely need to hold the lock while marking but, I think we can move the entire postGC step out of the CrossThreadPersistentRegion::LockScope.
On 2017/02/09 04:34:21, keishi wrote: > I tried removing the lock from the AudioNode prefinalizer, but I think the way > it works, it is impossible. > > We definitely need to hold the lock while marking but, I think we can move the > entire postGC step out of the CrossThreadPersistentRegion::LockScope. Maybe you're correct. However, for safety (for making the mental model simpler), I want to keep threadLocalWeakProcessing() in the lock scope. Can you split postGC() into the following two parts? - postGC(): Calls prepareForSweep and threadLocalWeakProcessing - preSweep(): Calls invokePreFinalizers, eagerSweep etc And hold the lock during postGC() but not during preSweep(). > This should be okay as the CrossThreadPersistentRegion::LockScope only exists to avoid add/deletetion of CrossThreadPersistentNodes during marking. Remember that the lock scope is also needed to make GCs on two threads mutually exclusive.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
On 2017/02/09 04:47:51, haraken wrote: > On 2017/02/09 04:34:21, keishi wrote: > > I tried removing the lock from the AudioNode prefinalizer, but I think the way > > it works, it is impossible. > > > > We definitely need to hold the lock while marking but, I think we can move the > > entire postGC step out of the CrossThreadPersistentRegion::LockScope. > > Maybe you're correct. > > However, for safety (for making the mental model simpler), I want to keep > threadLocalWeakProcessing() in the lock scope. > > Can you split postGC() into the following two parts? > > - postGC(): Calls prepareForSweep and threadLocalWeakProcessing > - preSweep(): Calls invokePreFinalizers, eagerSweep etc > > And hold the lock during postGC() but not during preSweep(). > > > This should be okay as the CrossThreadPersistentRegion::LockScope only exists > to avoid add/deletetion of CrossThreadPersistentNodes during marking. > > Remember that the lock scope is also needed to make GCs on two threads mutually > exclusive. I'd like to understand why & where having that exclusion matters. But given this and https://codereview.chromium.org/2660463003/ , I wonder if there should be a separate CTPs-being-locked-during-a-GC lock.
On 2017/02/09 06:46:01, sof wrote: > On 2017/02/09 04:47:51, haraken wrote: > > On 2017/02/09 04:34:21, keishi wrote: > > > I tried removing the lock from the AudioNode prefinalizer, but I think the > way > > > it works, it is impossible. > > > > > > We definitely need to hold the lock while marking but, I think we can move > the > > > entire postGC step out of the CrossThreadPersistentRegion::LockScope. > > > > Maybe you're correct. > > > > However, for safety (for making the mental model simpler), I want to keep > > threadLocalWeakProcessing() in the lock scope. > > > > Can you split postGC() into the following two parts? > > > > - postGC(): Calls prepareForSweep and threadLocalWeakProcessing > > - preSweep(): Calls invokePreFinalizers, eagerSweep etc > > > > And hold the lock during postGC() but not during preSweep(). > > > > > This should be okay as the CrossThreadPersistentRegion::LockScope only > exists > > to avoid add/deletetion of CrossThreadPersistentNodes during marking. > > > > Remember that the lock scope is also needed to make GCs on two threads > mutually > > exclusive. > > I'd like to understand why & where having that exclusion matters. > > But given this and https://codereview.chromium.org/2660463003/ , I wonder if > there should be a separate CTPs-being-locked-during-a-GC lock. I'm confused. CrossThreadPersistentRegion::m_mutex is a recursive mutex. Why can it cause a dead lock?
On 2017/02/09 07:15:11, haraken wrote: > On 2017/02/09 06:46:01, sof wrote: > > On 2017/02/09 04:47:51, haraken wrote: > > > On 2017/02/09 04:34:21, keishi wrote: > > > > I tried removing the lock from the AudioNode prefinalizer, but I think the > > way > > > > it works, it is impossible. > > > > > > > > We definitely need to hold the lock while marking but, I think we can move > > the > > > > entire postGC step out of the CrossThreadPersistentRegion::LockScope. > > > > > > Maybe you're correct. > > > > > > However, for safety (for making the mental model simpler), I want to keep > > > threadLocalWeakProcessing() in the lock scope. > > > > > > Can you split postGC() into the following two parts? > > > > > > - postGC(): Calls prepareForSweep and threadLocalWeakProcessing > > > - preSweep(): Calls invokePreFinalizers, eagerSweep etc > > > > > > And hold the lock during postGC() but not during preSweep(). > > > > > > > This should be okay as the CrossThreadPersistentRegion::LockScope only > > exists > > > to avoid add/deletetion of CrossThreadPersistentNodes during marking. > > > > > > Remember that the lock scope is also needed to make GCs on two threads > > mutually > > > exclusive. > > > > I'd like to understand why & where having that exclusion matters. > > > > But given this and https://codereview.chromium.org/2660463003/ , I wonder if > > there should be a separate CTPs-being-locked-during-a-GC lock. > > I'm confused. CrossThreadPersistentRegion::m_mutex is a recursive mutex. Why can > it cause a dead lock? It can't, this wasn't a question on safety. I was just wondering if we can avoid contention on lock-taking between threads assigning CTPs -- those thread operations will have to be locked out while a GC runs, but should ideally otherwise be allowed to concurrently happen. But upon further thought, there doesn't seem to be a way to improve on having that current global lock. Back the first issue above, why is this lock also needed to enforce exclusion on GCs between threads?
On 2017/02/09 07:25:16, sof wrote: > On 2017/02/09 07:15:11, haraken wrote: > > On 2017/02/09 06:46:01, sof wrote: > > > On 2017/02/09 04:47:51, haraken wrote: > > > > On 2017/02/09 04:34:21, keishi wrote: > > > > > I tried removing the lock from the AudioNode prefinalizer, but I think > the > > > way > > > > > it works, it is impossible. > > > > > > > > > > We definitely need to hold the lock while marking but, I think we can > move > > > the > > > > > entire postGC step out of the CrossThreadPersistentRegion::LockScope. > > > > > > > > Maybe you're correct. > > > > > > > > However, for safety (for making the mental model simpler), I want to keep > > > > threadLocalWeakProcessing() in the lock scope. > > > > > > > > Can you split postGC() into the following two parts? > > > > > > > > - postGC(): Calls prepareForSweep and threadLocalWeakProcessing > > > > - preSweep(): Calls invokePreFinalizers, eagerSweep etc > > > > > > > > And hold the lock during postGC() but not during preSweep(). > > > > > > > > > This should be okay as the CrossThreadPersistentRegion::LockScope only > > > exists > > > > to avoid add/deletetion of CrossThreadPersistentNodes during marking. > > > > > > > > Remember that the lock scope is also needed to make GCs on two threads > > > mutually > > > > exclusive. > > > > > > I'd like to understand why & where having that exclusion matters. > > > > > > But given this and https://codereview.chromium.org/2660463003/ , I wonder if > > > there should be a separate CTPs-being-locked-during-a-GC lock. > > > > I'm confused. CrossThreadPersistentRegion::m_mutex is a recursive mutex. Why > can > > it cause a dead lock? > > It can't, this wasn't a question on safety. I was just wondering if we can avoid > contention on lock-taking between threads assigning CTPs -- those thread > operations will have to be locked out while a GC runs, but should ideally > otherwise be allowed to concurrently happen. But upon further thought, there > doesn't seem to be a way to improve on having that current global lock. > > Back the first issue above, why is this lock also needed to enforce exclusion on > GCs between threads? Yeah, agreed. Now that the heap is completely isolated per thread, there will be no reason to make GCs between threads exclusive.
The CQ bit was checked by keishi@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: ios-device on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device/builds...) ios-simulator on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/bui...) ios-simulator-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator-xco...)
The CQ bit was checked by keishi@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_...)
The CQ bit was checked by keishi@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: cast_shell_linux on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/cast_shell_linu...)
The CQ bit was checked by keishi@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: ios-device on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device/builds...) ios-device-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device-xcode-...) ios-simulator on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/bui...)
The CQ bit was checked by keishi@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
On 2017/02/09 04:47:51, haraken wrote: > On 2017/02/09 04:34:21, keishi wrote: > > I tried removing the lock from the AudioNode prefinalizer, but I think the way > > it works, it is impossible. > > > > We definitely need to hold the lock while marking but, I think we can move the > > entire postGC step out of the CrossThreadPersistentRegion::LockScope. > > Maybe you're correct. > > However, for safety (for making the mental model simpler), I want to keep > threadLocalWeakProcessing() in the lock scope. > > Can you split postGC() into the following two parts? > > - postGC(): Calls prepareForSweep and threadLocalWeakProcessing > - preSweep(): Calls invokePreFinalizers, eagerSweep etc > > And hold the lock during postGC() but not during preSweep(). Done. PTAL
LGTM https://codereview.chromium.org/2686533003/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/heap/ThreadState.h (right): https://codereview.chromium.org/2686533003/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/heap/ThreadState.h:230: // pre-finalization, eager sweeping and heap compaction. Update this comment.
https://codereview.chromium.org/2686533003/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/heap/ThreadState.h (right): https://codereview.chromium.org/2686533003/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/heap/ThreadState.h:230: // pre-finalization, eager sweeping and heap compaction. On 2017/02/13 16:56:24, haraken wrote: > > Update this comment. Done.
The CQ bit was checked by keishi@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from haraken@chromium.org Link to the patchset: https://codereview.chromium.org/2686533003/#ps140001 (title: "fix")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 140001, "attempt_start_ts": 1487035557359240,
"parent_rev": "4c6747c1032af89b54e32d268439add818cbe37b", "commit_rev":
"52b19c8f68c222c08944af937a01f3ff7e46705c"}
Message was sent while issue was closed.
Description was changed from ========== Move postGC out of CrossThreadPersistentRegion::LockScope Some finalizers/prefinalizers acquire locks, causing a dead lock when CrossThreadPersistent tries to acquire the CrossThreadPersistentRegion lock. This CL moves the postGC step outside of the CrossThreadPersistentRegion::LockScope. This should be okay as the CrossThreadPersistentRegion::LockScope only exists to avoid add/deletetion of CrossThreadPersistentNodes during marking. BUG=684856,685624,685624 ========== to ========== Move postGC out of CrossThreadPersistentRegion::LockScope Some finalizers/prefinalizers acquire locks, causing a dead lock when CrossThreadPersistent tries to acquire the CrossThreadPersistentRegion lock. This CL moves the postGC step outside of the CrossThreadPersistentRegion::LockScope. This should be okay as the CrossThreadPersistentRegion::LockScope only exists to avoid add/deletetion of CrossThreadPersistentNodes during marking. BUG=684856,685624,685624 Review-Url: https://codereview.chromium.org/2686533003 Cr-Commit-Position: refs/heads/master@{#450251} Committed: https://chromium.googlesource.com/chromium/src/+/52b19c8f68c222c08944af937a01... ==========
Message was sent while issue was closed.
Committed patchset #8 (id:140001) as https://chromium.googlesource.com/chromium/src/+/52b19c8f68c222c08944af937a01... |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
