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

Unified Diff: base/trace_event/process_memory_dump.cc

Issue 2923123004: [memory-infra] Add API to ProcessMemoryDump to create ownership edges for base::SharedMemory (Closed)
Patch Set: fixes. Created 3 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 side-by-side diff with in-line comments
Download patch
Index: base/trace_event/process_memory_dump.cc
diff --git a/base/trace_event/process_memory_dump.cc b/base/trace_event/process_memory_dump.cc
index cb8d5fa768424e1b52024c28efd532bcd49c8d1a..7acb2118a9ec870c18762a5d13916dceba8448b9 100644
--- a/base/trace_event/process_memory_dump.cc
+++ b/base/trace_event/process_memory_dump.cc
@@ -9,6 +9,7 @@
#include <vector>
#include "base/memory/ptr_util.h"
+#include "base/memory/shared_memory_tracker.h"
#include "base/process/process_metrics.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/heap_profiler_heap_dump_writer.h"
@@ -16,6 +17,7 @@
#include "base/trace_event/memory_infra_background_whitelist.h"
#include "base/trace_event/process_memory_totals.h"
#include "base/trace_event/trace_event_argument.h"
+#include "base/unguessable_token.h"
#include "build/build_config.h"
#if defined(OS_IOS)
@@ -382,6 +384,69 @@ void ProcessMemoryDump::AddOverridableOwnershipEdge(
}
}
+void ProcessMemoryDump::CreateSharedMemoryOwnershipEdge(
+ const MemoryAllocatorDumpGuid& client_local_dump_guid,
+ const MemoryAllocatorDumpGuid& client_global_dump_guid,
+ const UnguessableToken& shared_memory_guid,
+ int importance) {
+ CreateSharedMemoryOwnershipEdgeInternal(
+ client_local_dump_guid, client_global_dump_guid, shared_memory_guid,
+ importance, false /*is_weak*/);
+}
+
+void ProcessMemoryDump::CreateWeakSharedMemoryOwnershipEdge(
+ const MemoryAllocatorDumpGuid& client_local_dump_guid,
+ const MemoryAllocatorDumpGuid& client_global_dump_guid,
+ const UnguessableToken& shared_memory_guid,
+ int importance) {
+ CreateSharedMemoryOwnershipEdgeInternal(
+ client_local_dump_guid, client_global_dump_guid, shared_memory_guid,
+ importance, true /*is_weak*/);
+}
+
+void ProcessMemoryDump::CreateSharedMemoryOwnershipEdgeInternal(
+ const MemoryAllocatorDumpGuid& client_local_dump_guid,
+ const MemoryAllocatorDumpGuid& client_global_dump_guid,
+ const UnguessableToken& shared_memory_guid,
+ int importance,
+ bool is_weak) {
+ if (MemoryAllocatorDumpGuid::UseSharedMemoryBasedGUIDs()) {
+ DCHECK(!shared_memory_guid.is_empty());
+ // New model where the global dumps created by SharedMemoryTracker are used
+ // for the clients.
+
+ // The guid of the local dump cretaed by SharedMemoryTracker for the memory
dcheng 2017/06/08 19:28:30 Nit: created (same typo below)
ssid 2017/06/08 19:43:16 Done.
+ // segment.
+ auto local_shm_guid =
+ SharedMemoryTracker::GetDumpGUIDForTracing(shared_memory_guid);
+
+ // The dump guid of the global dump cretaed by the tracker for the memory
+ // segment.
+ auto global_shm_guid =
+ SharedMemoryTracker::GetGlobalDumpGUIDForTracing(shared_memory_guid);
+
+ // Create an edge between local dump of the client and the local dump of the
+ // SharedMemoryTracker. Do not need to create the dumps here since the
+ // tracker would create them.
+ AddOwnershipEdge(client_local_dump_guid, local_shm_guid);
+
+ // TODO(ssid): Handle the case of weak dumps here. This needs a new function
+ // GetOrCreaetGlobalDump() in PMD since we need to change the behavior of
+ // the created global dump.
+ // Create an edge that overrides the edge created by SharedMemoryTracker.
+ AddOwnershipEdge(local_shm_guid, global_shm_guid, importance);
+ } else {
+ // This is the old model where the clients create global dumps for
+ // themselves.
+ if (is_weak)
+ CreateWeakSharedGlobalAllocatorDump(client_global_dump_guid);
+ else
+ CreateSharedGlobalAllocatorDump(client_global_dump_guid);
+ AddOwnershipEdge(client_local_dump_guid, client_global_dump_guid,
+ importance);
+ }
+}
+
void ProcessMemoryDump::AddSuballocation(const MemoryAllocatorDumpGuid& source,
const std::string& target_node_name) {
// Do not create new dumps for suballocations in background mode.

Powered by Google App Engine
This is Rietveld 408576698