diff options
author | Yi Kong <yikong@google.com> | 2020-07-01 15:34:18 +0800 |
---|---|---|
committer | Yi Kong <yikong@google.com> | 2020-07-01 15:38:01 +0800 |
commit | 02272aad484a1de5956acee196051baf5ce4a2ae (patch) | |
tree | e624078df7fe8dab5a216c6f0ed067fdb665b654 /profcollectd | |
parent | 9f471ba03a5d09424fb8410c1e701938ee99a30c (diff) | |
download | extras-02272aad484a1de5956acee196051baf5ce4a2ae.tar.gz |
profcollectd: Accept a tag argument to trace command
This allows us to differentiate the source of trace request.
Bug: 79161490
Test: make
Change-Id: I80229e6d325d6bec986f417c9fa1438f19b1191f
Diffstat (limited to 'profcollectd')
8 files changed, 14 insertions, 13 deletions
diff --git a/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl b/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl index 9b87275a..50898289 100644 --- a/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl +++ b/profcollectd/binder/com/android/server/profcollect/IProfCollectd.aidl @@ -21,6 +21,6 @@ interface IProfCollectd { void ReadConfig(); void ScheduleCollection(); void TerminateCollection(); - void TraceOnce(); + void TraceOnce(@utf8InCpp String tag); void ProcessProfile(); } diff --git a/profcollectd/libprofcollectd/binder_service.cpp b/profcollectd/libprofcollectd/binder_service.cpp index 3f795b7f..92446509 100644 --- a/profcollectd/libprofcollectd/binder_service.cpp +++ b/profcollectd/libprofcollectd/binder_service.cpp @@ -59,8 +59,8 @@ Status ProfcollectdBinder::TerminateCollection() { return HandleIfError([=]() { return Scheduler->TerminateCollection(); }); } -Status ProfcollectdBinder::TraceOnce() { - return HandleIfError([=]() { return Scheduler->TraceOnce(); }); +Status ProfcollectdBinder::TraceOnce(const std::string& tag) { + return HandleIfError([=]() { return Scheduler->TraceOnce(tag); }); } Status ProfcollectdBinder::ProcessProfile() { diff --git a/profcollectd/libprofcollectd/binder_service.h b/profcollectd/libprofcollectd/binder_service.h index fd0626ae..af272085 100644 --- a/profcollectd/libprofcollectd/binder_service.h +++ b/profcollectd/libprofcollectd/binder_service.h @@ -35,7 +35,7 @@ class ProfcollectdBinder : public BinderService<ProfcollectdBinder>, binder::Status ReadConfig() override; binder::Status ScheduleCollection() override; binder::Status TerminateCollection() override; - binder::Status TraceOnce() override; + binder::Status TraceOnce(const std::string& tag) override; binder::Status ProcessProfile() override; protected: diff --git a/profcollectd/libprofcollectd/hwtrace_provider.h b/profcollectd/libprofcollectd/hwtrace_provider.h index 59329dd0..e60a87ff 100644 --- a/profcollectd/libprofcollectd/hwtrace_provider.h +++ b/profcollectd/libprofcollectd/hwtrace_provider.h @@ -33,7 +33,7 @@ class HwtraceProvider { * @param period Length of time to trace in seconds. * @return True if successful. */ - virtual bool Trace(const std::filesystem::path& outputPath, + virtual bool Trace(const std::filesystem::path& outputPath, const std::string& tag, std::chrono::duration<float> samplingPeriod) = 0; /** diff --git a/profcollectd/libprofcollectd/interface.cpp b/profcollectd/libprofcollectd/interface.cpp index 3cf42c9b..20ce4925 100644 --- a/profcollectd/libprofcollectd/interface.cpp +++ b/profcollectd/libprofcollectd/interface.cpp @@ -71,7 +71,7 @@ void TerminateCollection() { } void TraceOnce() { - GetIProfcollectdService()->TraceOnce(); + GetIProfcollectdService()->TraceOnce("manual"); } void Process() { diff --git a/profcollectd/libprofcollectd/scheduler.cpp b/profcollectd/libprofcollectd/scheduler.cpp index 38bf19a4..4c1fa302 100644 --- a/profcollectd/libprofcollectd/scheduler.cpp +++ b/profcollectd/libprofcollectd/scheduler.cpp @@ -86,7 +86,7 @@ bool ClearOnConfigChange(const ProfcollectdScheduler::Config& config) { void PeriodicCollectionWorker(std::future<void> terminationSignal, ProfcollectdScheduler& scheduler, std::chrono::seconds& interval) { do { - scheduler.TraceOnce(); + scheduler.TraceOnce("periodic"); } while ((terminationSignal.wait_for(interval)) == std::future_status::timeout); } @@ -155,9 +155,9 @@ OptError ProfcollectdScheduler::TerminateCollection() { return std::nullopt; } -OptError ProfcollectdScheduler::TraceOnce() { +OptError ProfcollectdScheduler::TraceOnce(const std::string& tag) { const std::lock_guard<std::mutex> lock(mu); - bool success = hwtracer->Trace(config.traceOutputDir, config.samplingPeriod); + bool success = hwtracer->Trace(config.traceOutputDir, tag, config.samplingPeriod); if (!success) { static std::string errmsg = "Trace failed"; return errmsg; diff --git a/profcollectd/libprofcollectd/scheduler.h b/profcollectd/libprofcollectd/scheduler.h index 3325abab..31ffc5fb 100644 --- a/profcollectd/libprofcollectd/scheduler.h +++ b/profcollectd/libprofcollectd/scheduler.h @@ -50,7 +50,7 @@ class ProfcollectdScheduler { OptError ReadConfig(); OptError ScheduleCollection(); OptError TerminateCollection(); - OptError TraceOnce(); + OptError TraceOnce(const std::string& tag); OptError ProcessProfile(); private: diff --git a/profcollectd/libprofcollectd/simpleperf_etm_provider.cpp b/profcollectd/libprofcollectd/simpleperf_etm_provider.cpp index 8882ccd5..0d6491e6 100644 --- a/profcollectd/libprofcollectd/simpleperf_etm_provider.cpp +++ b/profcollectd/libprofcollectd/simpleperf_etm_provider.cpp @@ -49,7 +49,8 @@ namespace fs = std::filesystem; class SimpleperfETMProvider : public HwtraceProvider { public: static bool IsSupported(); - bool Trace(const fs::path& outputPath, std::chrono::duration<float> samplingPeriod) override; + bool Trace(const fs::path& outputPath, const std::string& tag, + std::chrono::duration<float> samplingPeriod) override; bool Process(const fs::path& inputPath, const fs::path& outputPath, const std::string& binaryFilter) override; }; @@ -58,10 +59,10 @@ bool SimpleperfETMProvider::IsSupported() { return simpleperf::etm::HasSupport(); } -bool SimpleperfETMProvider::Trace(const fs::path& outputPath, +bool SimpleperfETMProvider::Trace(const fs::path& outputPath, const std::string& tag, std::chrono::duration<float> samplingPeriod) { const std::string timestamp = GetTimestamp(); - auto outputFile = outputPath / (timestamp + ETM_TRACEFILE_EXTENSION); + auto outputFile = outputPath / (timestamp + "_" + tag + ETM_TRACEFILE_EXTENSION); return simpleperf::etm::Record(outputFile, samplingPeriod); } |