Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp516774rdf; Tue, 21 Nov 2023 08:39:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8rFsO4yzCYPzGjzVjPWvirbaOCU82A2yok78HYe94qtA5VG6/94AHdizAYTwXtHJ3npUD X-Received: by 2002:a17:902:e84f:b0:1ce:1603:f50e with SMTP id t15-20020a170902e84f00b001ce1603f50emr10540513plg.42.1700584749036; Tue, 21 Nov 2023 08:39:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700584749; cv=none; d=google.com; s=arc-20160816; b=Yg3225gyBo+axu1Ok2EenavLoxZkrDQ5vYHc+BU3j5p7VxOyD3yYVfQAEM1AW8JYm/ rq+XL+87VQn3/mJSGc7ZauBepNn0ZUViUkNdql6/yDzEbn73tucQOgW8wvztGRAv/BOJ Adlw0XrsON1Ed4QSs3tjH3gd6PuBArnpKjFGCCte9jRfwNBhWYQx6qzxMG5fVQ6iTCdn VEilTBv+hUMmDpXIjQsDF9qzzik2obl7nFReZUW+QIi5wO+yQS7CAleNyFQc9cZk4QD7 Zew0MQesUsKWfMtQky6xmuJ/wJD73QOdwkEcG4+XGrpiohOlndqDud/+oslNCMZto4ks IisQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=H9XU0AWE1T+1mScmN12mxBP4eAvi45H7i3NBZsgxcv4=; fh=Mmu/H+wU+pFPLcntLNif9vDtLWgRTARMSz7TRsJ3X2A=; b=03CoxYVJDQLl9Xd1Kml0n1taRA4EKolLaWjWXiEr6429/uDhEdf7Oj7AUyxl0HPnE/ QLmI7+aDk560rDO1nY/9PtfokNm/RuTa5VeJ4ZUwI/gS5qO0oJHGl9cufPpWWImGklJ0 qCXExj2+ztEdRed/eTS0wwqPqhPDy99gdtFCD9vO2Wz4Dcp3DtXCG4tZ9qk3EsuIVTBi EpaEy1YY82be6/fxCZPW3v0GvErY6YxVpHoC0tGbEz6hKaS+0Ii4+ugtDEh/LX4tAGr/ A/fWFO8OFE4/vZddt7ppvrysg6FvZVv+kGiUdiGcfm+EiHoNGiu9JdPmVHEF2/8wbwEM cv5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DCvBN3he; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id i7-20020a1709026ac700b001cf579f7584si6471085plt.376.2023.11.21.08.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 08:39:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DCvBN3he; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6E2B0804ACCD; Tue, 21 Nov 2023 08:39:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233961AbjKUQjG (ORCPT + 99 others); Tue, 21 Nov 2023 11:39:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233556AbjKUQjE (ORCPT ); Tue, 21 Nov 2023 11:39:04 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB2F9100 for ; Tue, 21 Nov 2023 08:38:59 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4078fe6a063so69515e9.1 for ; Tue, 21 Nov 2023 08:38:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700584738; x=1701189538; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=H9XU0AWE1T+1mScmN12mxBP4eAvi45H7i3NBZsgxcv4=; b=DCvBN3heWs1FUS3O0ktwBVILNZrygL11zFqSdRjMqGkimq4dINCLsdd8WmOov6+Fts ugDEJuPkCjgGRM84q8u9oBCZQ32+ljr9aSuxbZpr4zvzRDNVnR1WZhPfWb2KYDG66NdL M34TeeXqOswfeO/42ZhUnWS5oKI/nUMw/Qut+5Ksf9D4LSMdgPV5v564cAubV+bQ0/9M JGAXHz2X9TkbWbGM6HGeQACxotljzhecS3t9hs/PGLDqu7kDVPduYUzZfxxsclBbA9ZB JWtq4A5gHMOyXaODFUVlk6gSjaorpVo0EOlUPPFmYwnt82OzNxbn7IFsAH9nMxysuNkZ Q+5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700584738; x=1701189538; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H9XU0AWE1T+1mScmN12mxBP4eAvi45H7i3NBZsgxcv4=; b=gj9gP2XH20nOuqpHzKY4KzCh5vHgMjtGCHiExsuMAHhjoKdT8cGeoCV5jG/EcGpzMq mimLwMYO+Vm5AoNoB03sWxz2uMG9OHRKIlbbAcgZVcdpqhtzszvM5qItI4vASmUzKp7T aRUdMBmW8Lb0gCQalEgrV+A6WrcBM1SgSv4jGecliT+jXzW8LkzDHjcGBnWEiLQLkooA iSODEBSquDf4G+SG2vWe47KFLbyyFYW8RuHfZqR0onEk9AqUc+RScJ+TAjz1q/UOOLbA Ib81DGMVITrmUcebDoKRIAfqUpUrD56jJMpn0uUmUmxtnqdX5RpuK7r514LV7wJO9qLE /fzQ== X-Gm-Message-State: AOJu0YzzKsn+28CO17K5y3qF8nyCdNon44yQcgOm/KyRxfTq9k9pY6wi pyWa1XdSCOZfmZraut3s56XRje/mHydzWWr6/9cp0A== X-Received: by 2002:a05:600c:c8d:b0:40b:2ec6:2a87 with SMTP id fj13-20020a05600c0c8d00b0040b2ec62a87mr8380wmb.5.1700584737994; Tue, 21 Nov 2023 08:38:57 -0800 (PST) MIME-Version: 1.0 References: <08f1f185-e259-4014-9ca4-6411d5c1bc65@marcan.st> <86pm03z0kw.wl-maz@kernel.org> <86o7fnyvrq.wl-maz@kernel.org> In-Reply-To: From: Ian Rogers Date: Tue, 21 Nov 2023 08:38:45 -0800 Message-ID: Subject: Re: [REGRESSION] Perf (userspace) broken on big.LITTLE systems since v6.5 To: Mark Rutland Cc: Marc Zyngier , Hector Martin , Arnaldo Carvalho de Melo , James Clark , linux-perf-users@vger.kernel.org, LKML , Asahi Linux Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 08:39:07 -0800 (PST) On Tue, Nov 21, 2023 at 8:15=E2=80=AFAM Mark Rutland = wrote: > > On Tue, Nov 21, 2023 at 08:09:37AM -0800, Ian Rogers wrote: > > On Tue, Nov 21, 2023 at 8:03=E2=80=AFAM Mark Rutland wrote: > > > > > > On Tue, Nov 21, 2023 at 07:46:57AM -0800, Ian Rogers wrote: > > > > On Tue, Nov 21, 2023 at 7:40=E2=80=AFAM Mark Rutland wrote: > > > > > > > > > > On Tue, Nov 21, 2023 at 03:24:25PM +0000, Marc Zyngier wrote: > > > > > > On Tue, 21 Nov 2023 13:40:31 +0000, > > > > > > Marc Zyngier wrote: > > > > > > > > > > > > > > [Adding key people on Cc] > > > > > > > > > > > > > > On Tue, 21 Nov 2023 12:08:48 +0000, > > > > > > > Hector Martin wrote: > > > > > > > > > > > > > > > > Perf broke on all Apple ARM64 systems (tested almost everyt= hing), and > > > > > > > > according to maz also on Juno (so, probably all big.LITTLE)= since v6.5. > > > > > > > > > > > > > > I can confirm that at least on 6.7-rc2, perf is pretty busted= on any > > > > > > > asymmetric ARM platform. It isn't clear what criteria is used= to pick > > > > > > > the PMU, but nothing works anymore. > > > > > > > > > > > > > > The saving grace in my case is that Debian still ships a 6.1 = perftool > > > > > > > package, but that's obviously not going to last. > > > > > > > > > > > > > > I'm happy to test potential fixes. > > > > > > > > > > > > At Mark's request, I've dumped a couple of perf (as of -rc2) ru= ns with > > > > > > -vvv. And it is quite entertaining (this is taskset to an 'ice= storm' > > > > > > CPU): > > > > > > > > > > IIUC the tool is doing the wrong thing here and overriding explic= it > > > > > ${pmu}/${event}/ events with PERF_TYPE_HARDWARE events rather tha= n events using > > > > > that ${pmu}'s type and event namespace. > > > > > > > > > > Regardless of the *new* ABI that allows PERF_TYPE_HARDWARE events= to be > > > > > targetted to a specific PMU, it's semantically wrong to rewrite e= vents like > > > > > this since ${pmu}/${event}/ is not necessarily equivalent to a si= milarly-named > > > > > PERF_COUNT_HW_${EVENT}. > > > > > > > > If you name a PMU and an event then the event should only be opened= on > > > > that PMU, 100% agree. There's a bunch of output, but when the legac= y > > > > cycles event is opened it appears to be because it was explicitly > > > > requested. > > > > > > I think you've missed that the named PMU events are being erreously t= ransformed > > > into PERF_TYPE_HARDWARE events. Look at the -vvv output, e.g. > > > > > > Opening: apple_firestorm_pmu/cycles/ > > > ------------------------------------------------------------ > > > perf_event_attr: > > > type 0 (PERF_TYPE_HARDWARE) > > > size 136 > > > config 0 (PERF_COUNT_HW_CPU_CYCLES) > > > sample_type IDENTIFIER > > > read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RU= NNING > > > disabled 1 > > > inherit 1 > > > enable_on_exec 1 > > > exclude_guest 1 > > > ------------------------------------------------------------ > > > sys_perf_event_open: pid 1045843 cpu -1 group_fd -1 flags 0x8 = =3D 4 > > > > > > ... which should not be PERF_TYPE_HARDWARE && PERF_COUNT_HW_CPU_CYCLE= S. > > > > > > Marc said that he bisected the issue down to commit: > > > > > > 5ea8f2ccffb23983 ("perf parse-events: Support hardware events as te= rms") > > > > > > ... so it looks like something is going wrong when the events are bei= ng parsed, > > > e.g. losing the HW PMU information? > > > > Ok, I think I'm getting confused by other things. This looks like the i= ssue. > > > > I think it may be working as intended, but not how you intended :-) If > > a core PMU is listed and then a legacy event, the legacy event should > > be opened on the core PMU as a legacy event with the extended type > > set. This is to allow things like legacy cache events to be opened on > > a specified PMU. Legacy event names match with a higher priority than > > those in sysfs or json as they are hard coded. > > That has never been the case previously, so this is user-visible breakage= , and > it prevents users from being able to do the right thing, so I think that'= s a > broken design. So the problem was caused by ARM and Intel doing two different things. Intel did at least contribute to the perf tool in support for their BIG.little/hybrid, so that's why the semantics match their approach. > > Presumably the expectation was that by advertising a cycles event, pres= umably > > in sysfs, then this is what would be matched. > > I expect that if I ask for ${pmu}/${event}/, that PMU is used, and the ev= ent > *in that PMU's namespace* is used. Overriding that breaks long-establishe= d > practice and provides users with no recourse to get the behavioru they ex= pect > (and previosuly had). On ARM but not Intel. > I do think that (regardless of whther this was the sematnic you intended) > silently overriding events with legacy events is a bug, and one we should= fix. > As I mentioned in another reply, just because the events have the same na= me > does not mean that they are semantically the same, so we're liable to giv= e > people the wrong numbers anyhow. > > Can we fix this? So I'd like to fix this, some things from various conversations: 1) we lack testing. Our testing relies on the sysfs of the machine being run on, which is better than nothing. I think ideally we'd have a collection of zipped up sysfs directories and then we could have a test that asserts on ARM you get the behavior you want. 2) for RISC-V they want to make the legacy event matching something in user land to simplify the PMU driver. 3) I'd like to get rid of the PMU json interface. My idea is to convert json events/metrics into sysfs style files, zip these up and then link them into the perf binary. On Intel the json is 70% of the binary (7MB out of 10MB) and we may get this down to 3MB with this approach. The json lookup would need to incorporate the cpuid matching that currently exists. When we look up an event I'd like the approach to be like unionfs with a specified but configurable order. Users could provide directories of their own events/metrics for various PMUs, and then this approach could be used to help with (1). Those proposals are not something to add as a -rc fix, so what I think you're asking for here is a "if ARM" fix somewhere in the event parsing. That's of course possible but it will cause problems if you did say: perf stat -e arm_pmu/LLC-load-misses/ ... as I doubt the PMU driver is advertising this legacy event in sysfs and the "if ARM" logic would presumably be trying to disable legacy events in the term list for the ARM PMU. Given all of this, is anything actually broken and needing a fix for 6.7? Thanks, Ian > Mark.