mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
Merge tag 'perf-urgent-2026-11-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf events fixes from Ingo Molnar: - Avoid AMD uncore context migration from non-owners (Sandipan Das) - Clear stop state in perf_trace_add(), to fix self-profilers such as async-profiler. Also fix a similar bug in hw_breakpoint_add() (Paolo Bertinetti) - Fix racy update of cpc->hrtimer_interval (Benjamin Segall) - Do not resurrect cpuctx->cgrp after last cgroup event exit, to fix UAF bug (Phat Dinh) * tag 'perf-urgent-2026-11-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/core: Do not resurrect cpuctx->cgrp after last cgroup event exit perf: Fix racy update of cpc->hrtimer_interval perf/hw_breakpoint: Clear stop state in hw_breakpoint_add() tracing/perf: Clear stop state in perf_trace_add() perf/x86/amd/uncore: Avoid context migration from non-owners
This commit is contained in:
@@ -595,7 +595,7 @@ static void amd_uncore_ctx_move(struct amd_uncore *uncore, unsigned int cpu)
|
||||
for (i = 0; i < uncore->num_pmus; i++) {
|
||||
pmu = &uncore->pmus[i];
|
||||
curr = *per_cpu_ptr(pmu->ctx, cpu);
|
||||
if (!curr)
|
||||
if (!curr || curr->cpu != cpu)
|
||||
continue;
|
||||
|
||||
/* Migrate to a shared sibling if possible */
|
||||
|
||||
+18
-13
@@ -1072,8 +1072,13 @@ static void perf_cgroup_switch(struct task_struct *task)
|
||||
* must not be done before ctxswout due
|
||||
* to update_cgrp_time_from_cpuctx() in
|
||||
* ctx_sched_out()
|
||||
*
|
||||
* ctx_sched_out() can consume a pending disable and drop the last cgroup
|
||||
* event, which clear the cpuctx->cgrp. Cgroup tracking follow active cgroup
|
||||
* event, so do not resurrect it
|
||||
*/
|
||||
cpuctx->cgrp = cgrp;
|
||||
if (cpuctx->ctx.nr_cgroups)
|
||||
cpuctx->cgrp = cgrp;
|
||||
/*
|
||||
* set cgrp before ctxsw in to allow
|
||||
* perf_cgroup_set_timestamp() in ctx_sched_in()
|
||||
@@ -1332,16 +1337,21 @@ static int perf_mux_hrtimer_restart(struct perf_cpu_pmu_context *cpc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int perf_mux_hrtimer_restart_ipi(void *arg)
|
||||
{
|
||||
return perf_mux_hrtimer_restart(arg);
|
||||
}
|
||||
|
||||
static __always_inline struct perf_cpu_pmu_context *this_cpc(struct pmu *pmu)
|
||||
{
|
||||
return *this_cpu_ptr(pmu->cpu_pmu_context);
|
||||
}
|
||||
|
||||
static int perf_mux_hrtimer_interval_ipi(void *arg)
|
||||
{
|
||||
struct pmu *pmu = arg;
|
||||
struct perf_cpu_pmu_context *cpc = this_cpc(pmu);
|
||||
int ms = pmu->hrtimer_interval_ms;
|
||||
|
||||
cpc->hrtimer_interval = ns_to_ktime(NSEC_PER_MSEC * ms);
|
||||
return perf_mux_hrtimer_restart(cpc);
|
||||
}
|
||||
|
||||
void perf_pmu_disable(struct pmu *pmu)
|
||||
{
|
||||
int *count = &this_cpc(pmu)->pmu_disable_count;
|
||||
@@ -12780,13 +12790,8 @@ perf_event_mux_interval_ms_store(struct device *dev,
|
||||
|
||||
/* update all cpuctx for this PMU */
|
||||
cpus_read_lock();
|
||||
for_each_online_cpu(cpu) {
|
||||
struct perf_cpu_pmu_context *cpc;
|
||||
cpc = *per_cpu_ptr(pmu->cpu_pmu_context, cpu);
|
||||
cpc->hrtimer_interval = ns_to_ktime(NSEC_PER_MSEC * timer);
|
||||
|
||||
cpu_function_call(cpu, perf_mux_hrtimer_restart_ipi, cpc);
|
||||
}
|
||||
for_each_online_cpu(cpu)
|
||||
cpu_function_call(cpu, perf_mux_hrtimer_interval_ipi, pmu);
|
||||
cpus_read_unlock();
|
||||
mutex_unlock(&mux_interval_mutex);
|
||||
|
||||
|
||||
@@ -968,8 +968,7 @@ static int hw_breakpoint_event_init(struct perf_event *bp)
|
||||
|
||||
static int hw_breakpoint_add(struct perf_event *bp, int flags)
|
||||
{
|
||||
if (!(flags & PERF_EF_START))
|
||||
bp->hw.state = PERF_HES_STOPPED;
|
||||
bp->hw.state = (flags & PERF_EF_START) ? 0 : PERF_HES_STOPPED;
|
||||
|
||||
if (is_sampling_event(bp)) {
|
||||
bp->hw.last_period = bp->hw.sample_period;
|
||||
|
||||
@@ -354,8 +354,7 @@ int perf_trace_add(struct perf_event *p_event, int flags)
|
||||
struct trace_event_call *tp_event = p_event->tp_event;
|
||||
struct hw_perf_event *hwc = &p_event->hw;
|
||||
|
||||
if (!(flags & PERF_EF_START))
|
||||
p_event->hw.state = PERF_HES_STOPPED;
|
||||
hwc->state = (flags & PERF_EF_START) ? 0 : PERF_HES_STOPPED;
|
||||
|
||||
if (is_sampling_event(p_event)) {
|
||||
hwc->last_period = hwc->sample_period;
|
||||
|
||||
Reference in New Issue
Block a user