probe_producer: Post metadata to helper sources
ftrace_reader needs a way to signal to the inode/ps metadata sources
with vectors of intresting inodes/pids. It should signal only data
sources which belong to the same tracing session. These sources may not
exist. Rather than keeping many parallel maps up to date and having
lookups in the fast path instead everytime a new datasource is created
we do a pass though all the ftrace datasources and try to set weak
pointers on them leading to the corresponding inode/ps datasources.
Then when we see metadata we post task to relevent datasource via the
weak pointer.
Bug: 73873362
Bug: 73625715
Bug: 73625480
Change-Id: I8371067f0e948733ed8d321479031deaa4ca7db9
diff --git a/src/traced/probes/filesystem/inode_file_data_source.cc b/src/traced/probes/filesystem/inode_file_data_source.cc
index 78b5bae..0bdf781 100644
--- a/src/traced/probes/filesystem/inode_file_data_source.cc
+++ b/src/traced/probes/filesystem/inode_file_data_source.cc
@@ -74,9 +74,13 @@
}
InodeFileDataSource::InodeFileDataSource(
+ TracingSessionID id,
std::map<BlockDeviceID, std::map<Inode, InodeMapValue>>* file_system_inodes,
std::unique_ptr<TraceWriter> writer)
- : file_system_inodes_(file_system_inodes), writer_(std::move(writer)) {}
+ : session_id_(id),
+ file_system_inodes_(file_system_inodes),
+ writer_(std::move(writer)),
+ weak_factory_(this) {}
void InodeFileDataSource::WriteInodes(
const std::vector<std::pair<uint64_t, uint32_t>>& inodes) {
@@ -124,4 +128,13 @@
}
}
+base::WeakPtr<InodeFileDataSource> InodeFileDataSource::GetWeakPtr() const {
+ return weak_factory_.GetWeakPtr();
+}
+
+void InodeFileDataSource::OnInodes(
+ const std::vector<std::pair<uint64_t, uint32_t>>& inodes) {
+ PERFETTO_DLOG("Saw FtraceBundle with %zu inodes.", inodes.size());
+}
+
} // namespace perfetto