Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1313071lqb; Thu, 30 May 2024 06:57:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW/+qg3ElE6hFGaFX/nGy8O9oWqJ5dF6zQ+ODiCBGtCaSa5z4fdO4xEjcFZhZiMjJdy/MX02P30VkUZ9/wTggsLIgSAHbMZkpXl1bD8pA== X-Google-Smtp-Source: AGHT+IHxOV0w4FmIfu5bY2ocjMtnmop/rMA66BLF3cAFrRP4cnMAd1h6Mu4pcgV+cqurPeXnJK9i X-Received: by 2002:a05:6358:7285:b0:192:63da:a9ff with SMTP id e5c5f4694b2df-199b95f0ffbmr222144555d.23.1717077470449; Thu, 30 May 2024 06:57:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717077470; cv=pass; d=google.com; s=arc-20160816; b=ysYcZd+g1Bl6Ge3c+5FJyKKCNQ0POnCCXMAkJOYzcEkY35bnnBfEzefdKyx5+3rBVB Xnvhh8yGWejDcFlc+xscXsijZSTISIPS1qvA5qKWKpF46RY7Xibe2MvIhyoo2OJJJ+rA q3H6WETzV0O2WaqH6FUkCY1ppYS212+zCXkSjkAnv8ARkJp2E5hHCnH78WZ60vOoYkKa 8lzlp8ZVHqld4767NBJlO0s6AWblMzDWpV8H+7h5ehjThxreAgzywm8CT7xB+hYl+LMF 0F7OVhzmr8GL5xhnrNvG6ib2ybFAnSb8fgng/HN6SlNTD1T5ocWrvNTvU8vBX3HOwXWN svSQ== 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=/tAW56zJXvgRLAmYST/Io71B8Ofionrgt6hjpIXJJGc=; fh=D7iZDBXLKnznT+7met3Xi3w+A2Rr4feY8bYuonY9pqc=; b=Zq+F1l5R+Ff6Kp9vAIil/3t/1IQJMH5UvRBeCUMsT6vLKAvfVicQXpE3ZlxyAld0Hr EK27SvLXDTCzMg0HhWPyPHAE0bjU1d5E4N0KKPB5xXto+ZeM5P1fT9UiOSmYp+xEQEfB lhDrLFoYR/7uHiyZuM/YC4sYTEHnqgQQVTh9hO+uqZNNiLaC4Bfgjcsa/X7ZOQE99JRJ P115XhgQ0PihW4LaLGxvjvWmpRfwDQgTnQw/YGKJaEX3HmEXlNQchTTPUTNifRQ1w1ID ca5LsElxVBJTjmMMBXg8F6k/8CLvgPaynI/Fliwl/cUargGIvffhK4o8qtH65TAWVNmP bxtQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=UL4Pb+s4; 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-195447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195447-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6822779baeasi11919712a12.284.2024.05.30.06.57.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 06:57:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=UL4Pb+s4; 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-195447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195447-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 816BA287F6C for ; Thu, 30 May 2024 13:48:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2F4017624C; Thu, 30 May 2024 13:46:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UL4Pb+s4" Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) (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 5AD8217622B for ; Thu, 30 May 2024 13:46:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717076782; cv=none; b=AmvE2jgrStTE180SMiqkBj0uKvF9c5TPz33qILa5gAQJD5HqjaWlcB45go9OVbYYkem7YfqhvcHMeaPEmtxCp20lo+5fnocceIhV2wWqwQWCdrlW6F1y8XJgXPahQED8trGpZbi3EvX6Qa0larfHvIWydr5vg5eCQGJ3nSDgVso= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717076782; c=relaxed/simple; bh=JFhwaAacDH2z63xbkQsWA6Css5WAh1oUSYItrm83lWs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=nTv30/BTuAXAIgwE3Mc7zEiX7tSAQGn7DOU/qIEh+K1bEJW/2EtzBC5GZIIwcLFeZWtk6OBBWSmqTj6mVfQSQQe++peihCx9+67kLNpooZRJTWTazIIO/JJlaIW9Mz7qRyVWqIDoohvULHWBhY9cQIO4FuU2QlaP9Um5YPJ9+mg= 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=UL4Pb+s4; arc=none smtp.client-ip=209.85.166.171 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-f171.google.com with SMTP id e9e14a558f8ab-3748945660bso6735ab.1 for ; Thu, 30 May 2024 06:46:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717076780; x=1717681580; 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=/tAW56zJXvgRLAmYST/Io71B8Ofionrgt6hjpIXJJGc=; b=UL4Pb+s4NQhgijASnZp82eLZ3oOsA5zO+Ca4bZzL1v04YjOqU5eShPeV9rKPEpSATT xt6h6w8f4Rda5jCpYSuJXf7OwJlJtExZ+cjAowgp9h9Kt45zlrStlmXWbeUPmMIy+YmN NBQTO52q+gEbtJYZXT2yf9JXNjkSfCKBQ0Xs8lKoK/nqH3GP0+o/n4rAr9jE053KS02S TljbfJvJ95+sl4Ks62bIKT0pifc2A2EMoHt0tIL4K5vOMfvgS9OeerclnzqlqsCr6E0e w//VFMUqLDWUaCOWdFcVIaZyLGN7v7VsBLvyU6EB6iamq9Vx+EszeTv+i17aV0CzsfIf Cd7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717076780; x=1717681580; 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=/tAW56zJXvgRLAmYST/Io71B8Ofionrgt6hjpIXJJGc=; b=UgfG1nozuKKUy1AAJ43un2P5i/fLL0TQO+P4UcKVUEM4myPmgYiQcZ52r1TplWh8ZK iwGu9LB0nN9Ev1RREmUuGJrpdfHQZLSte4Sw/RKx3fQkdTfPvYPFHtGZ16G9nAOoRZrj 6U3mNsUAZrqVUCPo6nIBLD3xuLOaHedOiA7VEapjetW/t7O0GE/2m6CgApG8e1qWXRm2 wwZxKtVu0DrTfD9GXTIkIW7ODDaqdZvaUPmPgmPil9M5zL4V4480wZoYx6y3MYNf2aTv 0HO88uKrLXxDCNcI/cHQjoo8iS3rsBXlJfpvBW1Df/cLMKfY/Lm5QJR2OJYgWQpC0iOU S4rg== X-Forwarded-Encrypted: i=1; AJvYcCXoPmBlYRKvcS9P4BaBveiKr8l9OfKnzEAHch8icAGqB1Uet2gNV6cBGbK5//zMnUBsJDnfXYZIaZkeHVCAoh2dIaus0B/YgxEm6E0T X-Gm-Message-State: AOJu0YwiFzR7FKKlHVjF6shrNdaXa+vs1YfBQMrDySyQXWJ6kFs2jnE9 W5hiGHZXyhqiwo2C9j5jSYznlGzWxy1cMR6e8kxvmKNjNylj2VWCorP3Ll+9NmAyeXw1hoGSa+7 HBoUvSsbehwGTuVX6nb/uO7jyezpu3bbWkmOC X-Received: by 2002:a05:6e02:16ca:b0:36d:cb9e:a0da with SMTP id e9e14a558f8ab-3747df9d137mr1748365ab.25.1717076780225; Thu, 30 May 2024 06:46:20 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240525152927.665498-1-irogers@google.com> <20240527105842.GB33806@debian-dev> In-Reply-To: From: Ian Rogers Date: Thu, 30 May 2024 06:46:08 -0700 Message-ID: Subject: Re: [PATCH v1] perf evlist: Force adding default events only to core PMUs To: James Clark Cc: Namhyung Kim , Arnaldo Carvalho de Melo , Leo Yan , Linus Torvalds , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Dominique Martinet , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 30, 2024 at 5:48=E2=80=AFAM James Clark w= rote: > > On 30/05/2024 06:35, Namhyung Kim wrote: > > On Wed, May 29, 2024 at 12:25=E2=80=AFPM Ian Rogers wrote: > >> We can fix the arm_dsu bug by renaming cycles there. If that's too > >> hard to land, clearing up ambiguity by adding a PMU name has always > >> been the way to do this. My preference for v6.10 is revert the revert, > >> then add either a rename of the arm_dsu event and/or the change here. > >> > >> We can make perf record tolerant and ignore opening events on PMUs > >> that don't support sampling, but I think it is too big a thing to do > >> for v6.10. > > > > How about adding a flag to parse_event_option_args so that we > > can check if it's for sampling events. And then we might skip > > uncore PMUs easily (assuming arm_dsu PMU is uncore). > > It's uncore yes. > > Couldn't we theoretically have a core PMU that still doesn't support > sampling though? And then we'd end up in the same situation. Attempting > to open the event is the only sure way of knowing, rather than trying to > guess with some heuristic in userspace? > > Maybe a bit too hypothetical but still worth considering. > > > > > It might not be a perfect solution but it could be a simple one. > > Ideally I think it'd be nice if the kernel exports more information > > about the PMUs like sampling and exclude capabilities. > > > Thanks, > > Namhyung > > That seems like a much better suggestion. Especially with the ever > expanding retry/fallback mechanism that can never really take into > account every combination of event attributes that can fail. I think this approach can work but we may break PMUs. Rather than use `is_core` on `struct pmu` we could have say a `supports_sampling` and we pass to parse_events an option to exclude any PMU that doesn't have that flag. Now obviously more than just core PMUs support sampling. All software PMUs, tracepoints, probes. We have an imprecise list of these in perf_pmu__is_software. So we can set supports_sampling for perf_pmu__is_software and is_core. I think the problem comes for things like the AMD IBS PMUs, intel_bts and intel_pt. Often these only support sampling but aren't core. There may be IBM S390 PMUs or other vendor PMUs that are similar. If we can make a list of all these PMU names then we can use that to set supports_sampling and not break event parsing for these PMUs. The name list sounds somewhat impractical, let's say we lazily compute the supports_sampling on a PMU. We need the sampling equivalent of is_event_supported: 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#n242 is_event_supported has had bugs, look at the exclude_guest workaround for Apple PMUs. It also isn't clear to me how we choose the event config that we're going to probe to determine whether sampling works. The perf_event_open may reject the test because of a bad config and not because sampling isn't supported. So I think we can make the approach work if we had either: 1) a list of PMUs that support sampling, 2) a reliable "is_sampling_supported" test. I'm not sure of the advantages of doing (2) rather than just creating the set of evsels and ignoring those that fail to open. Ignoring evsels that fail to open seems more unlikely to break anything as the user is giving the events/config values for the PMUs they care about. Thanks, Ian