Closed Bug 1569458 Opened 5 years ago Closed 5 years ago

Improve Base Profiler mutexes

Categories

(Core :: Gecko Profiler, task, P2)

task

Tracking

()

RESOLVED FIXED
mozilla70
Tracking Status
firefox70 --- fixed

People

(Reporter: mozbugz, Assigned: mozbugz)

References

Details

Attachments

(2 files)

baseprofiler::PSMutex and BlocksRingBuffer::RBMutex are pretty much the same, they could be unified in one class.

Also we should offer features similar to xpcom's Mutex, which can verify that the current thread owns the mutex, and can detect recursive locking.
This should help both our internal implementations, and its use by callers and their callbacks.

BPMutex is a concrete mutex based on MutexImpl, which was previously implemented
twice in both platform.h and BlocksRingBuffer.h.
This combined BPMutex has some DEBUG code (when MOZ_BASE_PROFILER is #defined)
to catch recursive locking, and to assert that the mutex is held (for code that
cannot easily use the "proof of lock" pattern; e.g., going through user-provided
callbacks).

This class needs to be public (because it is used in public headers), but is an
implementation detail, so it is located in a new header
"mozilla/BaseProfilerDetail.h" that will collect mozilla::baseprofiler::detail
code that may be useful to a few files in Base Profiler.

Depends on D38846

This of course checks that the mutex is locked as expected in non-public APIs.
It also checks that user callbacks will not keep readers/writers longer than
they should.

Depends on D39624

Pushed by gsquelart@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3357c0982cc2
Unify Base Profiler mutexes into one class - r=gregtatum
https://hg.mozilla.org/integration/autoland/rev/dee618137651
Use mMutex.AssertCurrentThreadOwns() in BlocksRingBuffer - r=gregtatum
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: