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

Side by Side Diff: base/trace_event/memory_dump_manager.cc

Issue 2049143002: [memory-infra] Log reasons for memory dump failure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/trace_event/memory_dump_manager.h" 5 #include "base/trace_event/memory_dump_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/atomic_sequence_num.h" 10 #include "base/atomic_sequence_num.h"
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 (*mdp_iter)->disabled = true; 330 (*mdp_iter)->disabled = true;
331 dump_providers_.erase(mdp_iter); 331 dump_providers_.erase(mdp_iter);
332 } 332 }
333 333
334 void MemoryDumpManager::RequestGlobalDump( 334 void MemoryDumpManager::RequestGlobalDump(
335 MemoryDumpType dump_type, 335 MemoryDumpType dump_type,
336 MemoryDumpLevelOfDetail level_of_detail, 336 MemoryDumpLevelOfDetail level_of_detail,
337 const MemoryDumpCallback& callback) { 337 const MemoryDumpCallback& callback) {
338 // Bail out immediately if tracing is not enabled at all. 338 // Bail out immediately if tracing is not enabled at all.
339 if (!UNLIKELY(subtle::NoBarrier_Load(&memory_tracing_enabled_))) { 339 if (!UNLIKELY(subtle::NoBarrier_Load(&memory_tracing_enabled_))) {
340 VLOG(1) << "Global memory dump failed because " << kTraceCategory
Primiano Tucci (use gerrit) 2016/06/08 18:00:45 I'd say s/Global memory dump/memory-infra dump/. I
petrcermak 2016/06/09 09:46:09 Done.
341 << " tracing category is not enabled";
340 if (!callback.is_null()) 342 if (!callback.is_null())
341 callback.Run(0u /* guid */, false /* success */); 343 callback.Run(0u /* guid */, false /* success */);
342 return; 344 return;
343 } 345 }
344 346
345 const uint64_t guid = 347 const uint64_t guid =
346 TraceLog::GetInstance()->MangleEventId(g_next_guid.GetNext()); 348 TraceLog::GetInstance()->MangleEventId(g_next_guid.GetNext());
347 349
348 // Creates an async event to keep track of the global dump evolution. 350 // Creates an async event to keep track of the global dump evolution.
349 // The |wrapped_callback| will generate the ASYNC_END event and then invoke 351 // The |wrapped_callback| will generate the ASYNC_END event and then invoke
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // Initalizes the ThreadLocalEventBuffer to guarantee that the TRACE_EVENTs 417 // Initalizes the ThreadLocalEventBuffer to guarantee that the TRACE_EVENTs
416 // in the PostTask below don't end up registering their own dump providers 418 // in the PostTask below don't end up registering their own dump providers
417 // (for discounting trace memory overhead) while holding the |lock_|. 419 // (for discounting trace memory overhead) while holding the |lock_|.
418 TraceLog::GetInstance()->InitializeThreadLocalEventBufferIfSupported(); 420 TraceLog::GetInstance()->InitializeThreadLocalEventBufferIfSupported();
419 421
420 // |dump_thread_| might be destroyed before getting this point. 422 // |dump_thread_| might be destroyed before getting this point.
421 // It means that tracing was disabled right before starting this dump. 423 // It means that tracing was disabled right before starting this dump.
422 // Anyway either tracing is stopped or this was the last hop, create a trace 424 // Anyway either tracing is stopped or this was the last hop, create a trace
423 // event, add it to the trace and finalize process dump invoking the callback. 425 // event, add it to the trace and finalize process dump invoking the callback.
424 if (!pmd_async_state->dump_thread_task_runner.get()) { 426 if (!pmd_async_state->dump_thread_task_runner.get()) {
427 VLOG(1)
428 << "Global memory dump failed because dump thread was destroyed before "
Primiano Tucci (use gerrit) 2016/06/08 18:00:45 you probably want to make "Global Memory Dump" (or
petrcermak 2016/06/09 09:46:09 Done.
429 << (pmd_async_state->pending_dump_providers.empty()
430 ? "finalizing memory dump"
431 : pmd_async_state->pending_dump_providers.back().get()->name);
425 pmd_async_state->dump_successful = false; 432 pmd_async_state->dump_successful = false;
426 pmd_async_state->pending_dump_providers.clear(); 433 pmd_async_state->pending_dump_providers.clear();
427 } 434 }
428 if (pmd_async_state->pending_dump_providers.empty()) 435 if (pmd_async_state->pending_dump_providers.empty())
429 return FinalizeDumpAndAddToTrace(std::move(pmd_async_state)); 436 return FinalizeDumpAndAddToTrace(std::move(pmd_async_state));
430 437
431 // Read MemoryDumpProviderInfo thread safety considerations in 438 // Read MemoryDumpProviderInfo thread safety considerations in
432 // memory_dump_manager.h when accessing |mdpinfo| fields. 439 // memory_dump_manager.h when accessing |mdpinfo| fields.
433 MemoryDumpProviderInfo* mdpinfo = 440 MemoryDumpProviderInfo* mdpinfo =
434 pmd_async_state->pending_dump_providers.back().get(); 441 pmd_async_state->pending_dump_providers.back().get();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 TRACE_EVENT_PHASE_MEMORY_DUMP, 596 TRACE_EVENT_PHASE_MEMORY_DUMP,
590 TraceLog::GetCategoryGroupEnabled(kTraceCategory), event_name, 597 TraceLog::GetCategoryGroupEnabled(kTraceCategory), event_name,
591 trace_event_internal::kGlobalScope, dump_guid, pid, 598 trace_event_internal::kGlobalScope, dump_guid, pid,
592 kTraceEventNumArgs, kTraceEventArgNames, 599 kTraceEventNumArgs, kTraceEventArgNames,
593 kTraceEventArgTypes, nullptr /* arg_values */, &event_value, 600 kTraceEventArgTypes, nullptr /* arg_values */, &event_value,
594 TRACE_EVENT_FLAG_HAS_ID); 601 TRACE_EVENT_FLAG_HAS_ID);
595 } 602 }
596 603
597 bool tracing_still_enabled; 604 bool tracing_still_enabled;
598 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kTraceCategory, &tracing_still_enabled); 605 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kTraceCategory, &tracing_still_enabled);
599 if (!tracing_still_enabled) 606 if (!tracing_still_enabled) {
600 pmd_async_state->dump_successful = false; 607 pmd_async_state->dump_successful = false;
608 VLOG(1) << "Memory dump failed: Tracing is not enabled any more";
Primiano Tucci (use gerrit) 2016/06/08 18:00:45 I'd say here: tracing disabled before the memory d
petrcermak 2016/06/09 09:46:09 Done.
609 }
601 610
602 if (!pmd_async_state->callback.is_null()) { 611 if (!pmd_async_state->callback.is_null()) {
603 pmd_async_state->callback.Run(dump_guid, pmd_async_state->dump_successful); 612 pmd_async_state->callback.Run(dump_guid, pmd_async_state->dump_successful);
604 pmd_async_state->callback.Reset(); 613 pmd_async_state->callback.Reset();
605 } 614 }
606 615
607 TRACE_EVENT_NESTABLE_ASYNC_END0(kTraceCategory, "ProcessMemoryDump", 616 TRACE_EVENT_NESTABLE_ASYNC_END0(kTraceCategory, "ProcessMemoryDump",
608 TRACE_ID_MANGLE(dump_guid)); 617 TRACE_ID_MANGLE(dump_guid));
609 } 618 }
610 619
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0) 829 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0)
821 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; 830 level_of_detail = MemoryDumpLevelOfDetail::DETAILED;
822 ++periodic_dumps_count_; 831 ++periodic_dumps_count_;
823 832
824 MemoryDumpManager::GetInstance()->RequestGlobalDump( 833 MemoryDumpManager::GetInstance()->RequestGlobalDump(
825 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); 834 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail);
826 } 835 }
827 836
828 } // namespace trace_event 837 } // namespace trace_event
829 } // namespace base 838 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698