Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1075213pxy; Thu, 22 Apr 2021 22:41:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnT4KeXkGAwRQyHVjrlVwRZSiol67aJvxptVpY+u3DKZrJFi7gq8TxeosW0QCK9zDKNy0j X-Received: by 2002:a50:ee0b:: with SMTP id g11mr2442429eds.218.1619156513532; Thu, 22 Apr 2021 22:41:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619156513; cv=none; d=google.com; s=arc-20160816; b=KHj8Cy+4fnESHhnHg0X23fx5KSXhb60Nke99kcxkpIyDt2fPbIOXFqEAZjiEPf05IK HRZHf/21GDn6JcdSqUKHnrmDWoi8YIsiIdZDNnNwsfTqD3Hn+917U3CJvI6NOwBnr9C8 T7393pTUk126pR6O2KnQW7eAKncqMbVrlGOsgBn5BpUJTor4I7fVKUkIuRdWLh68kCzX /51YnvekJfNa/Ba/5r19c4uDw8nxm2IVvDpvahZAfy0P0be5dlkrPzk2ujxxC3SDW6ji Exu9vjtOqG8+3jAQJFMWNgs5NeoDofTXTsZxZA4MH5GliJ7SGVigpJZkLkR7iz3jadvf oP/g== 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=FOAfl1yIIWLIDAJiVs8RtAo9r7VHojVoZ6iC1glmDuw=; b=ewW790R/XxqaK7oQ2tttV0Az2KXYqMKHUPGRtnZFNM4D1vc+tcmM1+dLyrUhWIvh/c V8MMb3qAZI8DYkBI7vPy/Fm3J9PX+pMEG48OkIhTMxknNaG3jmUKwBXoHV73BR5n8vqy nkv2yukwXCN7X7GAgMvN8l/bmk7k0D9J893grueooKj56S7qyfAbGf2TKUfm4cBk3lBw KhbRYr+Dx287mph/4Y4dg4/WXmgYejzSTtyv25EQ+W1yHD2caIdJDQkTWPG8pwtjCUTh etIYEOUeo7WSrRPQxo8hZdzrwqlgAi9+9/6gEjGrZtyPmypiV8UMwex8TJosghNmxvKs kDZA== 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 e2si4135889ejc.732.2021.04.22.22.41.30; Thu, 22 Apr 2021 22:41:53 -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 S240933AbhDWFiT (ORCPT + 99 others); Fri, 23 Apr 2021 01:38:19 -0400 Received: from mga18.intel.com ([134.134.136.126]:9345 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240767AbhDWFh7 (ORCPT ); Fri, 23 Apr 2021 01:37:59 -0400 IronPort-SDR: AYaHEqKSaYE7O7sltDPhDHfw6aycjVOOMpe41W3yLDEjFmsZpVqovioBxnwuQ0y2xkScE9wci3 bXRP3cSiOHaA== X-IronPort-AV: E=McAfee;i="6200,9189,9962"; a="183501849" X-IronPort-AV: E=Sophos;i="5.82,244,1613462400"; d="scan'208";a="183501849" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2021 22:37:23 -0700 IronPort-SDR: j/4Tp0mfsnfrr9PxnKiPso/aUzDLqJ3itEbooLnyIS4/f0g7ec4n+0uv94taMYi8WFyFvTvyoQ yovEsW0zJtyA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,244,1613462400"; d="scan'208";a="386293694" Received: from kbl-ppc.sh.intel.com ([10.239.159.163]) by orsmga006.jf.intel.com with ESMTP; 22 Apr 2021 22:37:20 -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 v5 17/26] perf record: Uniquify hybrid event name Date: Fri, 23 Apr 2021 13:35:32 +0800 Message-Id: <20210423053541.12521-18-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210423053541.12521-1-yao.jin@linux.intel.com> References: <20210423053541.12521-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 --- v5: - No change. 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