Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp104548lqh; Thu, 30 May 2024 15:51:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX8RoTcOoqGe4gcIvlUMctgVQuvSNgcUMttVGQVzFEbf6aeo1aNH+iK/ncico+Sbw8b0i9rDCCz1U+lIWCx2IsseTtmIcxfrW33I9kMtA== X-Google-Smtp-Source: AGHT+IF2zdsBAWAKdfmaj7lOspC3keqAnw1ncNPRKd6BK9qZrh3Mei37tfLCsQWbcS5zTm8EK9i8 X-Received: by 2002:a17:906:ae42:b0:a62:fc9d:6fec with SMTP id a640c23a62f3a-a68208fe418mr10294966b.34.1717109513125; Thu, 30 May 2024 15:51:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717109513; cv=pass; d=google.com; s=arc-20160816; b=Jb4kmiCAaccCiBVAow/AVbY94O96XZA0wVlALZrtppUt7cvyLxRdKRlrMZhp+Oge8q L20v+bNioWtyRKuJe8ysd1KlFmlLMuwGfD0i1sHK1cgLKug1PD6RjI5Zbuzx9IPy94Ap JL76EyzEyULFmF1isipf7rLwagEFioWxXF69fKZFdeGKaert2pl+G4PJnItDqzW8i2pP SkhcFkqTCRnfa2yNNlE1BRok0/o9hcnnfGfFWf901FxaZ4g3Uiuxk/H38Jp0HF2WAkXC CMwJqR0sDMi2ByETVPZcvogGF4WthBZ8kbtceZNP0PkXUU+AAu0FUCkS9xZN78w1uxlL TTgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nhVpHfRSSBnI/FxacvjgYXfutQFHBAFxAsSQxk4Vo4c=; fh=9jsOfprkR9GruXsmgH8GOqGr0+qEAzC1LqKXL313b1I=; b=HyskXXPe3DgHhhV2JOKLBOk1/zbDm4vBsEaRht/yKqkCu40FKDR+KHbWeer2BtlpLn tht1rs2w31Vh62INE1fNDL08Z9y8HAjE48oMG4gHzG1MnLt4Nvqzpna1b11hKYHYYVak q/renIlmU4U+/P5DSZKls4m+LWg3epekdwjB9pRGEF9xdWvQ6aqx9TRAxGCBZpUK2Pkq eTUEuFr9pnz5xPutef6hYxUBWMjQgOtjzw2tqQmTXVLw6fzJ4QFKvrFmjGg+k8a0aIxG KzuM17QJSSBYF85TWNUIF0nxanrGaAExPIeTWit9nslVRN+LSijgA23Ul/A9Pb04Us81 NDoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bgYQwgTy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-195991-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a67e73faaa5si22331166b.244.2024.05.30.15.51.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 15:51:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-195991-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bgYQwgTy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-195991-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-195991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id A73041F259B9 for ; Thu, 30 May 2024 22:51:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DCCEE182D3C; Thu, 30 May 2024 22:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bgYQwgTy" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 019F917545; Thu, 30 May 2024 22:51:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717109504; cv=none; b=fC4mXrFz8CeaN2j99sH8DcHcITBxk+7jMlfe0g7JggS70ZqHGN9n6FKeojV3MGVWpoOSJgLjefse+6PS1sTTqej4gZX38uuuEN+oib0+cuEzzoxw99EK1T7kr59zbBp5OrXJ68kU8fM/R5cHImSTOwi5GCDe4nJ/rapOclb+yj8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717109504; c=relaxed/simple; bh=5MoWl4cipWj3Mhd5Zbuh2px9BzjUnrX11GBXlLvgsmc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fcOhjvpqYTicO5lief0qIYU9HADcRT1WQSdWsuqkzAdF44Mv630bXMeKZCLnn1U222wjPKDQSVjNNNA5XhHIqc/91NCZT2B1i7oYle1bnqjhKrAGiBoYfD1TXXfpt0nUDBnHV0yMTT8+gXOAPQioV5PURCWtpzqevrIDsubL/jQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bgYQwgTy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56B28C2BBFC; Thu, 30 May 2024 22:51:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717109503; bh=5MoWl4cipWj3Mhd5Zbuh2px9BzjUnrX11GBXlLvgsmc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bgYQwgTypAE74OdO5a0czXJg104IC0qvO9oLl1T2ZxImVjilcK1+s8y5VeAkYckma tJvMTHSz13ON7ML0J9a/RodSEXCDKzw0h6bN0+oo5s/LHStwQHfUMvgDDuO/RBdD97 gw0wjcJGeQbswSykt8xId4b/JuN2N1BwYz1DXK4TkYK96xP3AssqNGcwppiO/mWrA2 46Nzov5rzhkeKrUQkAs3A4QnJ3Zo4esh/eSgXE9Tax6NNi/BIYg8fGFwoWD+dTn1ga /5FlVgSH8G0nSu9q+G/Cw++BOVesx0Mdg73TFOnhBjdh+GxsFcnmoaW9mGgiixt7Ss 9wfLcUP0Nebfg== Date: Thu, 30 May 2024 15:51:41 -0700 From: Namhyung Kim To: Ian Rogers Cc: James Clark , 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 Subject: Re: [PATCH v1] perf evlist: Force adding default events only to core PMUs Message-ID: References: <20240527105842.GB33806@debian-dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, May 30, 2024 at 06:46:08AM -0700, Ian Rogers wrote: > On Thu, May 30, 2024 at 5:48 AM James Clark wrote: > > > > On 30/05/2024 06:35, Namhyung Kim wrote: > > > On Wed, May 29, 2024 at 12:25 PM 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. Then I think it's a real problem and perf should report it like we do now. > > > > > > > > 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. Yep, we can do that if the kernel provides the info. But before that I think it's practical to skip uncore PMUs and hope other PMUs don't have event aliases clashing with the legacy names. :) > > 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/tree/tools/perf/util/print-events.c?h=perf-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. Yep, that's also possible. I'm ok if you want to go that direction. Thanks, Namhyung