Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp18908lqb; Tue, 28 May 2024 07:48:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7uiRaJQFisGbcSlABbb3OmXbNSsO38XhkshNN9UuBA58GReG8pitJvbmy6wSMJdURkf2bm4eVo+0gEGovtJ3hQ0riEKpwTchZKljFOQ== X-Google-Smtp-Source: AGHT+IFQp96rZ89mh9dUmoVMDdPRyCiC6CaS5VLpeLC3nL4Sg6JctBqiw43dhybNSRIpGtD7EG2X X-Received: by 2002:a05:6a20:de95:b0:1ad:878:5006 with SMTP id adf61e73a8af0-1b212daceb6mr10283870637.14.1716907726050; Tue, 28 May 2024 07:48:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716907726; cv=pass; d=google.com; s=arc-20160816; b=CAj7aS7BOkTuGgJIKUJUGrK/cuvHSwNL5IrrHRDfpiztKRuEG/kLrquN/1JQ2V2Yl2 0zwDq5UQEDlLWDAgXMJbduVDuBpLEbe4TbK665K1786NBRmM5Gli46KZGNGU5PAXi8+l TmkjVrWO192GylIAHnl5VjFNBCwUSnXW1jPHf0bboj7tknHprjZyW8NgboJqnmPDldaA DoKj/3Smb3huhrdDyjwVaD3Bdo7SlQv4r2O+uUGdf2OcHZ6LEj6qFcKtGjUR6keeGiUq LtEcTFXGJPHeHsFk6w3DDPkzK3+wscd8ppcrDYFSOacaBEiSLdOFsTK5Isf+LcMZd3ve 3+Hw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=NvI2py2Za8OrUxaoTv4MPNKfR4K2kb7CLWsRfWnqYD0=; fh=aGekJn4B6fjqZJa7neK4vRCLLH40JaK848RSH6yzUSw=; b=ftsSwVo+n9cYO4BV/ZZRFMX3l+T9uA8pu2BWUuv+Qs27H3RfXAP5gwKxIK8QJ0KsDg 4XWzRdTM5We5Yf8TiacowK7sJ96eInB5W3rtM2+QANLZOXpte+KmZkgQwZm3Ne9wyvqD jLyQJ9QnRb2eo6EQH3r1CHIZBFRBz9dq0OErb0l7loYVqqDVx+nwXQNAGoVCukfWOddY aERJzT0VqTM4MKZ3fRzzeVlcmZlDMUxUghCrgJgSbjywCQepD11C/0UYtB0i0gLZsPEv BmFc7BMv0NBSBhumG6upVQSCdjEgEkU1CAcKeK6UUdZSHqlOjvaH13V4TGUVQMx4D/0E 8AGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Wp/uaVtR"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192568-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192568-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f8fc373d0csi8135567b3a.127.2024.05.28.07.48.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 07:48:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192568-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Wp/uaVtR"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192568-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192568-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A538EB22FF7 for ; Tue, 28 May 2024 14:47:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 799B716FF39; Tue, 28 May 2024 14:47:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Wp/uaVtR" 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 96B7617C7F; Tue, 28 May 2024 14:47:20 +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=1716907640; cv=none; b=HbzlP4tHa9o0YJbFOpK5ti6Fz0LtCkc0QLOKkzmGrPcb/MXaiArf9Sq01hjqdCQuaHlhWgO+1zjAjNAx6t5iKx8AMAoCfeMBaNfj/ssQ328OFG+7zdmhIrPOU3W72VsTsGeNnZRJQfzpL4gTlrf64z/SOYmoNPg6KeOBVYcnKHE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716907640; c=relaxed/simple; bh=QO+rILPMmUh4nu8/ho57QXHNcGepvNHxpBMpLTzTy5M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sWKGcaQ6Zr4fkInwDRTLwffHWLf/2Ha0ZXxkxanCYTypHNIKOFVQGOmjj+0nfufrTvyg/HiuHWWAULvlIviphjTxiAbglxoV4NWW4wXa57m65vHw/Ah1RKyP8ZkKjWMHCLng3EhPOADRUWhyGW0lvSBVlVFunaxLeMhOYJ0Ms/E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wp/uaVtR; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B0C9C3277B; Tue, 28 May 2024 14:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716907640; bh=QO+rILPMmUh4nu8/ho57QXHNcGepvNHxpBMpLTzTy5M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Wp/uaVtRPQN3JEQRoKAgOcLxTTcYrC3WQOyBB5P6gbtJor6dJSUAZFH3W1+Vvo+V/ PUSErp18ZBXRhbJeZAOyDyKgMIEWba7nBc+cR4yFeG5iGBrNc33vzzTCRdOdZLJmpX psxXdIlzGT4tcKNv6Od3k/Y5JewG/lIHwt+Zy3j5p+O9ITGiGx+IQAWprK6chN8Mhf gyNsg09aSI/Nw1LH9XHSlRa9BuDagvOEdkSvaQJv2xNA5qObAa27Ubh+dZs+/WGIay hrKzeuOjUeuTi0KYsn5y8YQO9QQyFQMiOO0sKZxzU8htywBrPulCmNUN1aN29UPKil gFQyCa1s3bEGw== Date: Tue, 28 May 2024 11:47:16 -0300 From: Arnaldo Carvalho de Melo To: Artem Savkov Cc: Guilherme Amadio , Ian Rogers , linux-perf-users@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf record: add a shortcut for metrics Message-ID: References: <20240527101519.356342-1-asavkov@redhat.com> <20240528114525.GA449511@alecto.usersys.redhat.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240528114525.GA449511@alecto.usersys.redhat.com> On Tue, May 28, 2024 at 01:45:25PM +0200, Artem Savkov wrote: > On Mon, May 27, 2024 at 02:28:29PM -0300, Arnaldo Carvalho de Melo wrote: > > On Mon, May 27, 2024 at 02:04:54PM -0300, Arnaldo Carvalho de Melo wrote: > > > On Mon, May 27, 2024 at 02:02:33PM -0300, Arnaldo Carvalho de Melo wrote: > > > > On Mon, May 27, 2024 at 12:15:19PM +0200, Artem Savkov wrote: > > > > > Add -M/--metrics option to perf-record providing a shortcut to record > > > > > metrics and metricgroups. This option mirrors the one in perf-stat. > > > > > > > Suggested-by: Arnaldo Carvalho de Melo > > > > > Signed-off-by: Artem Savkov > > How did you test this? > > > > I'm trying: > > > > perf list metric > > > > pick a metric then: > > > > perf record -M tma_core_bound > > > > And it gets in a long loop doing perf_event_open() calls... > > [snip] > > > (gdb) bt > > #0 0x00007ffff6f21804 in close () from /lib64/libc.so.6 > > #1 0x000000000061fbd2 in perf_evsel__close_fd_cpu (evsel=0xdab470, cpu_map_idx=6) at evsel.c:188 > > #2 0x000000000061fc22 in perf_evsel__close_fd (evsel=0xdab470) at evsel.c:197 > > #3 0x000000000061fc9b in perf_evsel__close (evsel=0xdab470) at evsel.c:211 > > #4 0x00000000004e0b5f in evlist.reset_weak_group () > > #5 0x0000000000423bb9 in __cmd_record.constprop.0 () > > #6 0x00000000004276c5 in cmd_record () > > #7 0x00000000004c4579 in run_builtin () > > #8 0x00000000004c4889 in handle_internal_command () > > #9 0x0000000000410e57 in main () > > (gdb) c > > Continuing. > > ^C > > Program received signal SIGINT, Interrupt. > > 0x00007ffff6f21804 in close () from /lib64/libc.so.6 > > (gdb) > > > > So you should investigate this further. > > I tried a bunch of random metrics from perf list but didn't hit this. > > It spins forever in evlist__for_each_entry() loop in record__open() with > the same error: > > Weak group for TOPDOWN.SLOTS/5 failed > > Looks like the culprit is one of those unsupported metrics, will > investigate. Right, when trying something new, in a different way than the pre-existing codebase was envisioned to be used we may uncover latent problems, that endless loop seems like something we want fixed :-) > > The idea, from my notes, was to be able to have extra columns in 'perf > > report' with things like IPC and other metrics, probably not all metrics > > will apply. We need to find a way to find out which ones are OK for that > > purpose, for instance: > > > > Opening: cpu_core/topdown-bad-spec/ > > ------------------------------------------------------------ > > perf_event_attr: > > type 4 (cpu_core) > > size 136 > > config 0x8100 (topdown-bad-spec) > > { sample_period, sample_freq } 4000 > > sample_type IP|TID|TIME|CPU|PERIOD|IDENTIFIER > > read_format ID|LOST > > disabled 1 > > inherit 1 > > freq 1 > > sample_id_all 1 > > exclude_guest 1 > > ------------------------------------------------------------ > > sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 > > sys_perf_event_open failed, error -22 > > switching off PERF_FORMAT_LOST support > > Opening: cpu_core/topdown-bad-spec/ > > Is it just metrics containing unsupported events that need to be skipped > or there are other cases that wouldn't make much sense? If the latter > maybe it will be easier to just tag the ones that are supported (or not) in > pmu-events? Maybe we can use some criteria to look at the metric and filter out things that are not working right now? As you go on studying the codebase you will figure out the reasons, sometimes its a bug (the forever loop above), sometimes it plain don't make sense and we just skip it, leaving things like IPC, i.e. we have instructions, we have cycles, that is what needed for IPC, ok, that makes sense and we should have an IPC column when collecting both cycles and instructions, just like is done in a ad hoc way for IPC in perf stat since forever. People want to have those columns in 'perf report' and 'perf top'. - Arnaldo