Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6853901rdb; Fri, 15 Dec 2023 09:59:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCKCCLVpxdL8H4gWG6n/FNuI/xteJgk5sy+Wgtqt5V30uInl8CRhNLRC8BpsJwEBk/XfDm X-Received: by 2002:a05:6a21:1a4:b0:18f:e502:b67 with SMTP id le36-20020a056a2101a400b0018fe5020b67mr16954728pzb.32.1702663163633; Fri, 15 Dec 2023 09:59:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702663163; cv=none; d=google.com; s=arc-20160816; b=hoFWOa8QO8Dc2FU8LDLFps1ThlYyfaeYmzcgYQ9Y+qxPAvlPdP5iNd707SsXLQTDRl MhoqL2Ecb3whLjq54m9nxxTW+ifZeE/4WRqBpFi/kTCG5dK9yVmD8UR0U4uL7ilkyIG/ QxlPWP+cAPKrNiB+ksoUOS6btKEUpglcpBIb0DfJrAI+GXPKFFH/633jGEs/w9ql0MFU /MGm1aAttgKzB/ObYFUMa1G9k0rHhj4qmMcngI7UJHIUE4UWokltMR2OcwJLCWx25RtQ 74IEDYRBzt1pV4eO5XDxB0it93SHH0aIp8+rTSUIYEs9P+jKgc7m9OD63ByoT/82AwrR XlGQ== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1492-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 b30-20020a631b5e000000b005bdc49ba91bsi12715900pgm.151.2023.12.15.09.59.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 09:59:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1492-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=@intel.com header.s=Intel header.b=DMd0Xkx8; spf=pass (google.com: domain of linux-kernel+bounces-1492-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1492-linux.lists.archive=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 AFC3A2816B3 for ; Fri, 15 Dec 2023 17:59:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77D0A30121; Fri, 15 Dec 2023 17:55:24 +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 Content-Transfer-Encoding: 8bit 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; -- 2.35.1