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=1796281015; b=eqLldWoI2m7CqNcLI92SCdudQHa2tYoMLYMdQiuSSMMOeL+CLV/7ZtqTXdcobQ5SlI2M LhwCmzKxpGFz8jy71LSJeoCsVJ4KMJnuxJV4Y/TEd/9khpd3aKNp+weMnSv/4tqdYVRx1 oQ9it4TWD/mOSJgg/RvyDFOQgJgtbqqSDgoiE70oNggfYlL/+APlkz03BznDak0f/tefU KhpWF9MIYFr36lO2Sba7v8Bvzcp2qfUf+xm+BBS3B4we8xJtxRxs8jMiPQZU58nPEmQGx tef7k9YmhawM4CrZ1+ZQwBHsulYFvwIdyMUZQr8CJw4ffbZxIWzEDNaYjQUv7UsU0ow== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796281015; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=9VwVtgDCg2szb/CuXsvxaU7Z/eMqFuE6swALCTNBEts=; b=ns3wEtt5DXILiU7RH756spjBwtmD4PbZsyt7jQusftrva6efcH9xedm8x/LyWY83MDjL IcOK5m/B4MjpjDg+SNdywiLqdTWUCEMDym0jCFUF5XWIOjbMBeXhSK0H5RQQr6kZ/7yvq nywvKKQU6iv1GwPbJjTrDjmvGwVZlEcfQFddHO1KJpRpl79/cwcFxArEJedN5DtJhFd7u 3pzD57ZFgIk1OV49kukc8wa7U2/A/pZyuQfAL2cwyPXPq0i42mpZilujLTucyQDXE0RkI VISBgZHz0AnKrWdVfy3vzREbHdRBt3WKKUFqmKaGSSo0vsGZYHilX3fihW5gsAEmqEQ== 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=VwUi3ID2; 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 A26E4606A322 for ; Thu, 3 Dec 2026 06:56:55 +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=VwUi3ID2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 300BC1F00893; Thu, 3 Dec 2026 06:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796281015; bh=9VwVtgDCg2szb/CuXsvxaU7Z/eMqFuE6swALCTNBEts=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=VwUi3ID2Im9HRtvLKMoMN1cscxQ861hXA3zIF8JMtwlgLN52dvlwO0JErMfDbn2q2 JMTnVXz9I+0WtaV9Nde39AIyN2UtEnmPTtDYCFK+h90kTDhAHglnnt90+DgY7rdw3S rLOAdxyN9vJL/s5wSku0ldIWJGid88xdiJosqlP4TYdCXulXqaUKeLswy6oAbpeUJc W9DoCfYeNgQkED8Ss/pAfaR1hD1dQjsHXBwH0K/mD1Zqcm74CWCpPwin7tOVqjG2HB QqX7/RvmO0m7Slu6wAeChMfJngFrqfrEE4h3UsZnLztnzriufRS3MTfVTLXLoz8Eut H4EO6FagD0aNQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 1/4] perf/core: Do not account overflows of a throttled event Reply-To: sashiko-reviews@lists.linux.dev To: "Oancea Catalin" Cc: linux-perf-users@vger.kernel.org In-Reply-To: <20261203062703.15346-2-john3@mailbox.org> References: <20261203062703.15346-1-john3@mailbox.org> <20261203062703.15346-2-john3@mailbox.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 06:56:54 +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 1 potential issue to consider: - [High] perf/core: __perf_event_account_interrupt() returns 0 when already throttled -- commit 40d109737111a5945f5515a646e8889ee1a090bc Author: Oancea Catalin perf/core: Do not account overflows of a throttled event This commit adds an early return to __perf_event_account_interrupt() when hwc->interrupts is already MAX_INTERRUPTS, so reporting a pending overflow for an already-throttled event does not overwrite the throttle marker. > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 4ab3919ac78e9..cfe9ec01fdffa 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -10773,6 +10773,15 @@ __perf_event_account_interrupt(struct perf_event= *event, int throttle, > int ret =3D 0; > u64 seq; > =20 > + /* > + * A PMU handler can report an overflow which was pending when a > + * throttle stopped the event together with its group. Accounting it > + * would overwrite MAX_INTERRUPTS, and the tick would no longer > + * unthrottle the group if the event is its leader. > + */ > + if (unlikely(hwc->interrupts =3D=3D MAX_INTERRUPTS)) > + return 0; > + > seq =3D __this_cpu_read(perf_throttled_seq); > if (seq !=3D hwc->interrupts_seq) { > hwc->interrupts_seq =3D seq; [Severity: High] Should this return 1 instead of 0 when hwc->interrupts =3D=3D MAX_INTERRUPT= S? Callers of __perf_event_account_interrupt() and __perf_event_overflow() expect a non-zero return value whenever the event is throttled. For example, perf_swevent_overflow() runs with IRQs disabled and relies on a non-zero return to break out of its overflow loop: kernel/events/core.c:perf_swevent_overflow() { for (; overflow; overflow--) { if (__perf_event_overflow(event, throttle, data, regs)) { /* * We inhibit the overflow from happening when * hwc->interrupts =3D=3D MAX_INTERRUPTS. */ break; } throttle =3D 1; } } If a grouped hardware sibling NMI throttles a tracepoint event with a large overflow count (such as sched:sched_stat_*) during that loop, returning 0 prevents the loop from breaking while IRQs are disabled and can cause a hard lockup. Returning 0 also breaks other callers that check the throttled return value: perf_swevent_hrtimer() will re-arm a throttled hrtimer instead of returning HRTIMER_NORESTART, perf_ibs_handle_irq() in arch/x86/events/amd/ibs.c can re-enable IBS hardware while perf_ibs_stop() is marking it stopped, and hw_collect_samples() in arch/s390/kernel/perf_cpum_sf.c will keep delivering samples and skip backing off the sampling rate. Returning 1 here still lets __perf_event_overflow() deliver the pending sample while signaling the throttled state to callers. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203062703.1534= 6-1-john3@mailbox.org?part=3D1