From c03ba81608806023871e9d7272b10d959af2e7f4 Mon Sep 17 00:00:00 2001 From: Heinrich Zhou Date: Tue, 2 Jul 2024 14:54:10 +0800 Subject: [PATCH 1/2] add option for perf event attr inherit --- collectors/perf.cpp | 8 ++++++-- collectors/perf.hpp | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/collectors/perf.cpp b/collectors/perf.cpp index 8ec552d..aaef865 100644 --- a/collectors/perf.cpp +++ b/collectors/perf.cpp @@ -82,9 +82,12 @@ static inline uint64_t makeup_booker_ci_config(int nodetype, int eventid, int by PerfCollector::PerfCollector(const Json::Value& config, const std::string& name) : Collector(config, name) { struct event leader = {"CPUCycleCount", PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES}; - mEvents.push_back(leader); mSet = mConfig.get("set", -1).asInt(); + mInherit = mConfig.get("inherit", 1).asInt(); + + leader.inherited = mInherit; + mEvents.push_back(leader); if ((0 <= mSet) && (mSet <= 3)) { @@ -114,6 +117,7 @@ PerfCollector::PerfCollector(const Json::Value& config, const std::string& name) e.booker_ci = item.get("booker-ci", 0).asInt(); e.cspmu = item.get("CSPMU", 0).asInt(); e.device = item.get("device", "").asString(); + e.inherited = mInherit; if (e.booker_ci) { // booker-ci counter @@ -213,7 +217,7 @@ static int add_event(const struct event &e, int tid, int cpu, int group = -1) pe.config = e.config; pe.config1 = (e.len == hw_cnt_length::b32) ? 0 : 1; pe.disabled = 1; - pe.inherit = 1; + pe.inherit = e.inherited; pe.exclude_user = e.exc_user; pe.exclude_kernel = e.exc_kernel; pe.exclude_hv = 0; diff --git a/collectors/perf.hpp b/collectors/perf.hpp index 8474e24..4c0f753 100644 --- a/collectors/perf.hpp +++ b/collectors/perf.hpp @@ -50,6 +50,7 @@ struct event { bool booker_ci; // default is false bool cspmu; std::string device; // default is "" + uint32_t inherited; }; class event_context @@ -107,6 +108,7 @@ class PerfCollector : public Collector private: int mSet = -1; + int mInherit = 1; bool mAllThread = true; std::vector mEvents; std::vector mBookerEvents; From f3106dc03d3b473869147007bdd0e7619ebc2c2b Mon Sep 17 00:00:00 2001 From: Heinrich Zhou Date: Tue, 2 Jul 2024 15:48:24 +0800 Subject: [PATCH 2/2] add default value for event inherit attribute --- collectors/perf.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collectors/perf.hpp b/collectors/perf.hpp index 4c0f753..121548e 100644 --- a/collectors/perf.hpp +++ b/collectors/perf.hpp @@ -50,7 +50,7 @@ struct event { bool booker_ci; // default is false bool cspmu; std::string device; // default is "" - uint32_t inherited; + uint32_t inherited; // default is 1 }; class event_context