Skip to content

Commit 3881580

Browse files
committed
ci/diffs: replace perf reverts with a proper fix
Link: https://lore.kernel.org/bpf/d3c6b899-7281-4f97-a449-96f506181bab@linux.intel.com/ Signed-off-by: Ihor Solodrai <isolodrai@meta.com>
1 parent 65b9a46 commit 3881580

5 files changed

+100
-167
lines changed

ci/diffs/20250601-0003-Revert-perf-Only-dump-the-throttle-log-for-the-leade.patch

Lines changed: 0 additions & 38 deletions
This file was deleted.

ci/diffs/20250601-0004-Revert-perf-Fix-the-throttle-logic-for-a-group.patch

Lines changed: 0 additions & 127 deletions
This file was deleted.

ci/diffs/20250601-0001-selftests-bpf-Fix-bpf-selftest-build-error.patch renamed to ci/diffs/20250602-0001-selftests-bpf-Fix-bpf-selftest-build-error.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From 4b65d5ae971430287855a89635a184c489bd02a5 Mon Sep 17 00:00:00 2001
22
From: Saket Kumar Bhaskar <skb99@linux.ibm.com>
33
Date: Mon, 12 May 2025 14:41:07 +0530
4-
Subject: [PATCH 1/4] selftests/bpf: Fix bpf selftest build error
4+
Subject: [PATCH 1/3] selftests/bpf: Fix bpf selftest build error
55

66
On linux-next, build for bpf selftest displays an error due to
77
mismatch in the expected function signature of bpf_testmod_test_read

ci/diffs/20250601-0002-selftests-bpf-Fix-selftest-btf_tag-btf_type_tag_perc.patch renamed to ci/diffs/20250602-0002-selftests-bpf-Fix-selftest-btf_tag-btf_type_tag_perc.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From baa39c169dd526cb0186187fc44ec462266efcc6 Mon Sep 17 00:00:00 2001
22
From: Yonghong Song <yonghong.song@linux.dev>
33
Date: Thu, 29 May 2025 13:11:51 -0700
4-
Subject: [PATCH 2/4] selftests/bpf: Fix selftest
4+
Subject: [PATCH 2/3] selftests/bpf: Fix selftest
55
btf_tag/btf_type_tag_percpu_vmlinux_helper failure
66

77
Ihor Solodrai reported selftest 'btf_tag/btf_type_tag_percpu_vmlinux_helper'
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
From df3bed9ea57603e62696a2f8aee9609d3500b7d1 Mon Sep 17 00:00:00 2001
2+
From: Kan Liang <kan.liang@linux.intel.com>
3+
Date: Wed, 28 May 2025 10:58:32 -0700
4+
Subject: [PATCH 3/3] perf: Fix the throttle error of some clock events
5+
6+
The Arm CI reports RCU stall, which can be reproduced by the below perf
7+
command.
8+
perf record -a -e cpu-clock -- sleep 2
9+
10+
The cpu-clock and task_clock are two special SW events, which rely on
11+
the hrtimer. Instead of invoking the stop(), the HRTIMER_NORESTART is
12+
returned to stop the timer. Because the hrtimer interrupt handler cannot
13+
cancel itself, which causes infinite loop.
14+
15+
There may be two ways to fix it.
16+
- Add a check of MAX_INTERRUPTS in the event_stop. Return immediately if
17+
the stop is invoked by the throttle.
18+
- Introduce a PMU flag to track the case. Avoid the event_stop in
19+
perf_event_throttle() if the flag is detected.
20+
21+
The latter looks more generic. It may be used if there are more other
22+
cases that want to avoid the stop later. The latter is implemented.
23+
24+
Reported-by: Leo Yan <leo.yan@arm.com>
25+
Reported-by: Aishwarya TCV <aishwarya.tcv@arm.com>
26+
Closes: https://lore.kernel.org/lkml/20250527161656.GJ2566836@e132581.arm.com/
27+
Tested-by: Leo Yan <leo.yan@arm.com>
28+
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
29+
Link: https://lore.kernel.org/r/20250528175832.2999139-1-kan.liang@linux.intel.com
30+
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
31+
---
32+
include/linux/perf_event.h | 1 +
33+
kernel/events/core.c | 23 ++++++++++++++++++++---
34+
2 files changed, 21 insertions(+), 3 deletions(-)
35+
36+
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
37+
index 52dc7cfab0e0..97a747a97a50 100644
38+
--- a/include/linux/perf_event.h
39+
+++ b/include/linux/perf_event.h
40+
@@ -305,6 +305,7 @@ struct perf_event_pmu_context;
41+
#define PERF_PMU_CAP_EXTENDED_HW_TYPE 0x0100
42+
#define PERF_PMU_CAP_AUX_PAUSE 0x0200
43+
#define PERF_PMU_CAP_AUX_PREFER_LARGE 0x0400
44+
+#define PERF_PMU_CAP_NO_THROTTLE_STOP 0x0800
45+
46+
/**
47+
* pmu::scope
48+
diff --git a/kernel/events/core.c b/kernel/events/core.c
49+
index f34c99f8ce8f..abd19bb571e3 100644
50+
--- a/kernel/events/core.c
51+
+++ b/kernel/events/core.c
52+
@@ -2656,7 +2656,22 @@ static void perf_event_unthrottle(struct perf_event *event, bool start)
53+
54+
static void perf_event_throttle(struct perf_event *event)
55+
{
56+
- event->pmu->stop(event, 0);
57+
+ /*
58+
+ * Some PMUs, e.g., cpu-clock and task_clock, may rely on
59+
+ * a special mechanism (hrtimer) to manipulate counters.
60+
+ * The regular stop doesn't work, since the hrtimer interrupt
61+
+ * handler cannot cancel itself.
62+
+ *
63+
+ * The stop should be avoided for such cases. Let the
64+
+ * driver-specific code handle it.
65+
+ *
66+
+ * The counters will eventually be disabled in the driver-specific
67+
+ * code. In unthrottle, they still need to be re-enabled.
68+
+ * There is no handling for PERF_PMU_CAP_NO_THROTTLE_STOP in
69+
+ * the perf_event_unthrottle().
70+
+ */
71+
+ if (!(event->pmu->capabilities & PERF_PMU_CAP_NO_THROTTLE_STOP))
72+
+ event->pmu->stop(event, 0);
73+
event->hw.interrupts = MAX_INTERRUPTS;
74+
if (event == event->group_leader)
75+
perf_log_throttle(event, 0);
76+
@@ -11848,7 +11863,8 @@ static int cpu_clock_event_init(struct perf_event *event)
77+
static struct pmu perf_cpu_clock = {
78+
.task_ctx_nr = perf_sw_context,
79+
80+
- .capabilities = PERF_PMU_CAP_NO_NMI,
81+
+ .capabilities = PERF_PMU_CAP_NO_NMI |
82+
+ PERF_PMU_CAP_NO_THROTTLE_STOP,
83+
.dev = PMU_NULL_DEV,
84+
85+
.event_init = cpu_clock_event_init,
86+
@@ -11930,7 +11946,8 @@ static int task_clock_event_init(struct perf_event *event)
87+
static struct pmu perf_task_clock = {
88+
.task_ctx_nr = perf_sw_context,
89+
90+
- .capabilities = PERF_PMU_CAP_NO_NMI,
91+
+ .capabilities = PERF_PMU_CAP_NO_NMI |
92+
+ PERF_PMU_CAP_NO_THROTTLE_STOP,
93+
.dev = PMU_NULL_DEV,
94+
95+
.event_init = task_clock_event_init,
96+
--
97+
2.49.0
98+

0 commit comments

Comments
 (0)