From 9fc6b27a067879eea6eb966448ac298348f622f0 Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Wed, 20 Nov 2019 14:51:57 +0000 Subject: Properly sample calloc calls. We were ignoring the nmemb argument. This is a cherry pick of 55c239f395408a89867e7d74b10a59377b9d8832. Bug: 141567111 Change-Id: I58b4d25bde0b4a17762ae28556abca683786db96 Merged-In: I58b4d25bde0b4a17762ae28556abca683786db96 --- src/profiling/memory/malloc_hooks.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/profiling/memory/malloc_hooks.cc b/src/profiling/memory/malloc_hooks.cc index 387fd842d..904c6c198 100644 --- a/src/profiling/memory/malloc_hooks.cc +++ b/src/profiling/memory/malloc_hooks.cc @@ -467,7 +467,7 @@ void* HEAPPROFD_ADD_PREFIX(_malloc)(size_t size) { void* HEAPPROFD_ADD_PREFIX(_calloc)(size_t nmemb, size_t size) { const MallocDispatch* dispatch = GetDispatch(); void* addr = dispatch->calloc(nmemb, size); - MaybeSampleAllocation(size, addr); + MaybeSampleAllocation(nmemb * size, addr); return addr; } -- cgit v1.2.3 From 618afdc057b897383c3ca16b68cc4e8b9a4c7ed0 Mon Sep 17 00:00:00 2001 From: Hector Dearman Date: Tue, 7 Jan 2020 16:42:52 +0000 Subject: Fix CtsStatsdHostTestCases.AnomalyDetectionTests#testPerfetto Test: reboot then adb shell perfetto --dropbox -c :test Bug: 144826002 Change-Id: I8ab9f317c43919dfe976204f5a0ef3cb61dfc438 Merged-In: Ie1bcb144a8e93312475ecc515a9beb63e59acc60 --- perfetto.rc | 4 ++++ src/perfetto_cmd/rate_limiter.cc | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/perfetto.rc b/perfetto.rc index 8d077131e..a33bd036d 100644 --- a/perfetto.rc +++ b/perfetto.rc @@ -62,3 +62,7 @@ on property:persist.traced.enable=1 on property:persist.traced.enable=0 stop traced stop traced_probes + +# Reset the Perfetto guard rail state on boot: +on post-fs-data + rm /data/misc/perfetto-traces/.guardraildata diff --git a/src/perfetto_cmd/rate_limiter.cc b/src/perfetto_cmd/rate_limiter.cc index 3b018bc54..56f34c417 100644 --- a/src/perfetto_cmd/rate_limiter.cc +++ b/src/perfetto_cmd/rate_limiter.cc @@ -106,7 +106,8 @@ bool RateLimiter::ShouldTrace(const Args& args) { } // If we've uploaded in the last 5mins we shouldn't trace now. - if ((now_in_s - state_.last_trace_timestamp()) < kCooldownInSeconds) { + if (state_.last_trace_timestamp() != 0 && + (now_in_s - state_.last_trace_timestamp()) < kCooldownInSeconds) { PERFETTO_ELOG("Guardrail: Uploaded to DropBox in the last 5mins."); if (!args.ignore_guardrails) return false; -- cgit v1.2.3 From 7696e800b89ca053010aeace2a8e6eae659a4104 Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Fri, 8 Nov 2019 17:21:28 +0000 Subject: Do not block on control socket. This is a cherry-pick of 906e06987f66cfbd46cdd586a15b0072b2fbed19 Test: $ tools/heap_profile -i 1 --no-block-client -n system_server does not slow down phone Test: $ tools/heap_profile -n system_server produces profile Bug: 143934224 Change-Id: Iff8cad6f3dfbcf2f29a17b4e871996a43181dfea Merged-In: Iff8cad6f3dfbcf2f29a17b4e871996a43181dfea --- src/profiling/memory/client.cc | 13 ++++++------- src/profiling/memory/unwinding.cc | 4 +--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/profiling/memory/client.cc b/src/profiling/memory/client.cc index 59c7e20d5..37453d13d 100644 --- a/src/profiling/memory/client.cc +++ b/src/profiling/memory/client.cc @@ -202,10 +202,7 @@ std::shared_ptr Client::CreateAndHandshake( } PERFETTO_DCHECK(client_config.interval >= 1); - // TODO(fmayer): Always make this nonblocking. - // This is so that without block_client, we get the old behaviour that rate - // limits using the blocking socket. We do not want to change that for Q. - sock.SetBlocking(!client_config.block_client); + sock.SetBlocking(false); Sampler sampler{client_config.interval}; // note: the shared_ptr will retain a copy of the unhooked_allocator return std::allocate_shared(unhooked_allocator, std::move(sock), @@ -368,10 +365,12 @@ bool Client::IsConnected() { } bool Client::SendControlSocketByte() { - // TODO(fmayer): Fix the special casing that only block_client uses a - // nonblocking socket. + // If base::IsAgain(errno), the socket buffer is full, so the service will + // pick up the notification even without adding another byte. + // In other error cases (usually EPIPE) we want to disconnect, because that + // is how the service signals the tracing session was torn down. if (sock_.Send(kSingleByte, sizeof(kSingleByte)) == -1 && - (!client_config_.block_client || !base::IsAgain(errno))) { + !base::IsAgain(errno)) { PERFETTO_PLOG("Failed to send control socket byte."); return false; } diff --git a/src/profiling/memory/unwinding.cc b/src/profiling/memory/unwinding.cc index cc79477b7..31b9a9c96 100644 --- a/src/profiling/memory/unwinding.cc +++ b/src/profiling/memory/unwinding.cc @@ -314,9 +314,7 @@ void UnwindingWorker::HandleUnwindBatch(pid_t peer_pid) { shmem.EndRead(std::move(buf)); // Reparsing takes time, so process the rest in a new batch to avoid timing // out. - // TODO(fmayer): Do not special case blocking mode. - if (client_data.client_config.block_client && - reparses_before < client_data.metadata.reparses) { + if (reparses_before < client_data.metadata.reparses) { repost_task = true; break; } -- cgit v1.2.3