Commit 52448951 authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

Enable new ownership edges for base::SharedMemory

Now mojo is fixed to pass unique IDs across processes, Let's enable new
ownership edges for base::SharedMemory and remove old ownership edges.

Perf sheriffs: If you see sharp bumps in metrics like cc/gpu/discardable/
shared_memory this is very likely the culrprit, please revert it.

Bug: 604726
Change-Id: Iad7bf261f3e2c884d60e935cb2635923de46b2e2
Reviewed-on: https://chromium-review.googlesource.com/557741
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Reviewed-by: default avatarSiddhartha S <ssid@chromium.org>
Reviewed-by: default avatarPrimiano Tucci <primiano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488174}
parent d904bbaa
......@@ -13,7 +13,7 @@ namespace trace_event {
namespace {
bool g_use_shared_memory_guid = false;
bool g_use_shared_memory_guid = true;
uint64_t HashString(const std::string& str) {
uint64_t hash[(kSHA1Length + sizeof(uint64_t) - 1) / sizeof(uint64_t)] = {0};
......@@ -33,11 +33,6 @@ bool MemoryAllocatorDumpGuid::UseSharedMemoryBasedGUIDs() {
return false;
}
// static
void MemoryAllocatorDumpGuid::SetUseSharedMemoryBasedGUIDsForTesting() {
g_use_shared_memory_guid = true;
}
MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid(uint64_t guid) : guid_(guid) {}
MemoryAllocatorDumpGuid::MemoryAllocatorDumpGuid()
......
......@@ -19,7 +19,6 @@ class BASE_EXPORT MemoryAllocatorDumpGuid {
// If the clients of base::SharedMemory should use the global dump guid(s)
// created by SharedMemoryTracker.
static bool UseSharedMemoryBasedGUIDs();
static void SetUseSharedMemoryBasedGUIDsForTesting();
MemoryAllocatorDumpGuid();
explicit MemoryAllocatorDumpGuid(uint64_t guid);
......
......@@ -332,43 +332,12 @@ TEST(ProcessMemoryDumpTest, GlobalAllocatorDumpTest) {
ASSERT_EQ(MemoryAllocatorDump::Flags::DEFAULT, shared_mad1->flags());
}
TEST(ProcessMemoryDumpTest, OldSharedMemoryOwnershipTest) {
TEST(ProcessMemoryDumpTest, SharedMemoryOwnershipTest) {
std::unique_ptr<ProcessMemoryDump> pmd(
new ProcessMemoryDump(nullptr, kDetailedDumpArgs));
const ProcessMemoryDump::AllocatorDumpEdgesMap& edges =
pmd->allocator_dumps_edges_for_testing();
auto* shm_dump1 = pmd->CreateAllocatorDump("shared_mem/seg1");
auto* client_dump1 = pmd->CreateAllocatorDump("discardable/segment1");
MemoryAllocatorDumpGuid client_global_guid1(1);
auto shm_token1 = UnguessableToken::Create();
MemoryAllocatorDumpGuid shm_global_guid1 =
SharedMemoryTracker::GetGlobalDumpIdForTracing(shm_token1);
pmd->AddOverridableOwnershipEdge(shm_dump1->guid(), shm_global_guid1,
0 /* importance */);
pmd->CreateSharedMemoryOwnershipEdge(client_dump1->guid(),
client_global_guid1, shm_token1,
1 /* importance */);
EXPECT_EQ(2u, edges.size());
EXPECT_EQ(shm_global_guid1, edges.find(shm_dump1->guid())->second.target);
EXPECT_EQ(0, edges.find(shm_dump1->guid())->second.importance);
EXPECT_TRUE(edges.find(shm_dump1->guid())->second.overridable);
EXPECT_EQ(client_global_guid1,
edges.find(client_dump1->guid())->second.target);
EXPECT_EQ(1, edges.find(client_dump1->guid())->second.importance);
EXPECT_FALSE(edges.find(client_dump1->guid())->second.overridable);
}
TEST(ProcessMemoryDumpTest, NewSharedMemoryOwnershipTest) {
std::unique_ptr<ProcessMemoryDump> pmd(
new ProcessMemoryDump(nullptr, kDetailedDumpArgs));
const ProcessMemoryDump::AllocatorDumpEdgesMap& edges =
pmd->allocator_dumps_edges_for_testing();
MemoryAllocatorDumpGuid::SetUseSharedMemoryBasedGUIDsForTesting();
auto* client_dump2 = pmd->CreateAllocatorDump("discardable/segment2");
MemoryAllocatorDumpGuid client_global_guid2(2);
auto shm_token2 = UnguessableToken::Create();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment