Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp416600pxb; Fri, 16 Apr 2021 08:43:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS4Xt7JaEEaSdfxRHEFzFHT5/OIoAfInT6tmuLI4E1gyqIj01nUtsOSkQe2j3Ve7xYgC1Z X-Received: by 2002:a05:6a00:bc3:b029:258:17c2:d19f with SMTP id x3-20020a056a000bc3b029025817c2d19fmr7317256pfu.5.1618587809626; Fri, 16 Apr 2021 08:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618587809; cv=none; d=google.com; s=arc-20160816; b=SSF1bYhh4r4ABPmkrwb3XmHL8iDLIr4xrRgZMXEEn5kgVTR2FaNBeu3BPBqMPEgdjO Zljmp/y0NH1w4SnGSG6ECfdmxtN1aBjmnLsV/OLHikR+e/wit3ckNNXO2z3sbdreIp+u 4VCrIAoqUv8qcG2HJwLynnFsvi1gaZXPqOfwrvULm3j5Z9g3XzhXuvXljkVIt91NFJe0 xPmxPI245daDBByn+lGIl2h7K7nE/ibd1DMWW1+KYNUu5onSfPC1Skk4Mzgjt3HtmWWa H+MyC9d847ARuTxn7kunrXtQWotSZSy8TMYozckq8ipqO2hILtDN2kq6zhW6bPbR8NJv f+JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=h6V8qN/FyqPaAvkkL7dIqPZ6bIkthY5jWxUMx1uIPUo=; b=xWXhJtCnnezsi+PGwFxGyyTPbfGvhMiriZHEng/qGiw3PhL1SVFxChcXoWmvr/A3vp WLlraQCtt/eW3Ko+VrkUySZORu25Tqdyzamdoj+x01ShUO6qydJ8ai46pMUM/7cdkmDD gQcxLs2oCSnawzkgzr5yMb0P89G9Yazs4nFmd073yR0ngVicvwJ6ByQKskjEokh7ZQ5F Xh1It1L5poqg/PLSIqblt/VZ/OJdPARRB/i5XJm0o0zajCP0ojVnJNrQro48cQgW4qSB aj0lGiSzKUS+9T6Gu+6ip/5WOKQ3RA8dx0u9h8ZmkxBx2uofbuUzTrVdUrQ1iA6G3fbM 3BOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m13si6707652pgp.424.2021.04.16.08.43.17; Fri, 16 Apr 2021 08:43:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243190AbhDPOIa (ORCPT + 99 others); Fri, 16 Apr 2021 10:08:30 -0400 Received: from mga11.intel.com ([192.55.52.93]:23086 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241911AbhDPOHd (ORCPT ); Fri, 16 Apr 2021 10:07:33 -0400 IronPort-SDR: RguX0Q6x0qMK/oZnGv6YCuW1EPQVaeuEpqJLpBHFKgK5G/IRn3p+4CFDNV60I/xOs+V0BymRF9 ZUlL0jTi6OZw== X-IronPort-AV: E=McAfee;i="6200,9189,9956"; a="191854363" X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="191854363" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2021 07:07:09 -0700 IronPort-SDR: h8z3Qmug4moNMleLlc2UO7ltWGZ0DyWaavEEtVjqxpS155MPeP9LK8iZBnOrCmV9SpXj3Cl4sW CX15ykpMKyew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="612766862" Received: from kbl-ppc.sh.intel.com ([10.239.159.163]) by fmsmga006.fm.intel.com with ESMTP; 16 Apr 2021 07:07:04 -0700 From: Jin Yao To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, Jin Yao Subject: [PATCH v4 17/25] perf record: Uniquify hybrid event name Date: Fri, 16 Apr 2021 22:05:09 +0800 Message-Id: <20210416140517.18206-18-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416140517.18206-1-yao.jin@linux.intel.com> References: <20210416140517.18206-1-yao.jin@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For perf-record, it would be useful to tell user the pmu which the event belongs to. For example, # perf record -a -- sleep 1 # perf report # To display the perf.data header info, please use --header/--header-only options. # # # Total Lost Samples: 0 # # Samples: 106 of event 'cpu_core/cycles/' # Event count (approx.): 22043448 # # Overhead Command Shared Object Symbol # ........ ............ ....................... ............................ # ... Signed-off-by: Jin Yao --- v4: - No change. tools/perf/builtin-record.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 6af46c6a4fd8..3337b5f93336 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1605,6 +1605,32 @@ static void hit_auxtrace_snapshot_trigger(struct record *rec) } } +static void record__uniquify_name(struct record *rec) +{ + struct evsel *pos; + struct evlist *evlist = rec->evlist; + char *new_name; + int ret; + + if (!perf_pmu__has_hybrid()) + return; + + evlist__for_each_entry(evlist, pos) { + if (!evsel__is_hybrid(pos)) + continue; + + if (strchr(pos->name, '/')) + continue; + + ret = asprintf(&new_name, "%s/%s/", + pos->pmu_name, pos->name); + if (ret) { + free(pos->name); + pos->name = new_name; + } + } +} + static int __cmd_record(struct record *rec, int argc, const char **argv) { int err; @@ -1709,6 +1735,8 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) if (data->is_pipe && rec->evlist->core.nr_entries == 1) rec->opts.sample_id = true; + record__uniquify_name(rec); + if (record__open(rec) != 0) { err = -1; goto out_child; -- 2.17.1