Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2338)

Unified Diff: base/trace_event/memory_dump_manager.cc

Issue 2845633002: memory-infra: Remove is_enabled_ from MDM (Closed)
Patch Set: address comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/trace_event/memory_dump_manager.cc
diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc
index 2e3f36d225b1a5e3ed402b50dac35b8caa67d9ef..822be9281f4251d6534e35feabca143cf72b894f 100644
--- a/base/trace_event/memory_dump_manager.cc
+++ b/base/trace_event/memory_dump_manager.cc
@@ -157,7 +157,6 @@ void MemoryDumpManager::SetInstanceForTesting(MemoryDumpManager* instance) {
MemoryDumpManager::MemoryDumpManager()
: is_coordinator_(false),
- is_enabled_(0),
tracing_process_id_(kInvalidTracingProcessId),
dumper_registrations_ignored_for_testing_(false),
heap_profiling_enabled_(false) {
@@ -404,15 +403,12 @@ void MemoryDumpManager::RequestGlobalDump(
MemoryDumpType dump_type,
MemoryDumpLevelOfDetail level_of_detail,
const GlobalMemoryDumpCallback& callback) {
- // Bail out immediately if tracing is not enabled at all or if the dump mode
- // is not allowed.
- if (!UNLIKELY(subtle::NoBarrier_Load(&is_enabled_)) ||
- !IsDumpModeAllowed(level_of_detail)) {
- VLOG(1) << kLogPrefix << " failed because " << kTraceCategory
- << " tracing category is not enabled or the requested dump mode is "
+ if (!IsDumpModeAllowed(level_of_detail) &&
+ dump_type != MemoryDumpType::SUMMARY_ONLY) {
+ VLOG(1) << kLogPrefix
+ << " failed because the requested dump mode is "
"not allowed by trace config.";
- if (!callback.is_null())
- callback.Run(0u /* guid */, false /* success */);
+ callback.Run(0u /* guid */, false /* success */);
return;
}
ssid 2017/05/04 22:00:22 DCHECK(dump_type != SUMMARY_ONLY || level_of_detai
hjd 2017/05/05 14:54:52 Done.
@@ -498,6 +494,12 @@ void MemoryDumpManager::CreateProcessDump(
{
AutoLock lock(lock_);
+ if (args.level_of_detail == MemoryDumpLevelOfDetail::DETAILED &&
ssid 2017/05/04 22:00:22 Comment here saying: MDM could have been disabled
hjd 2017/05/05 14:54:52 Done.
+ heap_profiling_enabled_ && !session_state_) {
+ callback.Run(args.dump_guid, false /* success */, base::nullopt);
+ return;
+ }
+
pmd_async_state.reset(new ProcessMemoryDumpAsyncState(
args, dump_providers_, session_state_, callback,
GetOrCreateBgTaskRunnerLocked()));
@@ -534,22 +536,6 @@ void MemoryDumpManager::SetupNextMemoryDump(
// (for discounting trace memory overhead) while holding the |lock_|.
TraceLog::GetInstance()->InitializeThreadLocalEventBufferIfSupported();
- // MDM might have been disabled before getting to this point.
- // Anyway either MDM is disabled or this was the last hop, create a trace
- // event, add it to the trace and finalize process dump invoking the callback.
- if (!subtle::NoBarrier_Load(&is_enabled_)) {
- if (pmd_async_state->pending_dump_providers.empty()) {
- VLOG(1) << kLogPrefix << " failed because MemoryDumpManager was disabled"
- << " before finalizing the dump";
- } else {
- VLOG(1) << kLogPrefix << " failed because MemoryDumpManager was disabled"
- << " before dumping "
- << pmd_async_state->pending_dump_providers.back().get()->name;
- }
- pmd_async_state->dump_successful = false;
- pmd_async_state->pending_dump_providers.clear();
- }
-
if (pmd_async_state->pending_dump_providers.empty())
return FinalizeDumpAndAddToTrace(std::move(pmd_async_state));
@@ -809,8 +795,6 @@ void MemoryDumpManager::Enable(
DCHECK(!request_dump_function_.is_null());
session_state_ = session_state;
- subtle::NoBarrier_Store(&is_enabled_, 1);
-
MemoryDumpScheduler::Config periodic_config;
bool peak_detector_configured = false;
for (const auto& trigger : memory_dump_config.triggers) {
@@ -861,15 +845,11 @@ void MemoryDumpManager::Disable() {
// There might be a memory dump in progress while this happens. Therefore,
// ensure that the MDM state which depends on the tracing enabled / disabled
// state is always accessed by the dumping methods holding the |lock_|.
- if (!subtle::NoBarrier_Load(&is_enabled_))
- return;
- subtle::NoBarrier_Store(&is_enabled_, 0);
- {
- AutoLock lock(lock_);
- MemoryDumpScheduler::GetInstance()->Stop();
- MemoryPeakDetector::GetInstance()->TearDown();
- session_state_ = nullptr;
- }
+ AutoLock lock(lock_);
+
+ MemoryDumpScheduler::GetInstance()->Stop();
+ MemoryPeakDetector::GetInstance()->TearDown();
+ session_state_ = nullptr;
}
bool MemoryDumpManager::IsDumpModeAllowed(MemoryDumpLevelOfDetail dump_mode) {

Powered by Google App Engine
This is Rietveld 408576698