Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp491022rdf; Tue, 21 Nov 2023 08:04:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHTkRfcawVuqgQ9vIdFANSeGtsQZE52xN5hIiY9JF0VgDIroxCRjNKyFgBhA/mkkyg5GXNK X-Received: by 2002:a05:6870:f696:b0:1f5:cf0e:ea04 with SMTP id el22-20020a056870f69600b001f5cf0eea04mr6282452oab.58.1700582649595; Tue, 21 Nov 2023 08:04:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700582649; cv=none; d=google.com; s=arc-20160816; b=TJhAtpb5TaFxoS0HviGc+O8/CIHwjwktivKTOeVArbzp2q15mg7lePYuwQ0p4XWuV/ pm5qM1aFTBZnRwdYI/pFyLnIz2tZqfUTgHDmIHiHWMwHmRue8QgSq9hManbS7ASVFaZY ggmQC/jtzTLN99fANi92H4s/igNPiYs6gI2wYGZOZrrarXWIBOgJzK7Ok77gaDur+u6j p/kzxIQPzVJLkd0pY4KTIa/flgIlwgC+Vuvz6fPxLOZ+75quW1WFhY7+JyBGvGuRVBdc VXgJq7KF+h1ACZh9ptuQ7IHrfXgC4ag1KVOI10pJKcad9bUmcoIbrUOAnwjio8MvY8Pj osDQ== 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=YNQwcfbwd5MPP15HDWRuvMnBXafc9Od52XUUUFOJgh0=; fh=Mmu/H+wU+pFPLcntLNif9vDtLWgRTARMSz7TRsJ3X2A=; b=FLdRedhEkjAY5fKwd1w6uZBRqfzkHc0gENUUZS2K6GGzy9obV49gZwwSxvhe1amWYT ZUXED8KpKrE/5BS6VBA0cJ9IdwzkUUeZwOOO8OxF3YZoDCAmqZ24X7zlF7ZFp9yAT5kh JDimJ9OX8MuVdDqTIhB5b98tjv8rChKI6SaDjEOGQtvs+wvt0YvH7WYyB/73vXTKJmG1 6/eJHf84lBQSPMnZYrvGYpdDF5I4q+DIb2G/W2GKM0AMej+u9revPbch6kKdG5/RSRck dzBXtzp9xv8oyXioo2Ll/66tqy44KlCcMcnhTrXjZIfctbpidjNtPIEjFz7UtNXW1B1/ Se/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PjSozKHp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id pn12-20020a0568704d0c00b001f9352e04c8si1748741oab.169.2023.11.21.08.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 08:04:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PjSozKHp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id B19668026E2C; Tue, 21 Nov 2023 08:04:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233924AbjKUQDd (ORCPT + 99 others); Tue, 21 Nov 2023 11:03:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234878AbjKUQDb (ORCPT ); Tue, 21 Nov 2023 11:03:31 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14FF4194 for ; Tue, 21 Nov 2023 08:03:25 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-548ae9a5eeaso13221a12.1 for ; Tue, 21 Nov 2023 08:03:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700582603; x=1701187403; 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=YNQwcfbwd5MPP15HDWRuvMnBXafc9Od52XUUUFOJgh0=; b=PjSozKHpXoVTqGzzk/JTTw97W+ysi05ErCJl3Axic9yYFIt+tszfUbF9X6zh47pf86 8p3pD3uLYDg/e3gUbDFYO4Fvz5fnfmoZ9s2gGowHQ6xcQssUGr3hZhlxaXT4b1xKuKT1 aSU9PE7WVZ1sHsT9A+NXEKNHKAsSwbet2nkJUITxQsAImRrfZk/s0jKb74R3TV7mQmcH 28pRXrk3G3uWt/kGrEDBFvJJnOhd9mUKWsDsRkFkVrFstIUKg0bR+riAbkX2qgnCMsfD DUI6rTd560AtJh4RiUSQDnHtIjE2PeSCpNH8yQgHIg8nKGCvEzUTXQzaMzgBr9g/HRt2 l82w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700582603; x=1701187403; 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=YNQwcfbwd5MPP15HDWRuvMnBXafc9Od52XUUUFOJgh0=; b=E1gvNLglVVk0XmwTUaFdTzJonI7JPzvpiAuoyN/BF49G90crWBC13qzOeAV1n0Hrkw UCaIbLz6jm9iTefzDQ9Wo7duf/XNnUplLBy9jGxkrCmZgNK6DHjCZVd9P4NoplMFz+kU xUFV257f1iy5Z5+tjFusJW6Kb4vbdguJ7a09OrgLAKhC57dkCJru6hqZPhZKRc1Ui8tY XIp7mw10aQAAA/Dbaaja15LePIin+CnciHoWoUNCZ1ibdD+Q4ksLxd/qNfVRy3rIADTv ptUyW0g5apn/Iuyl+Susoqg22jq0LsabyugbbQ262RAvCe/OYymynP3ubbEK6gJADIiR UQMg== X-Gm-Message-State: AOJu0YxBNg7It183wzaQKx2VYioAOwgfahriZcaImFNXleLNmj+wKM9a GadWIQzpySuEiOdT0HaX5agjbAlHVIndlJNywBDHhA== X-Received: by 2002:a05:6402:ea1:b0:544:f741:62f4 with SMTP id h33-20020a0564020ea100b00544f74162f4mr466676eda.0.1700582603209; Tue, 21 Nov 2023 08:03:23 -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:03:11 -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=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Tue, 21 Nov 2023 08:04:05 -0800 (PST) On Tue, Nov 21, 2023 at 7:56=E2=80=AFAM Mark Rutland = wrote: > > On Tue, Nov 21, 2023 at 07:41:17AM -0800, Ian Rogers wrote: > > Hi Marc, > > Hi Ian, > > > I'm unclear if you are running a newer perf tool on an older kernel or > > not. In any case I'll assume the kernel and perf tool versions match. > > In Linux 6.6 this patch was added to the ARM PMU: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/comm= it/drivers/perf/arm_pmu.c?id=3D5c816728651ae425954542fed64d21d40cb75a9f > > > > My guess is that the apple_icestorm_pmu requires a similar patch. > > The apple_icestorm_pmu PMU driver uses the arm_pmu framework, so it's usi= ng > that code (since v6.6). > > > The perf tool is supposed to not use extended types when they aren't > > supported: > > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.gi= t/tree/tools/perf/util/pmus.c?h=3Dperf-tools-next#n532 > > How does that is_event_supported() check actually work? I suspect that's = giving > the wrong answer. Maybe, the implementation is to check using perf_event_open: 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#n232 This is recycling logic from perf list where many legacy cache events are elided due to a lack of support. > Regardless, I think the tool is doing something semantically wrong, see b= elow. > > > So I share your confusion as to why something broke. > > > > PERF_TYPE_HARDWARE is a legacy type where there are hardcoded type and > > config values that correspond to an event. The PMU driver turns legacy > > events into the real types. On BIG.little systems if the legacy events > > are monitoring a task a different event is needed for each PMU (ie >1 > > event). In your example you are monitoring 'ls', a task, and so > > different cycles events are necessary. In the high 32-bits (the > > extended type) the PMU is identified. > > I think the interesting thing here is that the tool is mapping events wit= h an > explicit PMU into legacy PERF_TYPE_HARDWARE events, which is the opposite > direction than intended. Regardless of whether PERF_TYPE_HARDWARE events = can be > targetted to a specific PMU, if the user has requested to use a specific = PMU we > should be using that PMU and related event namespace. > > Marc's command line was: > > sudo taskset -c 0 ./perf stat -vvv \ > -e apple_icestorm_pmu/cycles/ \ > -e apple_firestorm_pmu/cycles/ \ > -e cycles \ -e cycles here is a direct request for the legacy cycles event. It will match in the parser here: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tr= ee/tools/perf/util/parse-events.l?h=3Dperf-tools-next#n301 which goes to: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tr= ee/tools/perf/util/parse-events.y?h=3Dperf-tools-next#n397 and as this is a hardware event there is wildcard expansion on each core PM= U. Thanks, Ian > ls > > ... and so the apple_*_pmu events should target their respective PMUs, an= d the > plain 'cycles' event could legitimately be opened as a single > PERF_TYPE_HARDWARE event, or split into two directed PERF_TYPE_HARDWARE e= vents > targetting the two PMUs. > > However, thwe tool opens three (undirected?) PERF_TYPE_HARDWARE events: > > Opening: apple_icestorm_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_RUNNING > 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 3 > 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_RUNNING > 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 > Opening: 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_RUNNING > disabled 1 > inherit 1 > enable_on_exec 1 > exclude_guest 1 > ------------------------------------------------------------ > > Mark.