Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp88075rdh; Mon, 18 Dec 2023 12:23:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/rJa/1kIQ9zjoLAOVfD8kcIWhUNhiZrMHPtnQZ6UyBjAdbz5R9Q/NU8nfG+ZzMrfHOg9M X-Received: by 2002:a05:6a20:e11a:b0:194:8591:a6ad with SMTP id kr26-20020a056a20e11a00b001948591a6admr1077217pzb.73.1702931006253; Mon, 18 Dec 2023 12:23:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702931006; cv=none; d=google.com; s=arc-20160816; b=KgxoDdz7wx3+5jvSMCkeCtfbUQw/abfkSixH0VWdM3yoPevIt7Xn/k16Q4wBvYgtX/ Pq3b3AZS/2jQAEK96YJi6KQLz/D6Rg/+gLrT5WmFXjrsbjOelLS05rlIhXibFA5MmhZA VAjVL2dAeGkMajoNqT0YNZgVpwwO/fSC6//knaphRzI0gXPNlGkJpt/JGy/Woymq71xZ Sw++LVLLAIbMRsKJMfKPY+7xdPWyyuc3tRuAdRLo/OBObUnYJ6QliTdU7vxC4ZyVSovO 18AWWb18AtFYeRwBiVW9KKvsU8YNrrSPEy7swqurdwHv5Mwu3tluKQl6x7/lsI+SAgZM iXHw== ARC-Message-Signature: i=1; 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=/BfT1g6fQ0FJTsC8rB0IjhTQIwz2v4PVrlMxtRdHgcM=; fh=AjsESTX3aTv3V2yM642aZSjUft/RUW3Vlphe0X5D9Xc=; b=0/ITbiuIai0VvxiWuxf0+ae7ryhdSwlIuvIY7QiwO5DT8rzn29VzIKevIIKYGwsPET jpors46zDp5PZGmvm8flbelruzXcAL0/X518fLhfvVHQCDwKxtGRkW6d+7PUbdSUacs9 aOQPH2gCPT9RQCz6HlfWb0QrsB/wiMno00TnyTaSbnvj4VDPwQIUAvd1Jy2wM8GM6oEH V1O1WTg8rFcdAnfzbUztR3fMWcSxz991HOchIwt4rXWXYm4H5A8VYN/jF3osKz0egWRs hgvPNR6UDKCeNQPJFL3b9EsPlW/NaSa3AI9qwhpxy6D7oUx3BqYvWo1d/JTUaWlXB1uI msaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=e+z7paLf; spf=pass (google.com: domain of linux-kernel+bounces-4342-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4342-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q18-20020a656852000000b005c6183ccab1si4613168pgt.529.2023.12.18.12.23.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 12:23:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4342-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=e+z7paLf; spf=pass (google.com: domain of linux-kernel+bounces-4342-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4342-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D28FA285D77 for ; Mon, 18 Dec 2023 20:23:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD6EB73460; Mon, 18 Dec 2023 20:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="e+z7paLf" X-Original-To: linux-kernel@vger.kernel.org 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 10F0372050; Mon, 18 Dec 2023 20:23:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64B81C433C8; Mon, 18 Dec 2023 20:23:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702930998; bh=1BbFmHk7YWm21tYfkE1YB3VNtMpu0O976sXjLOROCI0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=e+z7paLfbgZAjpmOTmHVwoxJ6YSx551WdDhzrYfskPGJRhY7uveqGjw9UCH3DT7co LS1GpbLOmclwEHt/hYug9+hLkw9KGvrqwDqpnE9S8LuiDMo6vv0KtqRiTCn74Ll9fY 8uxJdMfBDMJO52quiokBGxQUBOgNItz/iN3aIpG80rMSqbH6rCRtYbdEHNuAIG/71a M70KyrYEGbDFKLyrAGJL4lkd3qXkn5+/pe/8R5jgtfH0UHTgFUZzz3PilpLwAMEu5F 1R94UaPdvvg/vuxU4ZqVAbThn2bGZ6WmeOkRkhoj4fKlYKpWYnYJu7ZBcS5B7xlzWr BZk1LqjBQZzBQ== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id E33F6403EF; Mon, 18 Dec 2023 17:23:15 -0300 (-03) Date: Mon, 18 Dec 2023 17:23:15 -0300 From: Arnaldo Carvalho de Melo To: "Liang, Kan" Cc: Mark Rutland , Ian Rogers , Namhyung Kim , maz@kernel.org, marcan@marcan.st, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH] perf top: Use evsel's cpus to replace user_requested_cpus Message-ID: References: <20231208210855.407580-1-kan.liang@linux.intel.com> <07677ab2-c29b-499b-b473-f7535fb27a8c@linux.intel.com> <4658ca16-9749-434e-9296-3893aa2a34da@linux.intel.com> <14957171-6abd-4fd6-9e05-669b4945c0df@linux.intel.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: <14957171-6abd-4fd6-9e05-669b4945c0df@linux.intel.com> X-Url: http://acmel.wordpress.com Em Fri, Dec 15, 2023 at 01:53:12PM -0500, Liang, Kan escreveu: > On 2023-12-15 1:26 p.m., Arnaldo Carvalho de Melo wrote: > > Right, I implemented it in a slightly different way, but end result > > should be the same: > > From: Arnaldo Carvalho de Melo > > Date: Fri, 15 Dec 2023 15:23:30 -0300 > > Subject: [PATCH 1/1] perf evlist: Move event attributes to after the / when uniquefying using the PMU name > Looks good to me and verified. > Tested-by: Kan Liang I ended up with a bit more simplified version: From 22ecc4601e28a12661f14ca877e39348dab6be8e Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 15 Dec 2023 15:23:30 -0300 Subject: [PATCH 1/1] perf evlist: Move event attributes to after the / when uniquefying using the PMU name When turning an event with attributes to the format including the PMU we need to move the "event:attributes" format to "event/attributes/" so that we can copy the event displayed and use it in the command line, i.e. in 'perf top' we had: 1K cpu_atom/cycles:P/ 11K cpu_core/cycles:P/ If I try to use that on the command line: # perf top -e cpu_atom/cycles:P/ event syntax error: 'cpu_atom/cycles:P/' \___ Bad event or PMU Unable to find PMU or event on a PMU of 'cpu_atom' Initial error: event syntax error: 'cpu_atom/cycles:P/' \___ unknown term 'cycles:P' for pmu 'cpu_atom' valid terms: event,pc,edge,offcore_rsp,ldlat,inv,umask,cmask,config,config1,config2,config3,name,period,freq,branch_type,time,call-graph,stack-size,no-inherit,inherit,max-stack,nr,no-overwrite,overwrite ,driver-config,percore,aux-output,aux-sample-size,metric-id,raw,legacy-cache,hardware Run 'perf list' for a list of valid events Usage: perf top [] -e, --event event selector. use 'perf list' to list available events # Cc: Hector Martin Cc: Ian Rogers Cc: Kan Liang Cc: Marc Zyngier Cc: Mark Rutland Cc: Namhyung Kim Link: https://lore.kernel.org/lkml/ZXxyanyZgWBTOnoK@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evlist.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 6f0892803c2249af..95f25e9fb994ab2a 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -2521,9 +2521,8 @@ void evlist__warn_user_requested_cpus(struct evlist *evlist, const char *cpu_lis void evlist__uniquify_name(struct evlist *evlist) { + char *new_name, empty_attributes[2] = ":", *attributes; struct evsel *pos; - char *new_name; - int ret; if (perf_pmus__num_core_pmus() == 1) return; @@ -2535,11 +2534,17 @@ void evlist__uniquify_name(struct evlist *evlist) if (strchr(pos->name, '/')) continue; - ret = asprintf(&new_name, "%s/%s/", - pos->pmu_name, pos->name); - if (ret) { + attributes = strchr(pos->name, ':'); + if (attributes) + *attributes = '\0'; + else + attributes = empty_attributes; + + if (asprintf(&new_name, "%s/%s/%s", pos->pmu_name, pos->name, attributes + 1)) { free(pos->name); pos->name = new_name; + } else { + *attributes = ':'; } } } -- 2.43.0