Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp19025rdd; Wed, 22 Nov 2023 08:19:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXugptSvLhvohPyD0lAEq4afgzFNuUb1SkokeFMyaCZDB/1T/kLDrKb1EJM8tA5r2AfZEp X-Received: by 2002:a17:902:d511:b0:1cf:59c0:7e05 with SMTP id b17-20020a170902d51100b001cf59c07e05mr3358370plg.17.1700669998640; Wed, 22 Nov 2023 08:19:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700669998; cv=none; d=google.com; s=arc-20160816; b=h7aqZMuxQX1dUMz8vd+Mve72DQtV9LOvPYYaaGe0dH/6oUDfNJKCybclEeIaI23GrM UXKK5op8d5tUqrIK+w2v3FRnEl8b7vdn8Dx+67iOg0OSZLSNlCM6hI4LdA6fy+MCQOdR TvKKNwo5BGZ3lZyLaxG/kNWWQQbrxU9F04pWAjAyUsZzi8z73Ay/kiMB6UfqA7CjNkRH tzfHCWS++pJW6YLhTiGaNksfjkivTekptRCO+Yy7m+eWiY70tVH/nnJ4SDnE2E/MC6Jp QubthyUKVuzLsShp97qp4gk+0FtqcjU/m4Wb4RQ7GpySAs3FKvVTwttTYuZnWM2MOvPE ROlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Q/N9LDYrAyq54pDOspSGJmsPZa18arAVjsNX5u/j60Y=; fh=Kv30kbckn7caXUVBFKPLkhek07Kju88vh6uZrvjQ9ls=; b=duHpYpdxN46146c3oTixL3JhsPtv7s7D5FaevpayXDoXJLGDLBKD+7XfNhLsDtChPy vt0F8U76QPu2f9xuhgiPI8GFQ8vfizzHa2LYr/EZQ2YVeLO9vOHpK3qZQr+PQct3Z/E6 MVUn9HFxKQE95SF/P/SRm4O5Yh8lF9LUx60YFLkKy5yVEn6ZQ3r8hVLCH15l95OBx0SJ viBhMOZtupk72cx2XtYVqR2B5glxCfUltvT03TZ6TBADzZN08vV1HvXlHjR5M5UVI6jB A7pnIrpS9woGrlfkZHQR+CZWf0KVYz8mJQJwRVXogpWrSLkK4HdKrFPTioSCMWB2KSZo meFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fqMGV6Ef; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id x11-20020a1709028ecb00b001c88fc3c593si12299480plo.560.2023.11.22.08.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 08:19:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fqMGV6Ef; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 6E7F182ABF22; Wed, 22 Nov 2023 08:19:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229513AbjKVQTn (ORCPT + 99 others); Wed, 22 Nov 2023 11:19:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbjKVQTl (ORCPT ); Wed, 22 Nov 2023 11:19:41 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F529D40 for ; Wed, 22 Nov 2023 08:19:38 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 772B4C433C8; Wed, 22 Nov 2023 16:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700669977; bh=fouog/Xb7wmwXW9eFuP6KgCbqL6WmR1O6M7kQuJhWRE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fqMGV6EfEclqRNWCP+8zvwiNVrs9/jewshE2jdobpwzZOvYzLAA57vSv0bb5eEe/A 3JwUawXzlZH+nTNsdhrQMpo0t1/vrDMjxl1KV50f9iL13JtOGbr26fPVu32ub7znQ2 MJ1nIpUJyLnUS5xGHBCS6kTrs+9u7OjFZuIVUGsVCdTmRsmOYw/937EdZEO9qn8KfP TJQSPnunjvP3/sYm+l8UbUOuEkIv/0XSuY2yeRZi+omlhZEjpHVmdnxbapVKuXS1iQ WVvZ7b8F3ztS34kf/0OQw47W0mblcJ6Yi+UEGvUf9NRNFwyoEqUZ7VTFXqximBCAeM LL2BytudzMJMA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id D606840094; Wed, 22 Nov 2023 13:19:34 -0300 (-03) Date: Wed, 22 Nov 2023 13:19:34 -0300 From: Arnaldo Carvalho de Melo To: Mark Rutland Cc: Hector Martin , Ian Rogers , Marc Zyngier , Arnaldo Carvalho de Melo , James Clark , linux-perf-users@vger.kernel.org, LKML , Asahi Linux Subject: Re: [REGRESSION] Perf (userspace) broken on big.LITTLE systems since v6.5 Message-ID: References: <86o7fnyvrq.wl-maz@kernel.org> <930bfb9a-dcbe-4385-9ae3-26e2aa14c50e@marcan.st> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Wed, 22 Nov 2023 08:19:53 -0800 (PST) Em Wed, Nov 22, 2023 at 03:49:18PM +0000, Mark Rutland escreveu: > On Wed, Nov 22, 2023 at 10:06:23AM -0300, Arnaldo Carvalho de Melo wrote: > > The point is that "cycles" when prefixed with "pmu/" shouldn't be > > considered "cycles" as HW/0, in that setting it is "cycles" for that > > PMU. > Exactly. > > (but we only have "cpu_cycles" for at least the a53 and a72 PMUs I > > have access in a Libre Computer rockchip 3399-pc hybrid board, if we use > > it, then we get what we want/had before, see below): > Both Cortex-A53 and Cortex-A72 have the common PMUv3 events, so they have > "cpu_cycles" and "bus_cycles". root@roc-rk3399-pc:~# ls -la /sys/devices/*/events/*cycles -r--r--r-- 1 root root 4096 Nov 22 12:35 /sys/devices/armv8_cortex_a53/events/bus_cycles -r--r--r-- 1 root root 4096 Nov 22 12:35 /sys/devices/armv8_cortex_a53/events/cpu_cycles -r--r--r-- 1 root root 4096 Nov 22 12:35 /sys/devices/armv8_cortex_a72/events/bus_cycles -r--r--r-- 1 root root 4096 Nov 22 12:35 /sys/devices/armv8_cortex_a72/events/cpu_cycles root@roc-rk3399-pc:~# But on x86, on a AMD machine: ⬢[acme@toolbox ~]$ ls -la /sys/devices/*/events/*cycles -r--r--r--. 1 nobody nobody 4096 Nov 22 12:48 /sys/devices/cpu/events/cpu-cycles ⬢[acme@toolbox ~]$ And an Intel: [acme@quaco asahi]$ ls -la /sys/devices/*/events/*cycles -r--r--r--. 1 root root 4096 Nov 22 13:11 /sys/devices/cpu/events/bus-cycles -r--r--r--. 1 root root 4096 Nov 22 13:11 /sys/devices/cpu/events/cpu-cycles -r--r--r--. 1 root root 4096 Nov 22 13:11 /sys/devices/cpu/events/ref-cycles [acme@quaco asahi]$ Slight difference with those - and _. > The Apple PMUs that Hector and Marc anre using don't follow the PMUv3 > architecture, and just have a "cycles" event. I see, and even being prefixed with the PMU name, as "apple_icestorm_pmu/cycles/" it ends up trumping that and moving that to (PERF_TYPE_HARDWARE, PERF_HW_CPU_CYCLES) instead of (/sys/devices/apple_icestorm_pmu/events/type, /sys/devices/apple_icestorm_pmu/events/cycles) as I noticed with: sys_perf_event_open: pid 0 cpu -1 group_fd -1 flags 0x8perf_event_open({type=PERF_TYPE_HARDWARE, size=0 /* PERF_ATTR_SIZE_??? */, config=0x7<<32|PERF_COUNT_HW_CPU_CYCLES, sample_period=0, sample_type=0, read_format=0, disabled=1, precise_ip=0 /* arbitrary skid */, ...}, 0, -1, -1, PERF_FLAG_FD_CLOEXEC) = -1 ENOENT (No such file or directory) I.e.: type=PERF_TYPE_HARDWARE, config=0x7<<32|PERF_COUNT_HW_CPU_CYCLES It should be: type=/sys/devices/apple_icestorm_pmu/events/type, config=/sys/devices/apple_icestorm_pmu/events/cycles That is the minimal patch to address the regression reported, even if using some kludge to buy time for a longer term more elegant solution, Ian? > [...] > > So what we need here seems to be to translate the generic term "cycles" > > to "cpu_cycles" when a PMU is explicitely passed in the event name and > > it doesn't have "cycles" and then just retry. > > I'm not sure we need to map that. > > My thinking is: > > * If the user asks for "cycles" without a PMU name, that should use the > PERF_TYPE_HARDWARE cycles event. The ARM PMUs handle that correctly when the > event is directed to them. > > * If the user asks for "${pmu}/cycles/", that should only use the "cycles" > event in that PMU's namespace, not PERF_TYPE_HARDWARE. And thus, armv8_cortex_a53/cycles/ and armv8_cortex_a72/cycles/ should just fail as there is no "cycles" for that PMU, no fallback. > * If we need a way so say "use the PERF_TYPE_HARDWARE cycles event on ${pmu}", > then we should have a new syntax for that (e.g. as we have for raw events), > e.g. it would be possible to have "pmu/hw:cycles/" or something like that. > > That way there's no ambiguity. - Arnaldo