From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8DCB9C2BD09 for ; Mon, 1 Jul 2024 14:44:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GUxJjHzj8Hmvvj2UuYtZeRJadX+8v+WhUOwONdmMSV4=; b=Qrm5kbkceTCy+kA/P8IK1K+KaW D4QTtxq1tENpkaNsQDBbsgCsq2dsR39a9iO323FI+jTKdUi30dG7+pBQENBkpDSnwVaRVFZ6Wurrc rTSAFblT2AawsFbHcrlVeIYOirmCT7iwyn76ECPWzD6vKlu4C6d57gViQuWL1wmGV7wnIV1Vf+8Yi QtYeGMgsXOOjx6tWE1/+QMv0Rh6tVjLUHAPoDxt31IeJya/ZuW16y3ML5QBa1FSURE7XSyy0hZqnn ATIlIz19WF8/iTWrqOYqcyWhtgDGd7dBbLzEC2AzT3eKCMU8cL+whEB5r0H0Lab3DiHM/devnDyWX Qy5XcrBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOIG4-00000003lqu-3rKn; Mon, 01 Jul 2024 14:43:57 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOIFt-00000003lnm-2Aab for linux-arm-kernel@lists.infradead.org; Mon, 01 Jul 2024 14:43:47 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 97A3ECE1708; Mon, 1 Jul 2024 14:43:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7471C116B1; Mon, 1 Jul 2024 14:43:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719845022; bh=bG2ru4fWCajW+qe+qA7NC/B+XA3N0d8dcjIR0OxiVhs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AObP9STyNMqcLb1LLilzdg7DMSkjB6Ji+XjK3vmCcyvKgrt1BXNSmuMOWqoNx05ak o+v0UK/0OSb2Ri2l6y/IdP3AtwbBMupdpBdr1nQxvg3ZZ4fxw60nqtX22OlHoM623S iPzRcOW+XJ+FQNxwL530PFUMjjBFSjj5XTSV/KD9rPU15SOttylRtq8ei69nQ+0+pH px2G4mazmq495kctJOz9rj9or8s+U+97wnI16sgJ9gfdmlOu4y6EpxzrwjySOu8UBt xKUp5yWidHSPRkih1FHr9fkeE9R7blK+VF0+KmFkhA30Qqz6I+rhJMLajxEphrMFbP rCwPv+OLfWkbA== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sOIFo-008peG-HV; Mon, 01 Jul 2024 15:43:40 +0100 Date: Mon, 01 Jul 2024 15:43:40 +0100 Message-ID: <87bk3hp3z7.wl-maz@kernel.org> From: Marc Zyngier To: Yangyu Chen , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Mark Rutland , Janne Grunau , Hector Martin , Asahi Lina , asahi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] drivers/perf: apple_m1: fix affinity table for event 0x96 and 0x9b In-Reply-To: <87cynxp52o.wl-maz@kernel.org> References: <20240701140148.GE2250@willie-the-truck> <87cynxp52o.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: cyy@cyyself.name, will@kernel.org, linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, j@jannau.net, marcan@marcan.st, lina@asahilina.net, asahi@lists.linux.dev, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240701_074345_941671_2CBA698E X-CRM114-Status: GOOD ( 31.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 01 Jul 2024 15:19:59 +0100, Marc Zyngier wrote: > > On Mon, 01 Jul 2024 15:01:48 +0100, > Will Deacon wrote: > > > > On Thu, Jun 20, 2024 at 11:04:28AM +0800, Yangyu Chen wrote: > > > Events 0x96 and 0x9b can be installed on counter 7 only. Fix this to avoid > > > getting the wrong counter value. > > > > > > Signed-off-by: Yangyu Chen > > > --- > > > drivers/perf/apple_m1_cpu_pmu.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/perf/apple_m1_cpu_pmu.c b/drivers/perf/apple_m1_cpu_pmu.c > > > index f322e5ca1114..b8127e5428e1 100644 > > > --- a/drivers/perf/apple_m1_cpu_pmu.c > > > +++ b/drivers/perf/apple_m1_cpu_pmu.c > > > @@ -107,12 +107,12 @@ static const u16 m1_pmu_event_affinity[M1_PMU_PERFCTR_LAST + 1] = { > > > [M1_PMU_PERFCTR_UNKNOWN_93] = ONLY_5_6_7, > > > [M1_PMU_PERFCTR_UNKNOWN_94] = ONLY_5_6_7, > > > [M1_PMU_PERFCTR_UNKNOWN_95] = ONLY_5_6_7, > > > - [M1_PMU_PERFCTR_UNKNOWN_96] = ONLY_5_6_7, > > > + [M1_PMU_PERFCTR_UNKNOWN_96] = BIT(7), > > > [M1_PMU_PERFCTR_UNKNOWN_97] = BIT(7), > > > [M1_PMU_PERFCTR_UNKNOWN_98] = ONLY_5_6_7, > > > [M1_PMU_PERFCTR_UNKNOWN_99] = ONLY_5_6_7, > > > [M1_PMU_PERFCTR_UNKNOWN_9a] = BIT(7), > > > - [M1_PMU_PERFCTR_UNKNOWN_9b] = ONLY_5_6_7, > > > + [M1_PMU_PERFCTR_UNKNOWN_9b] = BIT(7), > > > [M1_PMU_PERFCTR_UNKNOWN_9c] = ONLY_5_6_7, > > > [M1_PMU_PERFCTR_UNKNOWN_9f] = BIT(7), > > > [M1_PMU_PERFCTR_UNKNOWN_bf] = ONLY_5_6_7, > > > > It would be great if somebody with access to M1 hardware (and/or any > > PMU insight) could Test or Ack this, please. > > I'm a bit concerned by this. > > I originally generated this table by hacking the counter setup so that > it would try and count everywhere, and then feed the observations back > into the driver. > > So either my methodology was flaky (not unlikely), but I'd then expect > more of these mis-assignments, or this applies to an implementation > that is different from the one I wrote this driver against (the > original M1). Could it be that this for M2 only, and not M1? Or > another flavour of M1? > > Either way, it would be good to understand how this has been > established. > > In the meantime, I'll try and resurrect my original experiment and see > if I spot the same issue. A quick experiment shows that these events are counting on all 3 expected counters: maz@mary-lou:~$ sudo taskset -c 8 perf stat -e r096:u -e r096:u -e r096:u sleep 5 Performance counter stats for 'sleep 5': 10,775 r096:u 10,775 r096:u 10,775 r096:u 5.000110823 seconds time elapsed 0.000340000 seconds user 0.000000000 seconds sys maz@mary-lou:~$ sudo taskset -c 8 perf stat -e r09b:u -e r09b:u -e r09b:u sleep 5 Performance counter stats for 'sleep 5': 41,927 r09b:u 41,927 r09b:u 41,927 r09b:u 5.000109771 seconds time elapsed 0.000339000 seconds user 0.000000000 seconds sys This is on M2 Pro, by the way, and I also checked that my M1 Ultra counts the exact same way. Yangyu, can you please clarify how you came to the conclusion that these events didn't count anywhere other than counter 7? M. -- Without deviation from the norm, progress is not possible.