Skip to content
Merged
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
2 changes: 1 addition & 1 deletion arch/x86/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ void x86_pmu_enable_all(int added)
}
}

static inline int is_x86_event(struct perf_event *event)
int is_x86_event(struct perf_event *event)
Copy link

Copilot AI Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Since is_x86_event returns a boolean-like result, consider changing its return type to bool for clarity and consistency with other predicate functions.

Copilot uses AI. Check for mistakes.
{
int i;

Expand Down
8 changes: 6 additions & 2 deletions arch/x86/events/intel/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -4002,8 +4002,12 @@ static int intel_pmu_hw_config(struct perf_event *event)
x86_pmu.pebs_aliases(event);
}

if (needs_branch_stack(event) && is_sampling_event(event))
event->hw.flags |= PERF_X86_EVENT_NEEDS_BRANCH_STACK;
if (needs_branch_stack(event)) {
/* Avoid branch stack setup for counting events in SAMPLE READ */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Clarify SAMPLE_READ logic in comment

Consider updating the comment to clarify that branch stack setup is skipped only when the event is not a sampling event and PERF_SAMPLE_READ is set.

Suggested change
/* Avoid branch stack setup for counting events in SAMPLE READ */
/* Skip branch stack setup only for non-sampling events with PERF_SAMPLE_READ set */

if (is_sampling_event(event) ||
!(event->attr.sample_type & PERF_SAMPLE_READ))
event->hw.flags |= PERF_X86_EVENT_NEEDS_BRANCH_STACK;
Comment on lines +4008 to +4009
Copy link

Copilot AI Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding braces around the inner if block to improve readability and prevent accidental inclusion of additional statements in future edits.

Suggested change
!(event->attr.sample_type & PERF_SAMPLE_READ))
event->hw.flags |= PERF_X86_EVENT_NEEDS_BRANCH_STACK;
!(event->attr.sample_type & PERF_SAMPLE_READ)) {
event->hw.flags |= PERF_X86_EVENT_NEEDS_BRANCH_STACK;
}

Copilot uses AI. Check for mistakes.
}

if (branch_sample_counters(event)) {
struct perf_event *leader, *sibling;
Expand Down
9 changes: 8 additions & 1 deletion arch/x86/events/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,16 @@ static inline bool is_topdown_event(struct perf_event *event)
return is_metric_event(event) || is_slots_event(event);
}

int is_x86_event(struct perf_event *event);
Copy link

Copilot AI Jun 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a brief comment describing what constitutes an "x86 event" so maintainers understand the criteria without digging into the implementation.

Copilot uses AI. Check for mistakes.

static inline bool check_leader_group(struct perf_event *leader, int flags)
{
return is_x86_event(leader) ? !!(leader->hw.flags & flags) : false;
}

static inline bool is_branch_counters_group(struct perf_event *event)
{
return event->group_leader->hw.flags & PERF_X86_EVENT_BRANCH_COUNTERS;
return check_leader_group(event->group_leader, PERF_X86_EVENT_BRANCH_COUNTERS);
}

struct amd_nb {
Expand Down
Loading