Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp127521pxf; Wed, 10 Mar 2021 23:10:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2/oDBJ80sx89xww2EuaEMa5eBBsg90AsCdyrUBUUDSqbIL2wtFACZ+uHUSFuy3oxH6DRq X-Received: by 2002:a17:906:819:: with SMTP id e25mr1726802ejd.292.1615446642884; Wed, 10 Mar 2021 23:10:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615446642; cv=none; d=google.com; s=arc-20160816; b=XgGbvoHrrYnV718vWUneFTyexZQ16VSe8nZjK3lD0jwGT3eAM6oHRzAk1fFN7wpaJO VqXjq+v8AUTnKpkVaE1tuZ0cahqcOOWcpCghsUpb+PrQFL1X6q2THI2zckHAtZPyi0za h8CgMqCkd8iGwUVrRCcxjXNoXmmKYEPqGMlxzjYjC3aczgMHE96osdDC/PZr4YiU3VeM Rd4A+6a+CAqV2aQ8paatgtL+Uaum3Usqb43xCnzfQ2oMyyV2Miub0u8/4ieXouxkeH7+ wSoAk7QzWbbdcwjAFlfqSALGRL/JSnOxlVi66yIhC2e707h4fubaR5hnaUrQzqsk00H5 yu+Q== 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=2zd5Fv/rlTJlntblBNjTpwVrvzEpxvPkRnh7Oj/GY4c=; b=xBVO8Z8PWgcgIPh9I0chG5hIHH9pO7JKS4u2HESSiPoqLm/gtCpOt239b/w7s1QVBK y7HQ7V6CvroehWmGuQJ+WiVKjtuqZyyNtGz7GKYHJn/axHb8vkkIvejezZ1JnJzw3Qwa +8p5/5qr5//TogTha89+AW5jSdp3QLI6sX7UjBQuBV66+lo+GYsXr2RoeuvIgobD/MXe 4l1iCoI9gbiRpb3G05szPCaOeGBEMtTZd8j6OL83OmFiVNg/F1IsJi4QxDrA8rHzQfgE w/ZVmGNb8oEiK5G3R6JJfj0GRdMk8cCoS/c9Xb//1OBh13sI9tGYr+oYImzY36hZQTXy oxgw== 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 l25si1264193ejg.664.2021.03.10.23.10.20; Wed, 10 Mar 2021 23:10:42 -0800 (PST) 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 S231706AbhCKHI7 (ORCPT + 99 others); Thu, 11 Mar 2021 02:08:59 -0500 Received: from mga04.intel.com ([192.55.52.120]:22599 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231617AbhCKHI3 (ORCPT ); Thu, 11 Mar 2021 02:08:29 -0500 IronPort-SDR: T+AMjx+fWq3qDl8LSr6JxNvuZ74+l+4UyplouRZZ50Hfq+Dny663L4lfXrdtdwoz7bl0uSiPYy NpPIRWnJQjag== X-IronPort-AV: E=McAfee;i="6000,8403,9919"; a="186246023" X-IronPort-AV: E=Sophos;i="5.81,239,1610438400"; d="scan'208";a="186246023" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 23:08:29 -0800 IronPort-SDR: bfKadKmFQMDoWch046TEdIuMkOpxnHdhqFAeBLWbFgwaQxpPefrK4LvvGjQ+6e9rVNA/vXvSnG H1R/rjUH1F3Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,239,1610438400"; d="scan'208";a="509937829" Received: from kbl-ppc.sh.intel.com ([10.239.159.163]) by fmsmga001.fm.intel.com with ESMTP; 10 Mar 2021 23:08:26 -0800 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 v2 04/27] perf pmu: Save pmu name Date: Thu, 11 Mar 2021 15:07:19 +0800 Message-Id: <20210311070742.9318-5-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210311070742.9318-1-yao.jin@linux.intel.com> References: <20210311070742.9318-1-yao.jin@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On hybrid platform, one event is available on one pmu (such as, available on cpu_core or on cpu_atom). This patch saves the pmu name to the pmu field of struct perf_pmu_alias. Then next we can know the pmu which the event can be available on. Signed-off-by: Jin Yao --- tools/perf/util/pmu.c | 10 +++++++++- tools/perf/util/pmu.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 54e586bf19a5..45d8db1af8d2 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -283,6 +283,7 @@ void perf_pmu_free_alias(struct perf_pmu_alias *newalias) zfree(&newalias->str); zfree(&newalias->metric_expr); zfree(&newalias->metric_name); + zfree(&newalias->pmu); parse_events_terms__purge(&newalias->terms); free(newalias); } @@ -297,6 +298,10 @@ static bool perf_pmu_merge_alias(struct perf_pmu_alias *newalias, list_for_each_entry(a, alist, list) { if (!strcasecmp(newalias->name, a->name)) { + if (newalias->pmu && a->pmu && + !strcasecmp(newalias->pmu, a->pmu)) { + continue; + } perf_pmu_update_alias(a, newalias); perf_pmu_free_alias(newalias); return true; @@ -314,7 +319,8 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, int num; char newval[256]; char *long_desc = NULL, *topic = NULL, *unit = NULL, *perpkg = NULL, - *metric_expr = NULL, *metric_name = NULL, *deprecated = NULL; + *metric_expr = NULL, *metric_name = NULL, *deprecated = NULL, + *pmu = NULL; if (pe) { long_desc = (char *)pe->long_desc; @@ -324,6 +330,7 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, metric_expr = (char *)pe->metric_expr; metric_name = (char *)pe->metric_name; deprecated = (char *)pe->deprecated; + pmu = (char *)pe->pmu; } alias = malloc(sizeof(*alias)); @@ -389,6 +396,7 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, } alias->per_pkg = perpkg && sscanf(perpkg, "%d", &num) == 1 && num == 1; alias->str = strdup(newval); + alias->pmu = pmu ? strdup(pmu) : NULL; if (deprecated) alias->deprecated = true; diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 8164388478c6..0e724d5b84c6 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -72,6 +72,7 @@ struct perf_pmu_alias { bool deprecated; char *metric_expr; char *metric_name; + char *pmu; }; struct perf_pmu *perf_pmu__find(const char *name); -- 2.17.1