Skip to content

Commit 35eef64

Browse files
committed
ci/diffs: add current CI patches for bpf-next
Signed-off-by: Ihor Solodrai <[email protected]>
1 parent bca3ef8 commit 35eef64

3 files changed

+216
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
From 4b65d5ae971430287855a89635a184c489bd02a5 Mon Sep 17 00:00:00 2001
2+
From: Saket Kumar Bhaskar <[email protected]>
3+
Date: Mon, 12 May 2025 14:41:07 +0530
4+
Subject: [PATCH 1/3] selftests/bpf: Fix bpf selftest build error
5+
6+
On linux-next, build for bpf selftest displays an error due to
7+
mismatch in the expected function signature of bpf_testmod_test_read
8+
and bpf_testmod_test_write.
9+
10+
Commit 97d06802d10a ("sysfs: constify bin_attribute argument of bin_attribute::read/write()")
11+
changed the required type for struct bin_attribute to const struct bin_attribute.
12+
13+
To resolve the error, update corresponding signature for the callback.
14+
15+
Fixes: 97d06802d10a ("sysfs: constify bin_attribute argument of bin_attribute::read/write()")
16+
Reported-by: Venkat Rao Bagalkote <[email protected]>
17+
Closes: https://lore.kernel.org/all/[email protected]/
18+
Tested-by: Venkat Rao Bagalkote <[email protected]>
19+
Signed-off-by: Saket Kumar Bhaskar <[email protected]>
20+
Link: https://lore.kernel.org/r/[email protected]
21+
Signed-off-by: Alexei Starovoitov <[email protected]>
22+
---
23+
tools/testing/selftests/bpf/test_kmods/bpf_testmod.c | 6 +++---
24+
1 file changed, 3 insertions(+), 3 deletions(-)
25+
26+
diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
27+
index e6c248e3ae54..e9e918cdf31f 100644
28+
--- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
29+
+++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
30+
@@ -385,7 +385,7 @@ int bpf_testmod_fentry_ok;
31+
32+
noinline ssize_t
33+
bpf_testmod_test_read(struct file *file, struct kobject *kobj,
34+
- struct bin_attribute *bin_attr,
35+
+ const struct bin_attribute *bin_attr,
36+
char *buf, loff_t off, size_t len)
37+
{
38+
struct bpf_testmod_test_read_ctx ctx = {
39+
@@ -465,7 +465,7 @@ ALLOW_ERROR_INJECTION(bpf_testmod_test_read, ERRNO);
40+
41+
noinline ssize_t
42+
bpf_testmod_test_write(struct file *file, struct kobject *kobj,
43+
- struct bin_attribute *bin_attr,
44+
+ const struct bin_attribute *bin_attr,
45+
char *buf, loff_t off, size_t len)
46+
{
47+
struct bpf_testmod_test_write_ctx ctx = {
48+
@@ -567,7 +567,7 @@ static void testmod_unregister_uprobe(void)
49+
50+
static ssize_t
51+
bpf_testmod_uprobe_write(struct file *file, struct kobject *kobj,
52+
- struct bin_attribute *bin_attr,
53+
+ const struct bin_attribute *bin_attr,
54+
char *buf, loff_t off, size_t len)
55+
{
56+
unsigned long offset = 0;
57+
--
58+
2.49.0
59+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
From baa39c169dd526cb0186187fc44ec462266efcc6 Mon Sep 17 00:00:00 2001
2+
From: Yonghong Song <[email protected]>
3+
Date: Thu, 29 May 2025 13:11:51 -0700
4+
Subject: [PATCH 2/3] selftests/bpf: Fix selftest
5+
btf_tag/btf_type_tag_percpu_vmlinux_helper failure
6+
7+
Ihor Solodrai reported selftest 'btf_tag/btf_type_tag_percpu_vmlinux_helper'
8+
failure ([1]) during 6.16 merge window. The failure log:
9+
10+
...
11+
7: (15) if r0 == 0x0 goto pc+1 ; R0=ptr_css_rstat_cpu()
12+
; *(volatile int *)rstat; @ btf_type_tag_percpu.c:68
13+
8: (61) r1 = *(u32 *)(r0 +0)
14+
cannot access ptr member updated_children with moff 0 in struct css_rstat_cpu with off 0 size 4
15+
16+
Two changes are needed. First, 'struct cgroup_rstat_cpu' needs to be
17+
replaced with 'struct css_rstat_cpu' to be consistent with new data
18+
structure. Second, layout of 'css_rstat_cpu' is changed compared
19+
to 'cgroup_rstat_cpu'. The first member becomes a pointer so
20+
the bpf prog needs to do 8-byte load instead of 4-byte load.
21+
22+
[1] https://lore.kernel.org/bpf/[email protected]/
23+
24+
Cc: Ihor Solodrai <[email protected]>
25+
Cc: JP Kobryn <[email protected]>
26+
Signed-off-by: Yonghong Song <[email protected]>
27+
Acked-by: JP Kobryn <[email protected]>
28+
Link: https://lore.kernel.org/r/[email protected]
29+
Signed-off-by: Alexei Starovoitov <[email protected]>
30+
---
31+
tools/testing/selftests/bpf/progs/btf_type_tag_percpu.c | 6 +++---
32+
1 file changed, 3 insertions(+), 3 deletions(-)
33+
34+
diff --git a/tools/testing/selftests/bpf/progs/btf_type_tag_percpu.c b/tools/testing/selftests/bpf/progs/btf_type_tag_percpu.c
35+
index 69f81cb555ca..d93f68024cc6 100644
36+
--- a/tools/testing/selftests/bpf/progs/btf_type_tag_percpu.c
37+
+++ b/tools/testing/selftests/bpf/progs/btf_type_tag_percpu.c
38+
@@ -57,15 +57,15 @@ int BPF_PROG(test_percpu_load, struct cgroup *cgrp, const char *path)
39+
SEC("tp_btf/cgroup_mkdir")
40+
int BPF_PROG(test_percpu_helper, struct cgroup *cgrp, const char *path)
41+
{
42+
- struct cgroup_rstat_cpu *rstat;
43+
+ struct css_rstat_cpu *rstat;
44+
__u32 cpu;
45+
46+
cpu = bpf_get_smp_processor_id();
47+
- rstat = (struct cgroup_rstat_cpu *)bpf_per_cpu_ptr(
48+
+ rstat = (struct css_rstat_cpu *)bpf_per_cpu_ptr(
49+
cgrp->self.rstat_cpu, cpu);
50+
if (rstat) {
51+
/* READ_ONCE */
52+
- *(volatile int *)rstat;
53+
+ *(volatile long *)rstat;
54+
}
55+
56+
return 0;
57+
--
58+
2.49.0
59+
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 <[email protected]>
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 <[email protected]>
25+
Reported-by: Aishwarya TCV <[email protected]>
26+
Closes: https://lore.kernel.org/lkml/[email protected]/
27+
Tested-by: Leo Yan <[email protected]>
28+
Signed-off-by: Kan Liang <[email protected]>
29+
Link: https://lore.kernel.org/r/[email protected]
30+
Signed-off-by: Alexei Starovoitov <[email protected]>
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)