Skip to contentSkip to conversation

Several fixes for group flag and counters-snapshotting

PATCH Applied [email protected] 3 participants 15 messages Apr 24, 2025 – Apr 30, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Several fixes for group flag and counters-snapshotting

From: Kan Liang <[email protected]>

The patch series includes several fixes for the new Intel features.

The first 4 patches are to fix the group flag issue which impacts the branch counters, PEBS counters-snapshotting and ACR.
The V1 can be found at
https://lore.kernel.org/lkml/[email protected]/

The last patch is to fix an issue of counters-snapshotting. The V1 can be found at
https://lore.kernel.org/lkml/[email protected]/

Kan Liang (5):
perf/x86/intel: Only check the group flag for X86 leader perf/x86/intel: Check the X86 leader for pebs_counter_event_group perf/x86/intel: Check the X86 leader for ACR group perf/x86: Optimize the is_x86_event
perf/x86/intel/ds: Fix counter backwards of non-precise events
counters-snapshotting

 arch/x86/events/core.c       | 19 ++++++++++---------
 arch/x86/events/intel/ds.c   | 21 +++++++++++++++++++--
 arch/x86/events/perf_event.h | 14 ++++++++++----
 3 files changed, 39 insertions(+), 15 deletions(-)
Signature · 1 line
2.38.1
#1 lore raw

PATCH v2 1/5 perf/x86/intel: Only check the group flag for X86 leader

From: Kan Liang <[email protected]>

A warning in intel_pmu_lbr_counters_reorder() may be triggered by below perf command.

perf record -e "{cpu-clock,cycles/call-graph="lbr"/}" -- sleep 1

It's because the group is mistakenly treated as a branch counter group.

The hw.flags of the leader are used to determine whether a group is a branch counters group. However, the hw.flags is only available for a hardware event. The field to store the flags is a union type. For a software event, it's a hrtimer. The corresponding bit may be set if the leader is a software event.

For a branch counter group and other groups that have a group flag (e.g., topdown, PEBS counters snapshotting, and ACR), the leader must be a X86 event. Check the X86 event before checking the flag. The patch only fixes the issue for the branch counter group. The following patch will fix the other groups.

There may be an alternative way to fix the issue by moving the hw.flags out of the union type. It should work for now. But it's still possible that the flags will be used by other types of events later. As long as that type of event is used as a leader, a similar issue will be triggered. So the alternative way is dropped.

Fixes 33744916196b ("perf/x86/intel: Support branch counters logging")
---
 arch/x86/events/perf_event.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
arch/x86/events/perf_event.h +8 -2
index 902bc42a6cfe..4fc61a09c30e 100644
@@ -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);
+
+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_PEBS_CNTR);
 }
 
 static inline bool is_pebs_counter_event_group(struct perf_event *event)
@@ -1129,7 +1136,6 @@ static struct perf_pmu_format_hybrid_attr format_attr_hybrid_##_name = {\
 	.pmu_type	= _pmu,						\
 }
 
-int is_x86_event(struct perf_event *event);
 struct pmu *x86_get_pmu(unsigned int cpu);
 extern struct x86_pmu x86_pmu __read_mostly;
 
Signature · 1 line
2.38.1
merge bot Applied
#2 lore raw

[tip: perf/core] perf/x86/intel: Only check the group flag for X86 leader

The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     75aea4b0656ead0facd13d2aae4cb77326e53d2f
Gitweb:        https://git.kernel.org/tip/75aea4b0656ead0facd13d2aae4cb77326e53d2f
Author:        Kan Liang <[email protected]>
AuthorDate:    Thu, 24 Apr 2025 06:47:14 -07:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Fri, 25 Apr 2025 14:55:19 +02:00

perf/x86/intel: Only check the group flag for X86 leader

A warning in intel_pmu_lbr_counters_reorder() may be triggered by below perf command.

perf record -e "{cpu-clock,cycles/call-graph="lbr"/}" -- sleep 1

It's because the group is mistakenly treated as a branch counter group.

The hw.flags of the leader are used to determine whether a group is a branch counters group. However, the hw.flags is only available for a hardware event. The field to store the flags is a union type. For a software event, it's a hrtimer. The corresponding bit may be set if the leader is a software event.

For a branch counter group and other groups that have a group flag (e.g., topdown, PEBS counters snapshotting, and ACR), the leader must be a X86 event. Check the X86 event before checking the flag. The patch only fixes the issue for the branch counter group. The following patch will fix the other groups.

There may be an alternative way to fix the issue by moving the hw.flags out of the union type. It should work for now. But it's still possible that the flags will be used by other types of events later. As long as that type of event is used as a leader, a similar issue will be triggered. So the alternative way is dropped.

---
 arch/x86/events/core.c       |  2 +-
 arch/x86/events/perf_event.h |  9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
arch/x86/events/core.c +1 -1
index 3a4f031..139ad80 100644
@@ -754,7 +754,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)
 {
 	int i;
 
arch/x86/events/perf_event.h +8 -1
index 2c0ce0e..4237c37 100644
@@ -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);
+
+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);
 }
 
 static inline bool is_pebs_counter_event_group(struct perf_event *event)
#3 lore raw

PATCH v2 2/5 perf/x86/intel: Check the X86 leader for pebs_counter_event_group

In reply to [email protected]

From: Kan Liang <[email protected]>

The PEBS counters snapshotting group also requires a group flag in the leader. The leader must be a X86 event.

Fixes e02e9b0374c3 ("perf/x86/intel: Support PEBS counters snapshotting")
---
 arch/x86/events/perf_event.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/perf_event.h +1 -1
index 4fc61a09c30e..fd409d70e568 100644
@@ -124,7 +124,7 @@ static inline bool is_branch_counters_group(struct perf_event *event)
 
 static inline bool is_pebs_counter_event_group(struct perf_event *event)
 {
-	return event->group_leader->hw.flags & PERF_X86_EVENT_PEBS_CNTR;
+	return check_leader_group(event->group_leader, PERF_X86_EVENT_PEBS_CNTR);
 }
 
 static inline bool is_acr_event_group(struct perf_event *event)
Signature · 1 line
2.38.1
merge bot Applied
#4 lore raw

[tip: perf/core] perf/x86/intel: Check the X86 leader for pebs_counter_event_group

The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     e9988ad7b1744991118ac348a804f9395368a284
Gitweb:        https://git.kernel.org/tip/e9988ad7b1744991118ac348a804f9395368a284
Author:        Kan Liang <[email protected]>
AuthorDate:    Thu, 24 Apr 2025 06:47:15 -07:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Fri, 25 Apr 2025 14:55:19 +02:00

perf/x86/intel: Check the X86 leader for pebs_counter_event_group

The PEBS counters snapshotting group also requires a group flag in the leader. The leader must be a X86 event.

Fixes e02e9b0374c3 ("perf/x86/intel: Support PEBS counters snapshotting")
---
 arch/x86/events/perf_event.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/perf_event.h +1 -1
index 4237c37..46d1205 100644
@@ -124,7 +124,7 @@ static inline bool is_branch_counters_group(struct perf_event *event)
 
 static inline bool is_pebs_counter_event_group(struct perf_event *event)
 {
-	return event->group_leader->hw.flags & PERF_X86_EVENT_PEBS_CNTR;
+	return check_leader_group(event->group_leader, PERF_X86_EVENT_PEBS_CNTR);
 }
 
 struct amd_nb {
#5 lore raw

PATCH v2 3/5 perf/x86/intel: Check the X86 leader for ACR group

In reply to [email protected]

From: Kan Liang <[email protected]>

The auto counter reload group also requires a group flag in the leader. The leader must be a X86 event.

---
 arch/x86/events/perf_event.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/perf_event.h +1 -1
index fd409d70e568..bac252ba3da6 100644
@@ -129,7 +129,7 @@ static inline bool is_pebs_counter_event_group(struct perf_event *event)
 
 static inline bool is_acr_event_group(struct perf_event *event)
 {
-	return event->group_leader->hw.flags & PERF_X86_EVENT_ACR;
+	return check_leader_group(event->group_leader, PERF_X86_EVENT_ACR);
 }
 
 struct amd_nb {
Signature · 1 line
2.38.1
merge bot Applied
#6 lore raw

[tip: perf/core] perf/x86/intel: Check the X86 leader for ACR group

The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     efd448540e6243dbdaf0a7e1bcf49734e73f3c93
Gitweb:        https://git.kernel.org/tip/efd448540e6243dbdaf0a7e1bcf49734e73f3c93
Author:        Kan Liang <[email protected]>
AuthorDate:    Thu, 24 Apr 2025 06:47:16 -07:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Fri, 25 Apr 2025 14:55:22 +02:00

perf/x86/intel: Check the X86 leader for ACR group

The auto counter reload group also requires a group flag in the leader. The leader must be a X86 event.

---
 arch/x86/events/perf_event.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/perf_event.h +1 -1
index 9c5cab8..e8bce89 100644
@@ -129,7 +129,7 @@ static inline bool is_pebs_counter_event_group(struct perf_event *event)
 
 static inline bool is_acr_event_group(struct perf_event *event)
 {
-	return event->group_leader->hw.flags & PERF_X86_EVENT_ACR;
+	return check_leader_group(event->group_leader, PERF_X86_EVENT_ACR);
 }
 
 struct amd_nb {
#7 lore raw

PATCH v2 4/5 perf/x86: Optimize the is_x86_event

In reply to [email protected]

From: Kan Liang <[email protected]>

The current is_x86_event has to go through the hybrid_pmus list to find the matched pmu, then check if it's a X86 PMU and a X86 event. It's not necessary.

The X86 PMU has a unique type ID on a non-hybrid machine, and a unique capability type. They are good enough to do the check.

---
 arch/x86/events/core.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
arch/x86/events/core.c +10 -9
index b0ef07d14c83..43053ddd7073 100644
@@ -757,15 +757,16 @@ void x86_pmu_enable_all(int added)
 
 int is_x86_event(struct perf_event *event)
 {
-	int i;
-
-	if (!is_hybrid())
-		return event->pmu == &pmu;
-
-	for (i = 0; i < x86_pmu.num_hybrid_pmus; i++) {
-		if (event->pmu == &x86_pmu.hybrid_pmu[i].pmu)
-			return true;
-	}
+	/*
+	 * For a non-hybrid platforms, the type of X86 pmu is
+	 * always PERF_TYPE_RAW.
+	 * For a hybrid platform, the PERF_PMU_CAP_EXTENDED_HW_TYPE
+	 * is a unique capability for the X86 PMU.
+	 * Use them to detect a X86 event.
+	 */
+	if (event->pmu->type == PERF_TYPE_RAW ||
+	    event->pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE)
+		return true;
 
 	return false;
 }
Signature · 1 line
2.38.1
merge bot Applied
#8 lore raw

[tip: perf/core] perf/x86: Optimize the is_x86_event

The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     3e830f657f69ab6a4822d72ec2f364c6d51beef8
Gitweb:        https://git.kernel.org/tip/3e830f657f69ab6a4822d72ec2f364c6d51beef8
Author:        Kan Liang <[email protected]>
AuthorDate:    Thu, 24 Apr 2025 06:47:17 -07:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Fri, 25 Apr 2025 14:55:22 +02:00

perf/x86: Optimize the is_x86_event

The current is_x86_event has to go through the hybrid_pmus list to find the matched pmu, then check if it's a X86 PMU and a X86 event. It's not necessary.

The X86 PMU has a unique type ID on a non-hybrid machine, and a unique capability type. They are good enough to do the check.

---
 arch/x86/events/core.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
arch/x86/events/core.c +10 -9
index b2762f2..92c3fb6 100644
@@ -762,15 +762,16 @@ void x86_pmu_enable_all(int added)
 
 int is_x86_event(struct perf_event *event)
 {
-	int i;
-
-	if (!is_hybrid())
-		return event->pmu == &pmu;
-
-	for (i = 0; i < x86_pmu.num_hybrid_pmus; i++) {
-		if (event->pmu == &x86_pmu.hybrid_pmu[i].pmu)
-			return true;
-	}
+	/*
+	 * For a non-hybrid platforms, the type of X86 pmu is
+	 * always PERF_TYPE_RAW.
+	 * For a hybrid platform, the PERF_PMU_CAP_EXTENDED_HW_TYPE
+	 * is a unique capability for the X86 PMU.
+	 * Use them to detect a X86 event.
+	 */
+	if (event->pmu->type == PERF_TYPE_RAW ||
+	    event->pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE)
+		return true;
 
 	return false;
 }
#9 lore raw

PATCH v2 5/5 perf/x86/intel/ds: Fix counter backwards of non-precise events counters-snapshotting

In reply to [email protected]

From: Kan Liang <[email protected]>

The counter backwards may be observed in the PMI handler when counters-snapshotting some non-precise events in the freq mode.

For the non-precise events, it's possible the counters-snapshotting records a positive value for an overflowed PEBS event. Then the HW auto-reload mechanism reset the counter to 0 immediately. Because the pebs_event_reset is cleared in the freq mode, which doesn't set the PERF_X86_EVENT_AUTO_RELOAD.
In the PMI handler, 0 will be read rather than the positive value recorded in the counters-snapshotting record.

The counters-snapshotting case has to be specially handled. Since the event value has been updated when processing the counters-snapshotting record, only needs to set the new period for the counter via x86_pmu_set_period().

Fixes e02e9b0374c3 ("perf/x86/intel: Support PEBS counters snapshotting")
---
 arch/x86/events/intel/ds.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
arch/x86/events/intel/ds.c +19 -2
index 486881fe162e..83ffbfdf4982 100644
@@ -2376,8 +2376,25 @@ __intel_pmu_pebs_last_event(struct perf_event *event,
 			 */
 			intel_pmu_save_and_restart_reload(event, count);
 		}
-	} else
-		intel_pmu_save_and_restart(event);
+	} else {
+		/*
+		 * For a non-precise event, it's possible the
+		 * counters-snapshotting records a positive value for the
+		 * overflowed event. Then the HW auto-reload mechanism
+		 * reset the counter to 0 immediately, because the
+		 * pebs_event_reset is cleared if the PERF_X86_EVENT_AUTO_RELOAD
+		 * is not set. The counter backwards may be observed in a
+		 * PMI handler.
+		 *
+		 * Since the event value has been updated when processing the
+		 * counters-snapshotting record, only needs to set the new
+		 * period for the counter.
+		 */
+		if (is_pebs_counter_event_group(event))
+			static_call(x86_pmu_set_period)(event);
+		else
+			intel_pmu_save_and_restart(event);
+	}
 }
 
 static __always_inline void
Signature · 1 line
2.38.1
merge bot Applied
#10 lore raw

[tip: perf/core] perf/x86/intel/ds: Fix counter backwards of non-precise events counters-snapshotting

The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     7da9960b59fb7e590eb8538c9428db55a4ea2d23
Gitweb:        https://git.kernel.org/tip/7da9960b59fb7e590eb8538c9428db55a4ea2d23
Author:        Kan Liang <[email protected]>
AuthorDate:    Thu, 24 Apr 2025 06:47:18 -07:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Fri, 25 Apr 2025 14:55:19 +02:00

perf/x86/intel/ds: Fix counter backwards of non-precise events counters-snapshotting

The counter backwards may be observed in the PMI handler when counters-snapshotting some non-precise events in the freq mode.

For the non-precise events, it's possible the counters-snapshotting records a positive value for an overflowed PEBS event. Then the HW auto-reload mechanism reset the counter to 0 immediately. Because the pebs_event_reset is cleared in the freq mode, which doesn't set the PERF_X86_EVENT_AUTO_RELOAD.
In the PMI handler, 0 will be read rather than the positive value recorded in the counters-snapshotting record.

The counters-snapshotting case has to be specially handled. Since the event value has been updated when processing the counters-snapshotting record, only needs to set the new period for the counter via x86_pmu_set_period().

Fixes e02e9b0374c3 ("perf/x86/intel: Support PEBS counters snapshotting")
---
 arch/x86/events/intel/ds.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
arch/x86/events/intel/ds.c +19 -2
index 18c3ab5..9b20acc 100644
@@ -2379,8 +2379,25 @@ __intel_pmu_pebs_last_event(struct perf_event *event,
 			 */
 			intel_pmu_save_and_restart_reload(event, count);
 		}
-	} else
-		intel_pmu_save_and_restart(event);
+	} else {
+		/*
+		 * For a non-precise event, it's possible the
+		 * counters-snapshotting records a positive value for the
+		 * overflowed event. Then the HW auto-reload mechanism
+		 * reset the counter to 0 immediately, because the
+		 * pebs_event_reset is cleared if the PERF_X86_EVENT_AUTO_RELOAD
+		 * is not set. The counter backwards may be observed in a
+		 * PMI handler.
+		 *
+		 * Since the event value has been updated when processing the
+		 * counters-snapshotting record, only needs to set the new
+		 * period for the counter.
+		 */
+		if (is_pebs_counter_event_group(event))
+			static_call(x86_pmu_set_period)(event);
+		else
+			intel_pmu_save_and_restart(event);
+	}
 }
 
 static __always_inline void
maintainer
#11 lore raw
In reply to [email protected]
Quoted 13 lines · On Thu, Apr 24, 2025 at 06:47:13AM -0700, [email protected] wrote:

From: Kan Liang <[email protected]>

The patch series includes several fixes for the new Intel features.

The first 4 patches are to fix the group flag issue which impacts the branch counters, PEBS counters-snapshotting and ACR.
The V1 can be found at
https://lore.kernel.org/lkml/[email protected]/

The last patch is to fix an issue of counters-snapshotting. The V1 can be found at
https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

Kan Liang (5):
perf/x86/intel: Only check the group flag for X86 leader perf/x86/intel: Check the X86 leader for pebs_counter_event_group perf/x86/intel: Check the X86 leader for ACR group perf/x86: Optimize the is_x86_event
perf/x86/intel/ds: Fix counter backwards of non-precise events
counters-snapshotting

It didn't apply cleanly, but I stomped on it and pushed out new perf/urgent and perf/core branches that contain these patches. Hopefully I didn't mess it up ;-)

author
#12 lore raw
Quoted 22 lines · Peter Zijlstra
Quoted 13 lines · On Thu, Apr 24, 2025 at 06:47:13AM -0700, [email protected] wrote:

From: Kan Liang <[email protected]>

The patch series includes several fixes for the new Intel features.

The first 4 patches are to fix the group flag issue which impacts the branch counters, PEBS counters-snapshotting and ACR.
The V1 can be found at
https://lore.kernel.org/lkml/[email protected]/

The last patch is to fix an issue of counters-snapshotting. The V1 can be found at
https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

Kan Liang (5):
perf/x86/intel: Only check the group flag for X86 leader perf/x86/intel: Check the X86 leader for pebs_counter_event_group perf/x86/intel: Check the X86 leader for ACR group perf/x86: Optimize the is_x86_event
perf/x86/intel/ds: Fix counter backwards of non-precise events
counters-snapshotting

Quoted 1 line

It didn't apply cleanly,

Sorry for it.

Quoted 3 lines

but I stomped on it and pushed out new
perf/urgent and perf/core branches that contain these patches. Hopefully I didn't mess it up ;-)

Something is missed in this patch 5d4d71ebc737 ("perf/x86/intel: Only check the group flag for X86 leader")

arch/x86/events/perf_event.h +0 -0
index a73b1ff031b2..1f72a4f77b5c 100644
@@ -119,7 +119,7 @@ static inline bool check_leader_group(struct

perf_event *leader, int flags)

static inline bool is_branch_counters_group(struct perf_event *event) {
- return check_leader_group(event->group_leader, PERF_X86_EVENT_PEBS_CNTR);
+ return check_leader_group(event->group_leader,
PERF_X86_EVENT_BRANCH_COUNTERS);
}

static inline bool is_pebs_counter_event_group(struct perf_event *event)
@@ -1123,7 +1123,6 @@ static struct perf_pmu_format_hybrid_attr format_attr_hybrid_##_name = {\
.pmu_type = _pmu, \
}

-int is_x86_event(struct perf_event *event);
struct pmu *x86_get_pmu(unsigned int cpu);
extern struct x86_pmu x86_pmu __read_mostly;

Thanks,
Kan

maintainer
#13 lore raw
Quoted 50 lines · Kan
Quoted 22 lines · Peter Zijlstra
Quoted 13 lines · On Thu, Apr 24, 2025 at 06:47:13AM -0700, [email protected] wrote:

From: Kan Liang <[email protected]>

The patch series includes several fixes for the new Intel features.

The first 4 patches are to fix the group flag issue which impacts the branch counters, PEBS counters-snapshotting and ACR.
The V1 can be found at
https://lore.kernel.org/lkml/[email protected]/

The last patch is to fix an issue of counters-snapshotting. The V1 can be found at
https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

Kan Liang (5):
perf/x86/intel: Only check the group flag for X86 leader perf/x86/intel: Check the X86 leader for pebs_counter_event_group perf/x86/intel: Check the X86 leader for ACR group perf/x86: Optimize the is_x86_event
perf/x86/intel/ds: Fix counter backwards of non-precise events
counters-snapshotting

Quoted 1 line

It didn't apply cleanly,

Sorry for it.

Quoted 3 lines

but I stomped on it and pushed out new
perf/urgent and perf/core branches that contain these patches. Hopefully I didn't mess it up ;-)

Something is missed in this patch 5d4d71ebc737 ("perf/x86/intel: Only check the group flag for X86 leader")

arch/x86/events/perf_event.h +1 -1
index a73b1ff031b2..1f72a4f77b5c 100644
@@ -119,7 +119,7 @@ static inline bool check_leader_group(struct
 perf_event *leader, int flags)
 
 static inline bool is_branch_counters_group(struct perf_event *event)
 {
-	return check_leader_group(event->group_leader, PERF_X86_EVENT_PEBS_CNTR);
+	return check_leader_group(event->group_leader,
 PERF_X86_EVENT_BRANCH_COUNTERS);
 }
Quoted 1 line

static inline bool is_pebs_counter_event_group(struct perf_event *event)

Right.

arch/x86/events/perf_event.h static struct perf_pmu_format_hybrid_attr · line 1128

Quoted 8 lines
arch/x86/events/perf_event.h +0 -1
@@ -1123,7 +1123,6 @@ static struct perf_pmu_format_hybrid_attr
 format_attr_hybrid_##_name = {\
 	.pmu_type	= _pmu,                                         \
 }
 
-int is_x86_event(struct perf_event *event);
 struct pmu *x86_get_pmu(unsigned int cpu);
 extern struct x86_pmu x86_pmu __read_mostly;

See, that isn't there in tip/perf/urgent :-)

I've pushed out an updated set. Please check.

author
#14 lore raw
Quoted 60 lines · Peter Zijlstra
Quoted 50 lines · Kan
Quoted 22 lines · Peter Zijlstra
Quoted 13 lines · On Thu, Apr 24, 2025 at 06:47:13AM -0700, [email protected] wrote:

From: Kan Liang <[email protected]>

The patch series includes several fixes for the new Intel features.

The first 4 patches are to fix the group flag issue which impacts the branch counters, PEBS counters-snapshotting and ACR.
The V1 can be found at
https://lore.kernel.org/lkml/[email protected]/

The last patch is to fix an issue of counters-snapshotting. The V1 can be found at
https://lore.kernel.org/lkml/[email protected]/

Quoted 7 lines

Kan Liang (5):
perf/x86/intel: Only check the group flag for X86 leader perf/x86/intel: Check the X86 leader for pebs_counter_event_group perf/x86/intel: Check the X86 leader for ACR group perf/x86: Optimize the is_x86_event
perf/x86/intel/ds: Fix counter backwards of non-precise events
counters-snapshotting

Quoted 1 line

It didn't apply cleanly,

Sorry for it.

Quoted 3 lines

but I stomped on it and pushed out new
perf/urgent and perf/core branches that contain these patches. Hopefully I didn't mess it up ;-)

Something is missed in this patch 5d4d71ebc737 ("perf/x86/intel: Only check the group flag for X86 leader")

arch/x86/events/perf_event.h +1 -1
index a73b1ff031b2..1f72a4f77b5c 100644
@@ -119,7 +119,7 @@ static inline bool check_leader_group(struct
 perf_event *leader, int flags)
 
 static inline bool is_branch_counters_group(struct perf_event *event)
 {
-	return check_leader_group(event->group_leader, PERF_X86_EVENT_PEBS_CNTR);
+	return check_leader_group(event->group_leader,
 PERF_X86_EVENT_BRANCH_COUNTERS);
 }
Quoted 1 line

static inline bool is_pebs_counter_event_group(struct perf_event *event)

Right.

Quoted 5 lines
arch/x86/events/perf_event.h +0 -0
@@ -1123,7 +1123,6 @@ static struct perf_pmu_format_hybrid_attr
 format_attr_hybrid_##_name = {\
 	.pmu_type	= _pmu,                                         \
 }
 
Quoted 7 lines

arch/x86/events/perf_event.h static struct perf_pmu_format_hybrid_attr · line 1128

Quoted 3 lines
arch/x86/events/perf_event.h +0 -1
-int is_x86_event(struct perf_event *event);
 struct pmu *x86_get_pmu(unsigned int cpu);
 extern struct x86_pmu x86_pmu __read_mostly;

See, that isn't there in tip/perf/urgent :-)

Quoted 1 line

I've pushed out an updated set. Please check.

It looks good to me. Thanks a lot! :)

Kan