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

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: nits. 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 023deea8b539527285e24ebbfe12ede0a7710b48..34f583c1de2022c19ed50a2e5355808f9fbb22cb 100644
--- a/base/trace_event/process_memory_dump.cc
+++ b/base/trace_event/process_memory_dump.cc
@@ -9,12 +9,14 @@
#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"
#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)
@@ -353,6 +355,16 @@ void ProcessMemoryDump::AddOwnershipEdge(
AddOwnershipEdge(source, target, 0 /* importance */);
}
+void ProcessMemoryDump::CreateSharedMemoryOwnershipEdge(
+ const MemoryAllocatorDumpGuid& client_local_dump_guid,
+ const MemoryAllocatorDumpGuid& client_global_dump_guid,
+ const UnguessableToken& shared_memory_guid,
+ int importance) {
+ CreateWeakSharedMemoryOwnershipEdge(
+ client_local_dump_guid, client_global_dump_guid, shared_memory_guid,
+ importance, false /*is_weak*/);
+}
+
void ProcessMemoryDump::AddOverridableOwnershipEdge(
const MemoryAllocatorDumpGuid& source,
const MemoryAllocatorDumpGuid& target,
@@ -368,6 +380,47 @@ void ProcessMemoryDump::AddOverridableOwnershipEdge(
}
}
+void ProcessMemoryDump::CreateWeakSharedMemoryOwnershipEdge(
+ 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() &&
+ !shared_memory_guid.is_empty()) {
+ // New model where the global dumps created by SharedMemoryTracker are used
+ // for the clients.
+
hajimehoshi 2017/06/07 04:58:04 First I thought CreateSharedGlobalAllocatorDump sh
ssid 2017/06/08 00:05:58 Added extra comment. That is exactly what the todo
+ // The guid of the local dump cretaed by
+ // SharedMemoryTracker for the memory 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.
+ 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.
« base/trace_event/process_memory_dump.h ('K') | « base/trace_event/process_memory_dump.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698