Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp500924lqp; Wed, 12 Jun 2024 07:57:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUaWVAu/JAwxBr/Buz2IRDftyCykEHXLrbKxiTqVYlY5hqUjrQYLWTlG+uoRcFAIUm3zfQ7fyqO1lYKyPL1ofcZQ43NPboNlACFjr72JQ== X-Google-Smtp-Source: AGHT+IHLEd+5dSDejLHjS31Dd6Dudv1N7p86KHB2H940l8z6ssSgzozH37KRFOQNtSYQCbfFKuYL X-Received: by 2002:a05:620a:4607:b0:795:5d1e:2f05 with SMTP id af79cd13be357-797f60a41f5mr211387485a.19.1718204277589; Wed, 12 Jun 2024 07:57:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718204277; cv=pass; d=google.com; s=arc-20160816; b=ZYCMkk6YlcRtULNqI32h+0J/L5WGki4p1HymwOa1CYvPckKDIfPGz4iPOzh1R4khtA XvUB8O7M+iDbeLJwey2NAWqtp5H1EVx1fjcY/U+l/rfaoIxVIAP70mhyP+QTxfP/Nzmo MyoyKEXPvJJCy+TaKwLa009gdAZcbFUBDH4ZurugMzJ66n7FpUVTE70uCdM+CbP29qTs SiUFQc9RgRipbBTpjOiKIAq6gbx0Gr5OKzTIoPKOSU9K7X0APKwuqvTWDf4pRG/rymi5 L1nJGWSy/y8NF2CC9F3kNey/LzTaMRV6AgWL9tsdHqKZ7/QajRpce8gbxqRftfXNzVlt adeg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Plug/FubSS9ewmpduy54mROO8mLilKQ8oOX0XAiB/Gs=; fh=3YHymDS5tAFl2VcIlUFdw3KxfkLYnFcAYWn0f81LYfs=; b=OlJzH/x6KDWsNlbO/stYDGS96LLvuCmsGi5TX0D6h2U1R2Q//XEdB+rDTT6ouuFIB/ C6PPqz0dR/Misr4ZOI4wpYUH4mbSXN7e+CIVtcTzxDIXfygo7htjnHfYS8SBU3KsP5mJ xBYbptiHLFbKgL1RW3PRtv89xq6/d3NkHCfmFuZckhhUwqDzOJtBebFBccVgrbsSWA+q H8mJZ7hddWKxYHE2WrNll7kVeJV/fDwNOfA9GSEfKJD2W8j/4ma5GdDwXv9NM/3aE2D6 7ItZeIjzj46wIxRDqbPdQtpCnNajmq8qDiKL3mqN/LK3LYdxzshKRAgJweCTRVqTkH/P upFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DtdtnfeD; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-211721-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211721-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-795331d323bsi1508481885a.260.2024.06.12.07.57.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 07:57:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211721-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DtdtnfeD; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-211721-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211721-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 40B6E1C22888 for ; Wed, 12 Jun 2024 14:57:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39EB617FABD; Wed, 12 Jun 2024 14:57:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DtdtnfeD" Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF0CC17F4EE for ; Wed, 12 Jun 2024 14:57:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718204223; cv=none; b=CaPMZDqlAu4CPRQnwxuhy3m5DdO/tDvl6rYa5iOfvAA1cBPi8O+W2m3hcazCVA83jElRLh/Ytd5nI0q/6CuBGrpmvuhWJK7AtWVSrLwpVkU204FWt7DfQ+zqjUxfgTv33yTjLFpArtWT7AUuNfxrNb54BBiq3sbIgEgZ5m0/zO0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718204223; c=relaxed/simple; bh=kXvqJOj2qmIJtlSAfCsHO42GGGkuDIC0ENSaA26lh7s=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=nwGElxuj7k9Z9HDAtdRh+yfutCw27hKdKROwhKAghU94I8Fh49Q5jG7y/WcNabgcvZ1bZwDVGBm69ZkoTdOwJ5mpYQcl+jeY7yWiUNVEmMi3ZvVG+QlxnCw1UaC0LZleFrrFO91YJ4vQ9D5ZkOp2pBBrD06vPzHg4qcJhzC2qOA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=DtdtnfeD; arc=none smtp.client-ip=209.85.166.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-375bb80e5b8so133585ab.1 for ; Wed, 12 Jun 2024 07:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718204220; x=1718809020; 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=Plug/FubSS9ewmpduy54mROO8mLilKQ8oOX0XAiB/Gs=; b=DtdtnfeDIzv2aHUdLeehBrRIXrgnG39ZxfDCbqrBnnr1KFr6oXG3tume+V6wBO/fmx QjgUR0EVBLh3bLpIjy9a3RpkikjSGqhC23XlKYvOOHXrpmzTbJLe6c3b0/X7cG6K6rKN vlrQtwgnGU62ZjIfOnuRDGwv+SQVC8YLl1Qap6AZzTLPtH8nb/xbf3Tt8B9x3FWqqWPY +O7XpyU87FjNYN8sRGAMLtG4Nl8QsNTvdGhNoz3PWqwWwtB8o3q/nRvHuUzFPo6BLea3 27sApHvd1J3hKD76gJuJ/1c4xRuAhv9igfP9QatNsrSwHOaObpvP2lXDShmwnT+UQZFU HInA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718204220; x=1718809020; 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=Plug/FubSS9ewmpduy54mROO8mLilKQ8oOX0XAiB/Gs=; b=YpwLrwGhtBKkj6w51kzqQjLJvIBGoW1LJ6aAazWrupxkeSGEJ1xGwlP/NhR5ENc1gk p2A5bXxh5GSlrXD/l4/sPjw1M1PYSr0jm8b3+f5V9n0LT4lrvVGttapimsfI0hvNnY1+ ti/9FRHG6rfXZOVNQ9dz3dlA0OoIYEyhRHvIE3+OeCx5GruNzWRIYG8lhykHP8tLCpAU lsBCvWeIKyaTSvEyBaKGu4xvbJu0LSXi73wuEwvJER9eBNlEtI9BhMZD9Us/k01zysqM 75fkQScuqbojp3oS6uY0ldelKxvr6+cFXPn2Z9aGhVy1JZLF7ZQ6lA7B8JIHr0IYiJ3q EpiQ== X-Forwarded-Encrypted: i=1; AJvYcCWfGLFLiTJ/xFICNztgHkNQSnjlFyMH3i6dYNOLTZnuWfZka7FgiWwCs5sCvMlpeGIvVBmek7YuQMAGinYP7WyYlz5ay4d4VZv8cxke X-Gm-Message-State: AOJu0Yz5t3u3aQTkfunGrYmbFuBlQQrfcK5B0TGBTr5A9WzKCMpDcsAq VtLd/adWNESHdPUTycvg0sPa9ObvXxhXKU+jaHNywblkJAsLCSJMvmc4/CIVH5Q71jVtwVR8akv wTj5cA08dwNZStirPZQPXPn3cI4+Xl9g4Q7wB X-Received: by 2002:a05:6e02:3188:b0:375:9ed9:1322 with SMTP id e9e14a558f8ab-375cb514668mr3822735ab.16.1718204219578; Wed, 12 Jun 2024 07:56:59 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240515060114.3268149-1-irogers@google.com> <20240515060114.3268149-2-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Wed, 12 Jun 2024 07:56:48 -0700 Message-ID: Subject: Re: [PATCH v6 1/2] perf pmus: Sort/merge/aggregate PMUs like mrvl_ddr_pmu To: Robin Murphy Cc: Aishwarya TCV , Tuan Phan , Thomas Richter , Bhaskara Budiredla , Bharat Bhushan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , James Clark , Ravi Bangoria , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Will Deacon , Stephane Eranian , Mark Brown , Naresh Kamboju Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jun 12, 2024 at 6:57=E2=80=AFAM Robin Murphy = wrote: > > On 12/06/2024 1:32 pm, Ian Rogers wrote: > > On Wed, Jun 12, 2024 at 4:19=E2=80=AFAM Aishwarya TCV wrote: > >> > >> > >> > >> On 15/05/2024 07:01, Ian Rogers wrote: > >>> The mrvl_ddr_pmu is uncore and has a hexadecimal address suffix while > >>> the previous PMU sorting/merging code assumes uncore PMU names start > >>> with uncore_ and have a decimal suffix. Because of the previous > >>> assumption it isn't possible to wildcard the mrvl_ddr_pmu. > >>> > >>> Modify pmu_name_len_no_suffix but also remove the suffix number out > >>> argument, this is because we don't know if a suffix number of say 100 > >>> is in hexadecimal or decimal. As the only use of the suffix number is > >>> in comparisons, it is safe there to compare the values as hexadecimal= . > >>> Modify perf_pmu__match_ignoring_suffix so that hexadecimal suffixes > >>> are ignored. > >>> > >>> Only allow hexadecimal suffixes to be greater than length 2 (ie 3 or > >>> more) so that S390's cpum_cf PMU doesn't lose its suffix. > >>> > >>> Change the return type of pmu_name_len_no_suffix to size_t to > >>> workaround GCC incorrectly determining the result could be negative. > >>> > >>> Signed-off-by: Ian Rogers > >>> --- > >>> tools/perf/util/pmu.c | 33 +++++++++++++-------- > >>> tools/perf/util/pmus.c | 67 ++++++++++++++++++++++++---------------= --- > >>> tools/perf/util/pmus.h | 7 ++++- > >>> 3 files changed, 65 insertions(+), 42 deletions(-) > >>> > >> > >> Hi Ian, > >> > >> Perf test "perf_all_PMU_test" is failing when run against > >> next-master(next-20240612) kernel with Arm64 on JUNO in our CI. It loo= ks > >> like it is failing when run on JUNO alone. Verified by running on othe= r > >> boards like RB5 and Ampere_altra and confirming that it does not fail = on > >> these boards. Suspecting that the suffixed 'armv8_pmuv3_0' naming coul= d > >> be the reason of test failure. > >> > >> Reverting the change (3241d46f5f54) seems to fix it. > >> > >> This works fine on Linux version v6.10-rc3 > >> > >> Failure log > >> ------------ > >> 110: perf all PMU test: > >> --- start --- > >> test child forked, pid 8279 > >> Testing armv8_pmuv3/br_immed_retired/ > >> Event 'armv8_pmuv3/br_immed_retired/' not printed in: > >> # Running 'internals/synthesize' benchmark: > >> Computing performance of single threaded perf event synthesis by > >> synthesizing events on the perf process itself: > >> Average synthesis took: 1169.431 usec (+- 0.144 usec) > >> Average num. events: 35.000 (+- 0.000) > >> Average time per event 33.412 usec > >> Average data synthesis took: 1225.698 usec (+- 0.102 usec) > >> Average num. events: 119.000 (+- 0.000) > >> Average time per event 10.300 usec > >> > >> Performance counter stats for 'perf bench internals synthesize': > >> > >> 3263664785 armv8_pmuv3_0/br_immed_retired/ > >> > >> > >> 25.472854464 seconds time elapsed > >> > >> 8.004791000 seconds user > >> 17.060209000 seconds sys > >> ---- end(-1) ---- > >> 110: perf all PMU test : > >> FAILED! > > > > Hi Aishwarya, > > > > Thanks for reporting an issue. The test should be pretty self > > explanatory: it is doing a `perf stat -e > > armv8_pmuv3/br_immed_retired/` and then looking for that in the > > output. The event armv8_pmuv3/br_immed_retired/ comes from running > > perf list. As you can see in the output the event did work, so perf > > stat is working so nothing is actually broken here. What isn't working > > is the perf stat output matching the command line event and this is > > because of the unnecessary suffix on ARM's PMU name. > > > > We have a problem that ARM have buggy PMU drivers, either from > > introducing new naming conventions or by just being broken: > > https://lore.kernel.org/lkml/CAP-5=3DfWNDkOpnYF=3D5v1aQkVDrDWsmw+zYX1pj= S8hoiYVgZsRGA@mail.gmail.com/ > > I've also asked that ARM step up their testing, for example in the > > event parsing testing the PMU is hardcoded to the x86 PMU name of > > 'cpu': > > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.gi= t/tree/tools/perf/tests/parse-events.c?h=3Dperf-tools-next#n2317 > > On a cortex A53, then PMU is named 'armv8_cortex_a53': > > ``` > > $ ls /sys/devices/armv8_cortex_a53/ > > caps cpus events format perf_event_mux_interval_ms power > > subsystem type uevent > > ``` > > This name appears better, so what's up with ARM's core PMU name? > > With Devicetree, we are able to derive a descriptive PMU name from the > compatible string provided by the DT. Under ACPI, however, all we get > told is whether each CPU has a usable PMU or not, so the best we can do > is work out how many different CPU microarchitectures we have overall > and create a PMU instance for each type. We still don't know *what* each > one is, just that they're different, hence ending up with a common name > plus a suffix which we can increment for disambiguation if and when we > do see something new - userspace can still piece together the "cpus" > lists and MIDRs to figure out what's what, we just can't do much in the > kernel itself. > > > Anyway, I'm tempted to fix this by just skipping the test on ARM given > > ARM's overall broken state. > > This isn't a driver issue, it's a "the behaviour of 'perf list' changed > inconsistently" issue. I also had a brief dig into this using a > different arm64 ACPI system, and I think I can broadly characterise the > cause. This is prior to 3241d46f5f54: > > root@crazy-taxi:~# ./perf-mainline list armv8_pmuv3 > > List of pre-defined events (to be used in -e or -M): > > > armv8_pmuv3_0: > L1-dcache-loads OR armv8_pmuv3_0/L1-dcache-loads/ > L1-dcache-load-misses OR armv8_pmuv3_0/L1-dcache-load-misses/ > L1-icache-loads OR armv8_pmuv3_0/L1-icache-loads/ > L1-icache-load-misses OR armv8_pmuv3_0/L1-icache-load-misses/ > dTLB-loads OR armv8_pmuv3_0/dTLB-loads/ > dTLB-load-misses OR armv8_pmuv3_0/dTLB-load-misses/ > iTLB-loads OR armv8_pmuv3_0/iTLB-loads/ > iTLB-load-misses OR armv8_pmuv3_0/iTLB-load-misses/ > branch-loads OR armv8_pmuv3_0/branch-loads/ > branch-load-misses OR armv8_pmuv3_0/branch-load-misses/ > l3d_cache_wb OR armv8_pmuv3_0/l3d_cache_wb/ [Kernel PMU event] > > > And this is after: > > root@crazy-taxi:~# ./perf-next list armv8_pmuv3 > > List of pre-defined events (to be used in -e or -M): > > > armv8_pmuv3_0: > L1-dcache-loads OR armv8_pmuv3_0/L1-dcache-loads/ > L1-dcache-load-misses OR armv8_pmuv3_0/L1-dcache-load-misses/ > L1-icache-loads OR armv8_pmuv3_0/L1-icache-loads/ > L1-icache-load-misses OR armv8_pmuv3_0/L1-icache-load-misses/ > dTLB-loads OR armv8_pmuv3_0/dTLB-loads/ > dTLB-load-misses OR armv8_pmuv3_0/dTLB-load-misses/ > iTLB-loads OR armv8_pmuv3_0/iTLB-loads/ > iTLB-load-misses OR armv8_pmuv3_0/iTLB-load-misses/ > branch-loads OR armv8_pmuv3_0/branch-loads/ > branch-load-misses OR armv8_pmuv3_0/branch-load-misses/ > l3d_cache_wb OR armv8_pmuv3/l3d_cache_wb/ [Kernel PMU event] > > See the difference in the last line - it appears that CPU PMU events > which map to common hardware/cache events *do* still report the full PMU > name, but any PMU-type-specific events show a truncated name in list and > thus fail the test's strict match against the full name reported by stat. Thanks Robin. The hardware and cache events are legacy events that are printed here, the assumption being that core PMUs don't use a suffix: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tr= ee/tools/perf/util/print-events.c?h=3Dperf-tools-next#n304 Fwiw these events are knowingly broken on the Apple M? ARM PMUs as legacy events like L1-dcache-loads will use a legacy encoding which is broken on this PMU, hence trying to migrate to preferring sysfs/json events first - the support for which is reverted in v6.10. The l3d_cache_wb event is not a legacy event and so goes down the regular PMU event printing route that tries to avoid listing duplicate PMUs as there may be 10s or 100s of these: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tr= ee/tools/perf/util/pmus.c?h=3Dperf-tools-next#n490 Yes, this was an intentional behavior change as system scale has gotten lar= ger. I'm currently thinking that the suffix should just be ignored on core PMUs, we assume they never have duplicates. Unfortunately the code just has a name and doesn't know from this whether a PMU is core or not: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tr= ee/tools/perf/util/pmus.c?h=3Dperf-tools-next#n43 Note, following Kan Liang's advice we've been trying to actually document the PMU naming convention: https://lore.kernel.org/lkml/20240606044959.335715-1-irogers@google.com/ The inconsistency here comes from ARM core PMUs using suffixes, which isn't really intended behavior and will likely screw up, my guess is around legacy events (the tests of which currently have limited ARM coverage). Thanks, Ian > Thanks, > Robin.