perf/x86: Don't WARN when the ext_regs_buf allocation fails
Subsystems (2)
PATCH 1/1 perf/x86: Don't WARN when the ext_regs_buf allocation fails
reserve_ext_regs_buffers() wraps the per-CPU ext_regs_buf allocation in WARN_ON_ONCE(). The allocator already prints a warning with a stack dump when a GFP_KERNEL allocation fails, so the WARN only repeats it, which Documentation/process/coding-style.rst asks not to do. The failure is also handled: the buffers are freed again, the event is still created, and events that ask for SIMD or extended register sampling are rejected with -ENOMEM in x86_pmu_hw_config() and event_simd_regs_validate().
syzkaller hit this with fault injection on next-20261002. The trigger is a plain hardware cycles event opened while no other x86 PMU event exists, with the allocation failed:
!per_cpu(ext_regs_buf, cpu)
WARNING: arch/x86/events/core.c:441 at reserve_ext_regs_buffers arch/x86/events/core.c:441 [inline] WARNING: arch/x86/events/core.c:441 at x86_reserve_hardware+0x6ff/0x880 arch/x86/events/core.c:458 Call Trace: __x86_pmu_event_init arch/x86/events/core.c:825 [inline] x86_pmu_event_init+0x109/0xc50 arch/x86/events/core.c:3003 perf_try_init_event+0x140/0xbc0 kernel/events/core.c:13261 perf_init_event kernel/events/core.c:13365 [inline] perf_event_alloc+0x2145/0x5680 kernel/events/core.c:13640 __do_sys_perf_event_open+0x669/0x2d40 kernel/events/core.c:14185 do_syscall_64+0x12c/0x7b0 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Drop the WARN_ON_ONCE(). This matches reserve_ds_buffers() and reserve_lbr_buffers(), which also handle allocation failure without a warning.
---
Notes (not for the commit log):
Found with syzkaller in a QEMU/KVM guest with "-cpu host" (Intel Xeon Gold 5118 host).
Tested on next-20261002 (x86_64, syzbot's upstream-apparmor-kasan config, gcc 12) with a small C reproducer: write failslab/ignore-gfp-wait=N, then open a user-only cycles event with /proc/thread-self/fail-nth set to 1..64. The third injected failure lands on the ext_regs_buf kzalloc_node().
before: 3/3 runs hit the WARNING above, at fail-nth=3
after: 3/3 runs without any WARNING; with failslab/verbose=2 the forced
failure is shown at reserve_ext_regs_buffers() (arch/x86/events/core.c:439), and perf_event_open() returns a valid fd, as before
The WARN came up in the Sashiko review of v9 of the series. Dapeng preferred to keep the WARN_ON_ONCE() over propagating the error, since that would need a lot of fallback code:
https://lore.kernel.org/all/[email protected]/
This patch does not propagate the error either. It only drops the WARN, since the allocator already reports the failure.
The patch only removes the WARN, so failure handling does not change:
the event is still created, and events that need SIMD or extended register sampling get -ENOMEM until the last x86 PMU event is gone. x86_reserve_hardware() could return the error instead, but that would also make plain counting events fail, which seemed out of scope here.
The reproducer is available on request.
arch/x86/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/core.c +1 -1
@@ -438,7 +438,7 @@ static void reserve_ext_regs_buffers(void)for_each_possible_cpu (cpu) {per_cpu (ext_regs_buf, cpu) =kzalloc_node (size,GFP_KERNEL ,cpu_to_node (cpu)); -if (WARN_ON_ONCE (!per_cpu (ext_regs_buf, cpu))) +if (!per_cpu (ext_regs_buf, cpu)) goto err; }
Signature · 1 line
2.25.1
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 13 lines
reserve_ext_regs_buffers()wraps the per-CPUext_regs_bufallocation inWARN_ON_ONCE(). The allocator already prints a warning with a stack dump when aGFP_KERNELallocation fails, so the WARN only repeats it, whichDocumentation/process/coding-style.rstasks not to do. The failure is also handled: the buffers are freed again, the event is still created, and events that ask for SIMD or extended register sampling are rejected with-ENOMEMinx86_pmu_hw_config()andevent_simd_regs_validate().syzkaller hit this with fault injection on next-20261002. The trigger is a plain hardware cycles event opened while no other x86 PMU event exists, with the allocation failed:
!per_cpu(ext_regs_buf, cpu)
Quoted 8 lines
WARNING: arch/x86/events/core.c:441 at reserve_ext_regs_buffers arch/x86/events/core.c:441 [inline] WARNING: arch/x86/events/core.c:441 at x86_reserve_hardware+0x6ff/0x880 arch/x86/events/core.c:458[ ... ]
warning.Fixes b84c96283684 ("perf/x86: Enable XMM register sampling for non-PEBS events")Assisted-by Claude:claude-opus-5-5 syzkallerSigned-off-by vineash <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
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: f5a78ecccd98a04c47cea1cd63c2a2fdce8a4b48 Gitweb: https://git.kernel.org/tip/f5a78ecccd98a04c47cea1cd63c2a2fdce8a4b48 Author: vineash <[email protected]> AuthorDate: Tue, 13 Oct 2026 16:13:20 +08:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Fri, 16 Oct 2026 09:49:05 +02:00
perf/x86: Don't WARN when the ext_regs_buf allocation fails
reserve_ext_regs_buffers() wraps the per-CPU ext_regs_buf allocation in WARN_ON_ONCE(). The allocator already prints a warning with a stack dump when a GFP_KERNEL allocation fails, so the WARN only repeats it, which Documentation/process/coding-style.rst asks not to do. The failure is also handled: the buffers are freed again, the event is still created, and events that ask for SIMD or extended register sampling are rejected with -ENOMEM in x86_pmu_hw_config() and event_simd_regs_validate().
syzkaller hit this with fault injection on next-20261002. The trigger is a plain hardware cycles event opened while no other x86 PMU event exists, with the allocation failed:
!per_cpu(ext_regs_buf, cpu)
WARNING: arch/x86/events/core.c:441 at reserve_ext_regs_buffers arch/x86/events/core.c:441 [inline] WARNING: arch/x86/events/core.c:441 at x86_reserve_hardware+0x6ff/0x880 arch/x86/events/core.c:458 Call Trace: __x86_pmu_event_init arch/x86/events/core.c:825 [inline] x86_pmu_event_init+0x109/0xc50 arch/x86/events/core.c:3003 perf_try_init_event+0x140/0xbc0 kernel/events/core.c:13261 perf_init_event kernel/events/core.c:13365 [inline] perf_event_alloc+0x2145/0x5680 kernel/events/core.c:13640 __do_sys_perf_event_open+0x669/0x2d40 kernel/events/core.c:14185 do_syscall_64+0x12c/0x7b0 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Drop the WARN_ON_ONCE(). This matches reserve_ds_buffers() and reserve_lbr_buffers(), which also handle allocation failure without a warning.
--- arch/x86/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/core.c +1 -1
@@ -438,7 +438,7 @@ static void reserve_ext_regs_buffers(void)for_each_possible_cpu (cpu) {per_cpu (ext_regs_buf, cpu) =kzalloc_node (size,GFP_KERNEL ,cpu_to_node (cpu)); -if (WARN_ON_ONCE (!per_cpu (ext_regs_buf, cpu))) +if (!per_cpu (ext_regs_buf, cpu)) goto err; }