From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796479118; b=zb7A9N7vguP7IWPKbUvr3C7IZWQWewUvH08h3wQ3MWC93ZKuRcvJlE2BuCuZu1cx6wIQ 4MgEDDOXgQ+uQuAgd3+GoVlN5mfRuEGmznZoSm7JNBE72eT5/jSfiFn8t/B2ozG8XonDR pOjeIrwmu3ybplb+KXywKM7wb5HBDFo6I4bkycyuEzxWOsrauNvz370W/vsPDy7TBXsSe n6qOHJWr/YTZAHC/e6POUatNiHSR9dl2LWLmxVrrcf/twOon22gq5M7D9kyGLCo1APmaJ v2VmfM6N2xXmQDZt/UFisSevtnh0WnXfzFfqi3u9iqPxYcG4x12qXMwblxQ/cO+m/1A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796479118; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Ntyyh/HmGOlypD+skb58RIXqvWWxFIj7ITHWeAPGjO0=; b=qaK5puFdmiBC/89lFo4A+zwYEg4GCnSPRdvO3NmEWqFCJOOfDl3fSA/Yjcne2SKB/7Ma 1UKjUZp1/KLxXVpambZrvfsnmTSPTLWQ6XMT0TgWAOw/wiQvSApQJYbToC5JbJz8mh6V8 9CxuEgKEic0/Z+oR0W41QNz/eCufMPnDJ5K63xIE1FL/e11MDX5LMPOMwVRBqqlwzXWhZ 4QkExzbbR3b3ETaIIp/CfTBA9aiCsDcIthXM6BAPXHiciNCY7NBd0i2a1rZEzz5UKqfb4 +7VcsdR0jUdVGNr1srUoIPyyG0/7Uss1zl8NZUEdcnycqB2AbMdRnm01E40yULo/JBQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SWPDjBnM; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC6FE606A322 for ; Sat, 5 Dec 2026 13:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SWPDjBnM Received: by smtp.kernel.org (Postfix) with ESMTPSA id A08661F0092B; Sat, 5 Dec 2026 13:58:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796479117; bh=Ntyyh/HmGOlypD+skb58RIXqvWWxFIj7ITHWeAPGjO0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=SWPDjBnM6nMideSP0l+kGdvsNph/dFAX63PyLB1+CbGmekmk+XhvXPcihSQLEu3lo sNidEqEhs22Lyd5eUhBb/y21OA4wU/ZBdqSj4mdVSsadVGQeD/tfaJZcOf1nS297gc PUTTVStBdWwm8sJ1HYsnK/eQVrS/3gp26ElxwIKjLIESUteTbMjUG8gNcjyIIgaIxj jkI45DOO5lb5n0XnAKlO8+AFyPMMqOVr5fQ0wT9edzZNZXBMiF5IFXL2mawXushgXt kC4TNl6uSy39jSUE4giilL7cdvb5K0NEySWsclgDOOFUNDp6k7s4xwIi8NvqqLchGn oLzjSAn1+NsHA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 1/8] perf/core: Disable the PMU of the context in __perf_event_period() Reply-To: sashiko-reviews@lists.linux.dev To: "Oancea Catalin" Cc: linux-perf-users@vger.kernel.org In-Reply-To: <20261205133221.3294-2-john3@mailbox.org> References: <20261205133221.3294-1-john3@mailbox.org> <20261205133221.3294-2-john3@mailbox.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 13:58:37 +0000 X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] perf/core: __perf_event_period() skips disabling event->pmu in mixed groups - [Medium] perf/core: __perf_event_period() stops disabling event->pmu in mixed groups -- commit 54df77548d2b0f131559f285443e4651cf45fd41 Author: Oancea Catalin perf/core: Disable the PMU of the context in __perf_event_period() This commit changes __perf_event_period() to disable and re-enable event->pmu_ctx->pmu instead of event->pmu while updating the period and unthrottling the event's group. > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 4ab3919ac78e9..da4f217d633e1 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -6564,7 +6564,12 @@ static void __perf_event_period(struct perf_event = *event, > =20 > active =3D (event->state =3D=3D PERF_EVENT_STATE_ACTIVE); > if (active) { > - perf_pmu_disable(event->pmu); > + /* > + * Disable the PMU of the context, which for a software event in > + * a group with hardware events is theirs: their NMI must not > + * throttle the group while it is unthrottled below. > + */ > + perf_pmu_disable(event->pmu_ctx->pmu); > event->pmu->stop(event, PERF_EF_UPDATE); > } [Severity: Medium] Should __perf_event_period() still disable event->pmu in addition to event->pmu_ctx->pmu? When a perf_sw_context event is grouped with a hardware PMU, event->pmu differs from event->pmu_ctx->pmu. On s390, cf_diag uses perf_sw_context and can be grouped with cpumf_sampling, while cpumf_pmu_stop() and cpumf_pmu_start() rely on cpumf_pmu_disable()/enable() to execute lcctl(). Skipping perf_pmu_disable(event->pmu) and perf_pmu_enable(event->pmu) causes cfdiag_getctr() to read live un-paused counters and can leave hardware counter sets stopped while the event believes it is active. Because perf_tp_event_match() gates on perf_pmu_enabled(event->pmu), a grouped tracepoint such as msr:write_msr (from x86_pmu_start()) can also fire during perf_event_unthrottle_group() and throttle the group mid-walk, hitting WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED)). Commit "perf/core: Stop an event which overflows while it is throttled" moves event->pmu->start() after perf_event_unthrottle_group(), mitigating re-entry on event itself, but still leaves event->pmu enabled and does not fix the s390 cf_diag regression. Nesting perf_pmu_disable(event->pmu) and perf_pmu_enable(event->pmu) inside the event->pmu_ctx->pmu calls, as event_sched_in() and event_sched_out() do, avoids both regressions. > @@ -6580,7 +6585,7 @@ static void __perf_event_period(struct perf_event *= event, > */ > if (event->hw.interrupts =3D=3D MAX_INTERRUPTS) > perf_event_unthrottle_group(event, true); > - perf_pmu_enable(event->pmu); > + perf_pmu_enable(event->pmu_ctx->pmu); > } > } [Severity: Medium] Can leaving event->pmu enabled here let a perf_kprobe sibling throttle the group during perf_event_unthrottle_group()? In a hardware group containing two perf_kprobe siblings and two hardware siblings, where kprobe2 is attached to perf_event_update_userpage(), calling PERF_EVENT_IOC_PERIOD on throttled kprobe1 no longer disables &perf_kprobe, so perf_tp_event_match() still sees event->pmu as enabled: __perf_event_period(kprobe1) perf_pmu_disable(hw_pmu) perf_event_unthrottle_group(kprobe1, true) perf_event_unthrottle(kprobe2, true) perf_event_unthrottle(hw_sibling1, true) x86_pmu_start(hw_sibling1, 0) perf_event_update_userpage() ... -> perf_swevent_overflow() perf_event_throttle_group() <-- re-throttles group perf_event_unthrottle(hw_sibling2, true) <-- starts while throttled Returning from the kprobe lets perf_event_unthrottle_group() start hw_sibling2 in a throttled group, so the next unthrottle hits WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED)) in x86_pmu_start(). Even after commit "perf/core: Stop an event which overflows while it is throttled", this path still re-throttles the group mid-walk and also lets __perf_event_period() start kprobe1 with hw.throttled set. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205133221.3294= -1-john3@mailbox.org?part=3D1