Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp412159rdh; Thu, 23 Nov 2023 07:16:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtbYYTJpxLXbAXnvdaCmvZMcmB/TQoG202irkFAUIfbczPat3vpX7UHxyUSLvk35ecrL94 X-Received: by 2002:a05:6a00:158c:b0:6cb:916f:f3d8 with SMTP id u12-20020a056a00158c00b006cb916ff3d8mr5999288pfk.22.1700752601887; Thu, 23 Nov 2023 07:16:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700752601; cv=none; d=google.com; s=arc-20160816; b=Wk8ZAA+6+yDE5t9n1kbg6Xp/flf8Hq0Q8StojR5SMm7fALcWcMELAifDd6UjoKLzMn cwWgO0rrCKBfVhjpaEVo7HDulBY6cj5iEeIL3toPnjrpeC3am1Ld+tu6uDrtrFD9hXqh ALiOcxXA1OBtFuERS+7WLKn45fWFGxld/GF8iCnA/ZuGZrXAfLXMc1nSWPYUqChXogGn qNcLmpOylUakjBVRhgzlynDx5xJy0xM6q/X310J2V6vrWG6ahrsdvxS/Ittt7BvXAyHh 6hKov7+/Szn+qNtq0K0QNvuGSg2VLcVtNjQeagn9ol72CDjE9LGyPS7q6jWOYztn/0Rx F/Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=YU8q7I5UZ2MGmXN7S7UUO2Y0qpjeGhI9GwDG63qLc9s=; fh=SQhd/IGZ68d59Hyaa+xhgbHMk8B25LyQsmzIpY1Ivi8=; b=OFQ/Y6pgtq5pFUucFF0UDocApFWEvTMYG0KY9bGurO7Gl3MDeT1L1vpKxJk4PFF8Oh z2rVO42VzaKFQq3efxQihlF7ChM7/lfKUZVzPAyiAolhC6he9LpFfxBdGPioEPNzxHD5 fGMuSZcW2nx4Wrw4veGfU2B80tYfpKBwMsSWRJGA+Se7AWayyIU2CwRrV7PHhKX4zgA8 0sQlRgipvYR09dzi1Mpchlo2zhckZl79cP9ME9TCgxXriA5FxHMzzKfjIOVpWs337GKI ImrfDglVvLbgv6z+dYqntSBFrvQ84DV5QgqCvYiHty6MQk82b8prXXbKhc2/J9Imusqa VKVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GJeVqaGm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ch4-20020a056a0208c400b0058bc1c85714si1582534pgb.467.2023.11.23.07.16.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 07:16:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GJeVqaGm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 00776801C9B8; Thu, 23 Nov 2023 07:16:39 -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 S1346042AbjKWPQK (ORCPT + 99 others); Thu, 23 Nov 2023 10:16:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346012AbjKWPQG (ORCPT ); Thu, 23 Nov 2023 10:16:06 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6137CD53 for ; Thu, 23 Nov 2023 07:16:13 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB728C433C8; Thu, 23 Nov 2023 15:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700752573; bh=Do+ICJ+VG4Z1faB6kjDoh1PhnVA0WHPJgBUdNTKdRLg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=GJeVqaGmHy8DruIar6MmJ9fvCg/jDoweQLIc/0cCM8m7iviXPJTGbuWk+h9B4PBMP 38Lef3kwsQYdBZk/e9KdPB+A7seys6GUKlNQhSjsLi26xrWv2ySGmFuhDnvhQZZJ6p Cl404LY/KYDlxHCEpW6TLbpe18Z3kBnNcU0NtaCHHX7jsUiOteUkoHC5rlGXxWrAHB XIjDcY4edwruSi/ApApHUEgKSn64FBNnKpLtmVgBvCKGHIxF8n3fasXxgw/JN286Zf znFfB2iMimGtaLlnNGS51YHSqYKzmSLFufLuBMBPml0bAKpIOhbWgkiYqGxosVhYAi otYu9fbFCTcEA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.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 1r6BR4-00FoTj-9U; Thu, 23 Nov 2023 15:16:10 +0000 Date: Thu, 23 Nov 2023 15:16:09 +0000 Message-ID: <86cyw0zeiu.wl-maz@kernel.org> From: Marc Zyngier To: Ian Rogers Cc: Mark Rutland , Hector Martin , Arnaldo Carvalho de Melo , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v1] perf parse-events: Make legacy events lower priority than sysfs/json In-Reply-To: <20231123042922.834425-1-irogers@google.com> References: <20231123042922.834425-1-irogers@google.com> 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/29.1 (aarch64-unknown-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: irogers@google.com, mark.rutland@arm.com, marcan@marcan.st, acme@kernel.org, namhyung@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, adrian.hunter@intel.com, kan.liang@linux.intel.com, james.clark@arm.com, linux-perf-users@vger.kernel.org, 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-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 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]); Thu, 23 Nov 2023 07:16:39 -0800 (PST) On Thu, 23 Nov 2023 04:29:22 +0000, Ian Rogers wrote: > > The perf tool has previously made legacy events the priority so with > or without a PMU the legacy event would be opened: > > ``` > $ perf stat -e cpu-cycles,cpu/cpu-cycles/ true > Using CPUID GenuineIntel-6-8D-1 > intel_pt default config: tsc,mtc,mtc_period=3,psb_period=3,pt,branch > Attempting to add event pmu 'cpu' with 'cpu-cycles,' that may result in non-fatal errors > After aliases, add event pmu 'cpu' with 'cpu-cycles,' that may result in non-fatal errors > Control descriptor is not initialized > ------------------------------------------------------------ > 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 833967 cpu -1 group_fd -1 flags 0x8 = 3 > ------------------------------------------------------------ > 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 > ------------------------------------------------------------ > ... > ``` > > Fixes to make hybrid/BIG.little PMUs behave correctly, ie as core PMUs > capable of opening legacy events on each, removing hard coded > "cpu_core" and "cpu_atom" Intel PMU names, etc. caused a behavioral > difference on Apple/ARM due to latent issues in the PMU driver > reported in: > https://lore.kernel.org/lkml/08f1f185-e259-4014-9ca4-6411d5c1bc65@marcan.st/ > What issue? So far, I don't see anything that remotely looks like a kernel issue. > As part of that report Mark Rutland requested > that legacy events not be higher in priority when a PMU is specified > reversing what has until this change been perf's default > behavior. With this change the above becomes: > > ``` > $ perf stat -e cpu-cycles,cpu/cpu-cycles/ true > Using CPUID GenuineIntel-6-8D-1 > Attempt to add: cpu/cpu-cycles=0/ > ..after resolving event: cpu/event=0x3c/ > Control descriptor is not initialized > ------------------------------------------------------------ > 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 827628 cpu -1 group_fd -1 flags 0x8 = 3 > ------------------------------------------------------------ > perf_event_attr: > type 4 (PERF_TYPE_RAW) > size 136 > config 0x3c > sample_type IDENTIFIER > read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING > disabled 1 > inherit 1 > enable_on_exec 1 > exclude_guest 1 > ------------------------------------------------------------ > ... > ``` > > So the second event has become a raw event as > /sys/devices/cpu/events/cpu-cycles exists. > > A fix was necessary to config_term_pmu in parse-events.c as > check_alias expansion needs to happen after config_term_pmu, and > config_term_pmu may need calling a second time because of this. > > config_term_pmu is updated to not use the legacy event when the PMU > has such a named event (either from json or sysfs). > > The bulk of this change is updating all of the parse-events test > expectations so that if a sysfs/json event exists for a PMU the test > doesn't fail - a further sign, if it were needed, that the legacy > event priority was a known and tested behavior of the perf tool. > > Signed-off-by: Ian Rogers Reported-by:, Link: and Fixes: tags would be appreciated. > --- > This is a large behavioral change: > 1) the scope of the change means it should bake on linux-next and I > don't believe should be a 6.7-rc fix. I entirely disagree. Distros are shipping a broken perf tool. > 2) a fixes tag and stable backport I don't think are appropriate. The > real reported issue is with the PMU driver. A backport would bring the > risk that later fixes, due to the large behavior change, wouldn't be > backported and past releases get regressed in scenarios like > hybrid. Backports for the perf tool are also less necessary than say a > buggy PMU driver, as distributions should be updating to the latest > perf tool regardless of what Linux kernel is being run (the perf tool > is backward compatible). Again, perf gets shipped in distros, and not necessary as the latest version. Rather, they tend to ship the version matching the kernel. No backport, buggy perf. And again, I don't see a bug in the PMU driver. Now, in the interest of moving forward: this patch seems to address the basic problems I was seeing on both M1/M2 (running any kernel version) and Juno (running an older kernel), so: Tested-by: Marc Zyngier Thanks, M. -- Without deviation from the norm, progress is not possible.