Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option for perf event attr inherit #15

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions collectors/perf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ 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};

if (mConfig.isMember("event"))
{ // inherit counter option for group lead
Json::Value item_leader = mConfig["event"][0];
leader.inherited = item_leader.get("inherit",1).asInt();
}

mEvents.push_back(leader);

mSet = mConfig.get("set", -1).asInt();
Expand All @@ -92,10 +99,10 @@ PerfCollector::PerfCollector(const Json::Value& config, const std::string& name)
for (const struct event& e : EVENTS[mSet])
mEvents.push_back(e);
}
else if (mConfig.isMember("event"))
else if (mConfig.isMember("event_customer"))
{
DBG_LOG("Using customized CPU counter event, this will fail on non-ARM CPU's\n");
Json::Value eventArray = mConfig["event"];
Json::Value eventArray = mConfig["event_customer"];
for (Json::ArrayIndex i = 0; i < eventArray.size(); i++)
{
Json::Value item = eventArray[i];
Expand All @@ -114,6 +121,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 = item.get("inherit",1).asInt();

if (e.booker_ci)
{ // booker-ci counter
Expand Down Expand Up @@ -213,7 +221,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;
Expand Down
1 change: 1 addition & 0 deletions collectors/perf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading