From patchwork Fri Dec 15 17:54:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 179499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9464686dys; Fri, 15 Dec 2023 09:59:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhYWVC47QAF1kfxmPHKK4auZxt8ZsLPoYmCE/jnUsfXn+HtckpBX1z8hTWvRGq6oofiBda X-Received: by 2002:a05:6a20:3d23:b0:18c:d9:b413 with SMTP id y35-20020a056a203d2300b0018c00d9b413mr18727892pzi.5.1702663170775; Fri, 15 Dec 2023 09:59:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702663170; cv=none; d=google.com; s=arc-20160816; b=Pp9DrPCZ0aIXNchCXoCwmn9ssjFVOiPylb4g/HcLyWXpQ1m4pxjaiqDbPS7TxXRku5 Li1winlrfH75mwrc4M4DDFOMa1h6TCUwjYuxTzhyPyusX9wK5FBFXagObmkFpPKOHRbI gjs+Gs11krfsbpK5lZ+1F361jCrUJzdqt92RqbTM1NK2sx8QPb8S6/3TPr+8DsqD08Ic 5eMt7/zN4+0AUk7Zn5nopIiAFYrnouxHRSqmfJJgR2WGeR4kLYjjnX+S+8RMgl2H96hT UjDszWCg/iRKHdWUxKClV1XD3m/+EaeROMg+CIIVvEc2DA9S9yQtH8wWb1im9j/X9I9r JRwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=YTx9d8b9bU1LYXj83zkPpR9UfvtqnbJ+247Z0D0NHts=; fh=V97FFFi5RmpdUikarEoLTJWoOplAC1MpM9MGOX1xMoI=; b=j7QS1sZB/f2ljo2B4VGa4XAyDFlmRCOmR6OpEErRAwMJRbDHk3WxwDo0tNCq+eOI01 xLCYFFZAVlZefgDDQEKePxGpXy9aohoLIqUm5K7jbVTmmvsJwPnn8JG6pOny5f7jth8s 9CxjgcpwyFZa+CrY3m3tJvRhmtl20QQKDX5qgfBU/NAok9r8HmYkvmfqy+digeqJVqoI X0WcEHoVyf2H2HCS1lRIU32Abo+stPxMFFuY8kvRMhEIX+CR0+EypcOZxESVVpoIFIEq A7yS4zROW70yb2oLzWJDuECRQ+Cp2XFlAdANKyPtS7lrCANnilG+8e/gLSbCW7nfaAVR Ut5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DMd0Xkx8; spf=pass (google.com: domain of linux-kernel+bounces-1492-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1492-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t12-20020a6564cc000000b005c221909d4asi12804491pgv.830.2023.12.15.09.59.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 09:59:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1492-ouuuleilei=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=@intel.com header.s=Intel header.b=DMd0Xkx8; spf=pass (google.com: domain of linux-kernel+bounces-1492-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1492-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 81127283733 for ; Fri, 15 Dec 2023 17:59:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0DC283013E; Fri, 15 Dec 2023 17:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DMd0Xkx8" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) (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 C51FE82EEF; Fri, 15 Dec 2023 17:55:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702662921; x=1734198921; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=UH9+q6pJRO5+cSo0tmTFEhgrE0ZiEhcMwoihcTVbnBc=; b=DMd0Xkx8dysAqTT3ZLWeovd5mw1LXu3gfTxoM+lZX8BSDjD+bQkhdjSc OSpgKRWPSJEnjGcPCe9/lCnmsxMzALgkop07/JjjmwA+k44/B77dvNTmR PXy4mWgwh1yDq9+xYnA5h83Yb2DKiscDXJr1+s1BaxdyVuALkwheAinZf YmQ58NnBKvQejmsNV3PazBEYpJLuq0pePcSFbfwxV/ZpKc6EDjOm8WbS1 JmqXThmwcKyDYTJoVehwCaP/cXrM8EV1rdkPmBzFwKEdRpcvJMpD3Y7C+ xiIaaUH8W+nXYzrYiqOiR4h+fU9oVc55m3wmPdvpByt7/rQCRp5BpIrpQ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10925"; a="375456303" X-IronPort-AV: E=Sophos;i="6.04,279,1695711600"; d="scan'208";a="375456303" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2023 09:55:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10925"; a="840745963" X-IronPort-AV: E=Sophos;i="6.04,279,1695711600"; d="scan'208";a="840745963" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga008.fm.intel.com with ESMTP; 15 Dec 2023 09:55:20 -0800 From: kan.liang@linux.intel.com To: acme@kernel.org, irogers@google.com Cc: namhyung@kernel.org, mark.rutland@arm.com, maz@kernel.org, marcan@marcan.st, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Kan Liang Subject: [PATCH] perf evlist: Move the modifier after the slash when rename a hybrid event Date: Fri, 15 Dec 2023 09:54:55 -0800 Message-Id: <20231215175455.1300261-1-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785371737214514487 X-GMAIL-MSGID: 1785371737214514487 From: Kan Liang The event name shown in the perf top is wrong on a hybrid machine. $perf top 1K cpu_atom/cycles:P/ 11K cpu_core/cycles:P/ If using it on the command line: $perf top -e cpu_atom/cycles:P/ event syntax error: 'cpu_atom/cycles:P/' \___ Bad event or PMU The evlist__uniquify_name() changes a hybrid event name to "//" style. When using the "//" style, the event modifiers must be appended after the last "/". Split the old name into event and modifier. Apply the correct format for the "//" style. The patch fixes the same issue on the perf record as well. Reported-by: Arnaldo Carvalho de Melo Closes: https://lore.kernel.org/lkml/ZXxyanyZgWBTOnoK@kernel.org/ Signed-off-by: Kan Liang --- tools/perf/util/evlist.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 6f0892803c22..83f4e3ec62d0 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -2521,8 +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, *old_name, *modifier, *tmp; struct evsel *pos; - char *new_name; int ret; if (perf_pmus__num_core_pmus() == 1) @@ -2535,8 +2535,13 @@ void evlist__uniquify_name(struct evlist *evlist) if (strchr(pos->name, '/')) continue; - ret = asprintf(&new_name, "%s/%s/", - pos->pmu_name, pos->name); + /* The event modifiers must be appended after "/" */ + old_name = strtok_r(pos->name, ":", &tmp); + if (!old_name) + continue; + modifier = strtok_r(NULL, ":", &tmp); + ret = asprintf(&new_name, "%s/%s/%s", + pos->pmu_name, old_name, !modifier ? "" : modifier); if (ret) { free(pos->name); pos->name = new_name;