Merge "ftrace: Add oom_score_adj_update"
diff --git a/src/profiling/memory/bookkeeping.h b/src/profiling/memory/bookkeeping.h
index 2ec1491..755329b 100644
--- a/src/profiling/memory/bookkeeping.h
+++ b/src/profiling/memory/bookkeeping.h
@@ -243,8 +243,6 @@
// method receives messages on the input_queue and does the bookkeeping.
class BookkeepingThread {
public:
- BookkeepingThread(std::string file_name) : file_name_(file_name) {}
-
void Run(BoundedQueue<BookkeepingRecord>* input_queue);
// Inform the bookkeeping thread that a socket for this pid connected.
@@ -266,7 +264,6 @@
std::map<pid_t, BookkeepingData> bookkeeping_data_;
std::mutex bookkeeping_mutex_;
- std::string file_name_;
};
} // namespace profiling
diff --git a/src/profiling/memory/client.cc b/src/profiling/memory/client.cc
index b802156..d019af9 100644
--- a/src/profiling/memory/client.cc
+++ b/src/profiling/memory/client.cc
@@ -227,7 +227,7 @@
}
PERFETTO_DCHECK(client_config_.interval >= 1);
PERFETTO_DLOG("Initialized client.");
- inited_ = true;
+ inited_.store(true, std::memory_order_release);
}
Client::Client(const std::string& sock_name, size_t conns)
@@ -259,7 +259,7 @@
void Client::RecordMalloc(uint64_t alloc_size,
uint64_t total_size,
uint64_t alloc_address) {
- if (!inited_)
+ if (!inited_.load(std::memory_order_acquire))
return;
AllocMetadata metadata;
const char* stackbase = GetStackBase();
@@ -294,7 +294,7 @@
}
void Client::RecordFree(uint64_t alloc_address) {
- if (!inited_)
+ if (!inited_.load(std::memory_order_acquire))
return;
free_page_.Add(alloc_address, ++sequence_number_, &socket_pool_);
}
@@ -302,7 +302,7 @@
size_t Client::ShouldSampleAlloc(uint64_t alloc_size,
void* (*unhooked_malloc)(size_t),
void (*unhooked_free)(void*)) {
- if (!inited_)
+ if (!inited_.load(std::memory_order_acquire))
return false;
return SampleSize(pthread_key_.get(), alloc_size, client_config_.interval,
unhooked_malloc, unhooked_free);
@@ -320,7 +320,7 @@
void Client::Shutdown() {
socket_pool_.Shutdown();
- inited_ = false;
+ inited_.store(false, std::memory_order_release);
}
} // namespace profiling
diff --git a/src/profiling/memory/client.h b/src/profiling/memory/client.h
index 3b6fe45..a32a2a3 100644
--- a/src/profiling/memory/client.h
+++ b/src/profiling/memory/client.h
@@ -150,7 +150,7 @@
void (*unhooked_free)(void*));
const char* GetStackBase();
- bool inited_ = false;
+ std::atomic<bool> inited_{false};
ClientConfiguration client_config_;
PThreadKey pthread_key_;
SocketPool socket_pool_;
diff --git a/src/profiling/memory/heapprofd_integrationtest.cc b/src/profiling/memory/heapprofd_integrationtest.cc
index bb361ed..05faaae 100644
--- a/src/profiling/memory/heapprofd_integrationtest.cc
+++ b/src/profiling/memory/heapprofd_integrationtest.cc
@@ -56,7 +56,7 @@
TEST_F(HeapprofdIntegrationTest, MAYBE_EndToEnd) {
GlobalCallstackTrie callsites;
// TODO(fmayer): Actually test the dump.
- BookkeepingThread bookkeeping_thread("");
+ BookkeepingThread bookkeeping_thread;
base::TestTaskRunner task_runner;
auto done = task_runner.CreateCheckpoint("done");
@@ -97,7 +97,7 @@
TEST_F(HeapprofdIntegrationTest, MAYBE_MultiSession) {
GlobalCallstackTrie callsites;
// TODO(fmayer): Actually test the dump.
- BookkeepingThread bookkeeping_thread("");
+ BookkeepingThread bookkeeping_thread;
base::TestTaskRunner task_runner;
auto done = task_runner.CreateCheckpoint("done");
diff --git a/src/profiling/memory/heapprofd_producer.cc b/src/profiling/memory/heapprofd_producer.cc
index 693eafc..5ab9015 100644
--- a/src/profiling/memory/heapprofd_producer.cc
+++ b/src/profiling/memory/heapprofd_producer.cc
@@ -35,7 +35,6 @@
constexpr size_t kUnwinderQueueSize = 1000;
constexpr size_t kBookkeepingQueueSize = 1000;
constexpr size_t kUnwinderThreads = 5;
-constexpr const char* kDumpOutput = "/data/misc/perfetto-traces/heap_dump";
constexpr int kHeapprofdSignal = 36;
constexpr uint32_t kInitialConnectionBackoffMs = 100;
@@ -155,7 +154,6 @@
HeapprofdProducer::HeapprofdProducer(base::TaskRunner* task_runner)
: task_runner_(task_runner),
bookkeeping_queue_(kBookkeepingQueueSize),
- bookkeeping_thread_(kDumpOutput),
bookkeeping_th_([this] { bookkeeping_thread_.Run(&bookkeeping_queue_); }),
unwinder_queues_(MakeUnwinderQueues(kUnwinderThreads)),
unwinding_threads_(MakeUnwindingThreads(kUnwinderThreads)),
diff --git a/src/profiling/memory/socket_listener_unittest.cc b/src/profiling/memory/socket_listener_unittest.cc
index 21d9caf..1484570 100644
--- a/src/profiling/memory/socket_listener_unittest.cc
+++ b/src/profiling/memory/socket_listener_unittest.cc
@@ -54,8 +54,8 @@
callback_called();
};
- BookkeepingThread actor("");
- SocketListener listener(std::move(callback_fn), &actor);
+ BookkeepingThread bookkeeping_thread;
+ SocketListener listener(std::move(callback_fn), &bookkeeping_thread);
auto handle = listener.ExpectPID(getpid(), {});
MockEventListener client_listener;
EXPECT_CALL(client_listener, OnConnect(_, _))