From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=80.241.56.171 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796142546; b=GY16n4mvceopUtdkMZHmDx8vYytt99gvPyuJ0ZPWT2daS+cmWOGeYkLX+jhwIQHvzl79 h0aC37J1ArpqtDQ2KMkhLMYk47ZDch2QXfAuPTLryaH4PazN0M/vZvSm/glJoxw/G3+Pc lh/6DMlZe6bml9z9OpuuuSeP7WiZwc1ga9qTKGXjozUN77ttQcgkj+VhKFZ3cyCgKAX/V tnf9dU8LQicBLPeXJgVWX7kIZ8Pz0L1GuREFMok7rW/ty5kglAmoF/VwUlVRywheJ1UFU L8HYnaxPLwt1mUptOnI+ZybAOnzpBtkWD9ChThl+YFW8KoNbC8i4lyYcSrrikO4d4Nw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796142546; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding:X-MBO-RS-ID:X-MBO-RS-META; bh=WFWn1cdqdc8CnYmap0M9lMJ8pX+nn4Kz90vmTsjYxAY=; b=AAucmbH+c++WViWxEusOj1MBuKwVOQ/wV0mwOGcsi6VnGQSdVGKq5Pvp6QmYnz/0blzT GMKnuJ0noN9lIeOvXlWb/u2hUcKNLpodCsVsryaj62+lO8EiD372NY0BI5UV8lHpYwAJX RH3d44TRlz2oNTk/mBy5kWf7LOnDzafnVjD5J+iZhZHl1FF1V6FmcPx3+nFsLxrre8wYJ FuV2OM17m2y40N+4qOwFXPUgS1Rtd8521AGREDC9kcGtaAzIWuUOCE1dVO/AaZ/BBOhRh bYWj/vXf25TIpI7GtNSBeDnI+rFHyUvG+tCPbKBa/bzLCa3350BdbzCgRpLQ061mkKA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=mailbox.org; spf=pass smtp.mailfrom=mailbox.org; dkim=pass header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b="kx6m/PvK"; arc=none smtp.remote-ip=80.241.56.171 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21E00606A32A; Tue, 1 Dec 2026 16:29:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 21E00606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mailbox.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=kx6m/PvK Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4jf5tk1wzCzMlLH; Tue, 01 Dec 2026 17:29:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1796142542; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WFWn1cdqdc8CnYmap0M9lMJ8pX+nn4Kz90vmTsjYxAY=; b=kx6m/PvK8WVSK7fqw25B7+hMwnW0chdvm3cJcf2ZQnH0JkU3oHCoSUtauMDG4Ahi32EhbX copOQTMGpXc3/vLqjUQ6iagvtfONdRmrOKHlSdats2PZVlAfKTcRvB0NxMahlcht07jtRr YqrPIHyqqGOxvNQIgOcsN30x0UfuoOy1UacxDg1ZHtoph47h2G9oSMyxD7CttDgZU5NakA kPt/bRgumNB4y6yX8eJGRWGvx34NWSAESu4BhUntZsN3Jv+g5V/jqAvGLFat1+4zVzWpVc klLif3p7dVN2tXsCDv41LcJh5MG+zmUpox0qE24PZE3uxTpCMfq9t4zdGww5HA== From: Oancea Catalin To: Ravi Bangoria Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Kan Liang , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , James Clark , Thomas Gleixner , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Dapeng Mi Subject: Re: [PATCH] perf/x86/amd/core: Handle overflows of counters stopped by a throttle Date: Tue, 1 Dec 2026 18:28:58 +0200 Message-ID: <20261201162858.43478-1-john3@mailbox.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: References: <20261124211146.61378-1-john3@mailbox.org> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MBO-RS-ID: 4adced60238a0971883 X-MBO-RS-META: oet7h1y97kw1yt67iuitsdfno78m9qqd Hi Ravi, thanks for the review. On Tue, 1 Dec 2026 16:26:09 +0530, Ravi Bangoria wrote: >> The overflow of the sibling is not handled. Its period is not set up >> again and its status bit stays set, because only the handled bits are >> acknowledged. > > I assume Intel's PMI handler as well as generic x86_pmu_handle_irq() > are also affected? Yes, both. I have tested them now. For the generic handler I booted the same KVM guest with clearcpuid=perfmon_v2, so that amd_pmu_handle_irq() is used, on v7.4-rc5-25-g19cc08c1a6a6. It has no status register to compare with, so nothing warns, but the overflow of the sibling is skipped in the same way. In an MSR trace of 8 seconds there are 493 NMIs which reload counter 0, disable both event selects and do not touch counter 1, and the next read of counter 1, with the counter still disabled, shows that it had overflowed. With a debug print in the handler I counted 3574 and 1977 such counters in two runs of 8 seconds. About half of them are picked up by a later NMI after the group is unthrottled, since that handler goes by the counter values and the counter still reads as overflowed. That sample is late and covers more than one period. The other half are still pending when the task is scheduled out. The Intel handler I tested on an i7-14700T (bare metal, P-cores), same commit plus a debug print in handle_pmi_common(). It skips the stopped sibling too, and there it is worse: the status has already been acked, so no later PMI finds the counter again. The unthrottle restarts it with its old value and it does not sample until the event is scheduled out and in again. On bare metal the two periods of my reproducer (20000 and 20011) hardly ever overflow in the same PMI: 0 skips in about 11000 throttles. With both periods at 20000 it was 6575 skips in 8 seconds. But a few are enough. A single task with a 20000/20011 group, pinned to one P-core, run as uid 65534, got 16 skips in 3 seconds, and after each of them the sibling delivered no samples for 13 to 605 ms. In three such runs the sibling delivered 23%, 42% and 55% of the samples of the leader. Opened as two independent events, both deliver the same number. The counts stay right in all cases, it is the samples which are missing. This patch only changes amd_pmu_v2_handle_irq(), where the warning is. I can send patches for x86_pmu_handle_irq() and handle_pmi_common() with the same approach, if that is how you want it fixed. >> + /* Stopped by a group throttle in an earlier iteration */ > > Nit: Can this comment be more explicit: > > /* > * Group was throttled in an earlier iteration; re-arm the > * counter without delivering the sample. > */ Sure, I will use that in v2. Thanks, Catalin