<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/events/core.c, branch v6.16</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v6.16</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.16'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2025-07-09T11:40:17Z</updated>
<entry>
<title>perf/core: Fix WARN in perf_sigtrap()</title>
<updated>2025-07-09T11:40:17Z</updated>
<author>
<name>Tetsuo Handa</name>
<email>penguin-kernel@I-love.SAKURA.ne.jp</email>
</author>
<published>2025-07-09T11:27:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3da6bb419750f3ad834786d6ba7c9d5d062c770b'/>
<id>urn:sha1:3da6bb419750f3ad834786d6ba7c9d5d062c770b</id>
<content type='text'>
Since exit_task_work() runs after perf_event_exit_task_context() updated
ctx-&gt;task to TASK_TOMBSTONE, perf_sigtrap() from perf_pending_task() might
observe event-&gt;ctx-&gt;task == TASK_TOMBSTONE.

Swap the early exit tests in order not to hit WARN_ON_ONCE().

Closes: https://syzkaller.appspot.com/bug?extid=2fe61cb2a86066be6985
Reported-by: syzbot &lt;syzbot+2fe61cb2a86066be6985@syzkaller.appspotmail.com&gt;
Signed-off-by: Tetsuo Handa &lt;penguin-kernel@I-love.SAKURA.ne.jp&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/b1c224bd-97f9-462c-a3e3-125d5e19c983@I-love.SAKURA.ne.jp
</content>
</entry>
<entry>
<title>perf: Revert to requiring CAP_SYS_ADMIN for uprobes</title>
<updated>2025-07-03T08:33:55Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2025-07-02T16:21:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ba677dbe77af5ffe6204e0f3f547f3ba059c6302'/>
<id>urn:sha1:ba677dbe77af5ffe6204e0f3f547f3ba059c6302</id>
<content type='text'>
Jann reports that uprobes can be used destructively when used in the
middle of an instruction. The kernel only verifies there is a valid
instruction at the requested offset, but due to variable instruction
length cannot determine if this is an instruction as seen by the
intended execution stream.

Additionally, Mark Rutland notes that on architectures that mix data
in the text segment (like arm64), a similar things can be done if the
data word is 'mistaken' for an instruction.

As such, require CAP_SYS_ADMIN for uprobes.

Fixes: c9e0924e5c2b ("perf/core: open access to probes for CAP_PERFMON privileged process")
Reported-by: Jann Horn &lt;jannh@google.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/CAG48ez1n4520sq0XrWYDHKiKxE_+WCfAK+qt9qkY4ZiBGmL-5g@mail.gmail.com
</content>
</entry>
<entry>
<title>perf/core: Fix the WARN_ON_ONCE is out of lock protected region</title>
<updated>2025-06-30T07:32:49Z</updated>
<author>
<name>Luo Gengkun</name>
<email>luogengkun@huaweicloud.com</email>
</author>
<published>2025-06-26T13:54:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7b4c5a37544ba22c6ebe72c0d4ea56c953459fa5'/>
<id>urn:sha1:7b4c5a37544ba22c6ebe72c0d4ea56c953459fa5</id>
<content type='text'>
commit 3172fb986666 ("perf/core: Fix WARN in perf_cgroup_switch()") try to
fix a concurrency problem between perf_cgroup_switch and
perf_cgroup_event_disable. But it does not to move the WARN_ON_ONCE into
lock-protected region, so the warning is still be triggered.

Fixes: 3172fb986666 ("perf/core: Fix WARN in perf_cgroup_switch()")
Signed-off-by: Luo Gengkun &lt;luogengkun@huaweicloud.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/20250626135403.2454105-1-luogengkun@huaweicloud.com
</content>
</entry>
<entry>
<title>perf/aux: Fix pending disable flow when the AUX ring buffer overruns</title>
<updated>2025-06-26T08:50:37Z</updated>
<author>
<name>Leo Yan</name>
<email>leo.yan@arm.com</email>
</author>
<published>2025-06-25T17:07:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1476b218327b89bbb64c14619a2d34f0c320f2c3'/>
<id>urn:sha1:1476b218327b89bbb64c14619a2d34f0c320f2c3</id>
<content type='text'>
If an AUX event overruns, the event core layer intends to disable the
event by setting the 'pending_disable' flag. Unfortunately, the event
is not actually disabled afterwards.

In commit:

  ca6c21327c6a ("perf: Fix missing SIGTRAPs")

the 'pending_disable' flag was changed to a boolean. However, the
AUX event code was not updated accordingly. The flag ends up holding a
CPU number. If this number is zero, the flag is taken as false and the
IRQ work is never triggered.

Later, with commit:

  2b84def990d3 ("perf: Split __perf_pending_irq() out of perf_pending_irq()")

a new IRQ work 'pending_disable_irq' was introduced to handle event
disabling. The AUX event path was not updated to kick off the work queue.

To fix this bug, when an AUX ring buffer overrun is detected, call
perf_event_disable_inatomic() to initiate the pending disable flow.

Also update the outdated comment for setting the flag, to reflect the
boolean values (0 or 1).

Fixes: 2b84def990d3 ("perf: Split __perf_pending_irq() out of perf_pending_irq()")
Fixes: ca6c21327c6a ("perf: Fix missing SIGTRAPs")
Signed-off-by: Leo Yan &lt;leo.yan@arm.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Reviewed-by: James Clark &lt;james.clark@linaro.org&gt;
Reviewed-by: Yeoreum Yun &lt;yeoreum.yun@arm.com&gt;
Cc: Adrian Hunter &lt;adrian.hunter@intel.com&gt;
Cc: Alexander Shishkin &lt;alexander.shishkin@linux.intel.com&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@kernel.org&gt;
Cc: Ian Rogers &lt;irogers@google.com&gt;
Cc: Jiri Olsa &lt;jolsa@redhat.com&gt;
Cc: Liang Kan &lt;kan.liang@linux.intel.com&gt;
Cc: Marco Elver &lt;elver@google.com&gt;
Cc: Mark Rutland &lt;mark.rutland@arm.com&gt;
Cc: Namhyung Kim &lt;namhyung@kernel.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Cc: linux-perf-users@vger.kernel.org
Link: https://lore.kernel.org/r/20250625170737.2918295-1-leo.yan@arm.com
</content>
</entry>
<entry>
<title>perf: Fix the throttle error of some clock events</title>
<updated>2025-06-11T12:05:08Z</updated>
<author>
<name>Kan Liang</name>
<email>kan.liang@linux.intel.com</email>
</author>
<published>2025-06-06T19:25:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bc4394e5e79cdda1b0997e0be1d65e242f523f02'/>
<id>urn:sha1:bc4394e5e79cdda1b0997e0be1d65e242f523f02</id>
<content type='text'>
Both ARM and IBM CI reports RCU stall, which can be reproduced by the
below perf command.
  perf record -a -e cpu-clock -- sleep 2

The issue is introduced by the generic throttle patch set, which
unconditionally invoke the event_stop() when throttle is triggered.

The cpu-clock and task-clock are two special SW events, which rely on
the hrtimer. The throttle is invoked in the hrtimer handler. The
event_stop()-&gt;hrtimer_cancel() waits for the handler to finish, which is
a deadlock. Instead of invoking the stop(), the HRTIMER_NORESTART should
be used to stop the timer.

There may be two ways to fix it:
 - Introduce a PMU flag to track the case. Avoid the event_stop in
   perf_event_throttle() if the flag is detected.
   It has been implemented in the
   https://lore.kernel.org/lkml/20250528175832.2999139-1-kan.liang@linux.intel.com/
   The new flag was thought to be an overkill for the issue.
 - Add a check in the event_stop. Return immediately if the throttle is
   invoked in the hrtimer handler. Rely on the existing HRTIMER_NORESTART
   method to stop the timer.

The latter is implemented here.

Move event-&gt;hw.interrupts = MAX_INTERRUPTS before the stop(). It makes
the order the same as perf_event_unthrottle(). Except the patch, no one
checks the hw.interrupts in the stop(). There is no impact from the
order change.

When stops in the throttle, the event should not be updated,
stop(event, 0). But the cpu_clock_event_stop() doesn't handle the flag.
In logic, it's wrong. But it didn't bring any problems with the old
code, because the stop() was not invoked when handling the throttle.
Checking the flag before updating the event.

Fixes: 9734e25fbf5a ("perf: Fix the throttle logic for a group")
Closes: https://lore.kernel.org/lkml/20250527161656.GJ2566836@e132581.arm.com/
Closes: https://lore.kernel.org/lkml/djxlh5fx326gcenwrr52ry3pk4wxmugu4jccdjysza7tlc5fef@ktp4rffawgcw/
Closes: https://lore.kernel.org/lkml/8e8f51d8-af64-4d9e-934b-c0ee9f131293@linux.ibm.com/
Closes: https://lore.kernel.org/lkml/4ce106d0-950c-aadc-0b6a-f0215cd39913@maine.edu/
Reported-by: Leo Yan &lt;leo.yan@arm.com&gt;
Reported-by: Aishwarya TCV &lt;aishwarya.tcv@arm.com&gt;
Reported-by: Alexei Starovoitov &lt;alexei.starovoitov@gmail.com&gt;
Reported-by: Venkat Rao Bagalkote &lt;venkat88@linux.ibm.com&gt;
Reported-by: Vince Weaver &lt;vincent.weaver@maine.edu&gt;
Signed-off-by: Kan Liang &lt;kan.liang@linux.intel.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Reviewed-by: Ian Rogers &lt;irogers@google.com&gt;
Link: https://lkml.kernel.org/r/20250606192546.915765-1-kan.liang@linux.intel.com
</content>
</entry>
<entry>
<title>perf/core: Fix WARN in perf_cgroup_switch()</title>
<updated>2025-06-05T12:37:52Z</updated>
<author>
<name>Luo Gengkun</name>
<email>luogengkun@huaweicloud.com</email>
</author>
<published>2025-06-04T03:39:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3172fb986666dfb71bf483b6d3539e1e587fa197'/>
<id>urn:sha1:3172fb986666dfb71bf483b6d3539e1e587fa197</id>
<content type='text'>
There may be concurrency between perf_cgroup_switch and
perf_cgroup_event_disable. Consider the following scenario: after a new
perf cgroup event is created on CPU0, the new event may not trigger
a reprogramming, causing ctx-&gt;is_active to be 0. In this case, when CPU1
disables this perf event, it executes __perf_remove_from_context-&gt;
list _del_event-&gt;perf_cgroup_event_disable on CPU1, which causes a race
with perf_cgroup_switch running on CPU0.

The following describes the details of this concurrency scenario:

CPU0						CPU1

perf_cgroup_switch:
   ...
   # cpuctx-&gt;cgrp is not NULL here
   if (READ_ONCE(cpuctx-&gt;cgrp) == NULL)
   	return;

						perf_remove_from_context:
						   ...
						   raw_spin_lock_irq(&amp;ctx-&gt;lock);
						   ...
						   # ctx-&gt;is_active == 0 because reprogramm is not
						   # tigger, so CPU1 can do __perf_remove_from_context
						   # for CPU0
						   __perf_remove_from_context:
						         perf_cgroup_event_disable:
							    ...
							    if (--ctx-&gt;nr_cgroups)
							    ...

   # this warning will happened because CPU1 changed
   # ctx.nr_cgroups to 0.
   WARN_ON_ONCE(cpuctx-&gt;ctx.nr_cgroups == 0);

[peterz: use guard instead of goto unlock]
Fixes: db4a835601b7 ("perf/core: Set cgroup in CPU contexts for new cgroup events")
Signed-off-by: Luo Gengkun &lt;luogengkun@huaweicloud.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/20250604033924.3914647-3-luogengkun@huaweicloud.com
</content>
</entry>
<entry>
<title>perf: Fix dangling cgroup pointer in cpuctx</title>
<updated>2025-06-05T12:37:52Z</updated>
<author>
<name>Yeoreum Yun</name>
<email>yeoreum.yun@arm.com</email>
</author>
<published>2025-06-02T18:40:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3b7a34aebbdf2a4b7295205bf0c654294283ec82'/>
<id>urn:sha1:3b7a34aebbdf2a4b7295205bf0c654294283ec82</id>
<content type='text'>
Commit a3c3c6667("perf/core: Fix child_total_time_enabled accounting
bug at task exit") moves the event-&gt;state update to before
list_del_event(). This makes the event-&gt;state test in list_del_event()
always false; never calling perf_cgroup_event_disable().

As a result, cpuctx-&gt;cgrp won't be cleared properly; causing havoc.

Fixes: a3c3c6667("perf/core: Fix child_total_time_enabled accounting bug at task exit")
Signed-off-by: Yeoreum Yun &lt;yeoreum.yun@arm.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Tested-by: David Wang &lt;00107082@163.com&gt;
Link: https://lore.kernel.org/all/aD2TspKH%2F7yvfYoO@e129823.arm.com/
</content>
</entry>
<entry>
<title>perf: Fix cgroup state vs ERROR</title>
<updated>2025-06-05T12:37:52Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2025-06-05T10:37:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=61988e36dc5457cdff7ae7927e8d9ad1419ee998'/>
<id>urn:sha1:61988e36dc5457cdff7ae7927e8d9ad1419ee998</id>
<content type='text'>
While chasing down a missing perf_cgroup_event_disable() elsewhere,
Leo Yan found that both perf_put_aux_event() and
perf_remove_sibling_event() were also missing one.

Specifically, the rule is that events that switch to OFF,ERROR need to
call perf_cgroup_event_disable().

Unify the disable paths to ensure this.

Fixes: ab43762ef010 ("perf: Allow normal events to output AUX data")
Fixes: 9f0c4fa111dc ("perf/core: Add a new PERF_EV_CAP_SIBLING event capability")
Reported-by: Leo Yan &lt;leo.yan@arm.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/20250605123343.GD35970@noisy.programming.kicks-ass.net
</content>
</entry>
<entry>
<title>perf: Fix sample vs do_exit()</title>
<updated>2025-06-05T12:37:51Z</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2025-06-05T10:31:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4f6fc782128355931527cefe3eb45338abd8ab39'/>
<id>urn:sha1:4f6fc782128355931527cefe3eb45338abd8ab39</id>
<content type='text'>
Baisheng Gao reported an ARM64 crash, which Mark decoded as being a
synchronous external abort -- most likely due to trying to access
MMIO in bad ways.

The crash further shows perf trying to do a user stack sample while in
exit_mmap()'s tlb_finish_mmu() -- i.e. while tearing down the address
space it is trying to access.

It turns out that we stop perf after we tear down the userspace mm; a
receipie for disaster, since perf likes to access userspace for
various reasons.

Flip this order by moving up where we stop perf in do_exit().

Additionally, harden PERF_SAMPLE_CALLCHAIN and PERF_SAMPLE_STACK_USER
to abort when the current task does not have an mm (exit_mm() makes
sure to set current-&gt;mm = NULL; before commencing with the actual
teardown). Such that CPU wide events don't trip on this same problem.

Fixes: c5ebcedb566e ("perf: Add ability to attach user stack dump to sample")
Reported-by: Baisheng Gao &lt;baisheng.gao@unisoc.com&gt;
Suggested-by: Mark Rutland &lt;mark.rutland@arm.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Link: https://lkml.kernel.org/r/20250605110815.GQ39944@noisy.programming.kicks-ass.net
</content>
</entry>
<entry>
<title>perf: Only dump the throttle log for the leader</title>
<updated>2025-05-21T11:57:43Z</updated>
<author>
<name>Kan Liang</name>
<email>kan.liang@linux.intel.com</email>
</author>
<published>2025-05-20T18:16:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e800ac51202f053018f3d6acb1819ecec4d75a2c'/>
<id>urn:sha1:e800ac51202f053018f3d6acb1819ecec4d75a2c</id>
<content type='text'>
The PERF_RECORD_THROTTLE records are dumped for all throttled events.
It's not necessary for group events, which are throttled altogether.

Optimize it by only dump the throttle log for the leader.

The sample right after the THROTTLE record must be generated by the
actual target event. It is good enough for the perf tool to locate the
actual target event.

Suggested-by: Namhyung Kim &lt;namhyung@kernel.org&gt;
Signed-off-by: Kan Liang &lt;kan.liang@linux.intel.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Acked-by: Namhyung Kim &lt;namhyung@kernel.org&gt;
Link: https://lore.kernel.org/r/20250520181644.2673067-3-kan.liang@linux.intel.com
</content>
</entry>
</feed>
