-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Allow Mod of Perf Attributes #2129
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,7 +135,7 @@ static std::vector<uint64_t> GetPMUTypesForEvent(const perf_event_attr& attr) { | |
| } | ||
|
|
||
| PerfCounters PerfCounters::Create( | ||
| const std::vector<std::string>& counter_names) { | ||
| const std::vector<std::string>& counter_names, bool inherit) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. boolean parameters are notoriously hard to track as the callsite becomes opaque : https://abseil.io/tips/94 |
||
| if (!counter_names.empty()) { | ||
| Initialize(); | ||
| } | ||
|
|
@@ -202,8 +202,9 @@ PerfCounters PerfCounters::Create( | |
| // Note: the man page for perf_event_create suggests inherit = true and | ||
| // read_format = PERF_FORMAT_GROUP don't work together, but that's not the | ||
| // case. | ||
|
|
||
| attr.disabled = is_first; | ||
| attr.inherit = true; | ||
| attr.inherit = inherit; | ||
| attr.pinned = is_first; | ||
| attr.exclude_kernel = true; | ||
| attr.exclude_user = false; | ||
|
|
@@ -311,20 +312,21 @@ bool PerfCounters::Initialize() { return false; } | |
| bool PerfCounters::IsCounterSupported(const std::string&) { return false; } | ||
|
|
||
| PerfCounters PerfCounters::Create( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think this would be clearer as two methods: Create and CreateInherited (or whatever naming you land on) |
||
| const std::vector<std::string>& counter_names) { | ||
| const std::vector<std::string>& counter_names, bool inherit) { | ||
| if (!counter_names.empty()) { | ||
| GetErrorLogInstance() << "Performance counters not supported.\n"; | ||
| } | ||
| (void)inherit; // This just tells the compiler to ignore the variable | ||
| return NoCounters(); | ||
| } | ||
|
|
||
| void PerfCounters::CloseCounters() const {} | ||
| #endif // defined HAVE_LIBPFM | ||
|
|
||
| PerfCountersMeasurement::PerfCountersMeasurement( | ||
| const std::vector<std::string>& counter_names) | ||
| const std::vector<std::string>& counter_names, bool inherit) | ||
| : start_values_(counter_names.size()), end_values_(counter_names.size()) { | ||
| counters_ = PerfCounters::Create(counter_names); | ||
| counters_ = PerfCounters::Create(counter_names, inherit); | ||
| } | ||
|
|
||
| PerfCounters& PerfCounters::operator=(PerfCounters&& other) noexcept { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the AI generated comment please