Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4285316pxb; Mon, 8 Feb 2021 12:25:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3x63RqZq3+ucrpWBbKr82vmzTk0Ifgmubap0pPj7TZ/A1IOQArC6cA8sJF2hmP0GVNW9E X-Received: by 2002:a17:906:7253:: with SMTP id n19mr18875949ejk.543.1612815949395; Mon, 08 Feb 2021 12:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612815949; cv=none; d=google.com; s=arc-20160816; b=su6+g+N4NIIkyMUf0uo+pFWDLswoHDTWtekxWjnPK1BWS+NjS7B4fS+EvBozjUtuLm q8wQKDVZGr55ZrzNjAMJJigJcF4u20UyN0tSxgJq6ct8H1kGw/gxBD9Gp1+hmHyo8kpb Hvf5RdiQWmaHqewsbHx8hPcCNpWlWW6NRnZ0e6ERDFDPWlsOUY3VK2lVkNwQfs56d5TN i8Gj7tFM2x6oitKUCKJdzLwzjIpPTTD7fw9yXwP+JNOsxhcQ+GEFIc+TZFPy+Z4FYOKm X5I1hn7rmA/0/fAn8nxBL1k8xdSy2Z4Uwae5QEpmRoNG3F37ryVXpr1x9Hjw57+IOrYY DWfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DbBkQUi9E3JsEhbieypPSLu3xsDw64bTcPGnr8iWJmg=; b=NGkbNn6VsF2eGlEuDYJSl7xMHKSKIuUSnmTYarpMko6aieQs/36vEStoi+xSNrEhnQ 9Gv5BcmCVXBWVVot+2slABWEU9XHaVjZDPZYqEmITb5Pegyapw79npAAhL9SmaHV4VdQ 5WT2yxNS9EZIO1S/CU++UHIL3YYPUcVykmS/sqHDXjEQ/XvmzyIbQNBoT8jyNRlirVVr aGriXQjMYWYhgxmiKXvxRB+VQNP1KI242sP3nefTEwlLbu322FN8w87nR6dubQfu3wad aiRS0wRafsJkzRFPPF+s3ABIkDzN2G4AyqxM7rVddShsmU5hR0JeFyZAL+PRsMWDTdcv DgPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OJMNNgLF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si3879235edy.96.2021.02.08.12.25.26; Mon, 08 Feb 2021 12:25:49 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OJMNNgLF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236828AbhBHUWq (ORCPT + 99 others); Mon, 8 Feb 2021 15:22:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:34074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235383AbhBHS6Q (ORCPT ); Mon, 8 Feb 2021 13:58:16 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2EE0264E59; Mon, 8 Feb 2021 18:57:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612810655; bh=a6yQPRTEk7vZQGLw53cjDyiNa69Lzt2uZX/PWzN8GVc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OJMNNgLFVhLphi5pyDhLhbl/H5pQIXD2tlLi5irAuof0c6irk1Pz5O1AF/LUhH9NU QX8PstPwqJzmcal0LpgjUaZE1rrFCaEkBJeCvc1cOrllIQDjBAxySuTpkIAcYoLkAT pviHhn4PGsWXj6XeDKv6iDLg3Q9rXYMXF3R9WIyntdqElwqjh8nTfpCT3F6wr4eBpa dNALaBqBaDboB9aT01mxz5GeAwNrGS/VMRg9BUkJ15fOwZ5aXBDuPF7QTO2SJlPB7J EEl9DRCT4MwytpV/hJm4U0SiMMX4oXt6LCfmiN1afgfX+gNMxuLfXtaG+TSkYQHQKY B9SYUIluyTuuQ== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id CD9AC40513; Mon, 8 Feb 2021 15:57:32 -0300 (-03) Date: Mon, 8 Feb 2021 15:57:32 -0300 From: Arnaldo Carvalho de Melo To: kan.liang@linux.intel.com Cc: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, bp@alien8.de, namhyung@kernel.org, jolsa@redhat.com, ak@linux.intel.com, yao.jin@linux.intel.com, alexander.shishkin@linux.intel.com, adrian.hunter@intel.com Subject: Re: [PATCH 27/49] perf util: Save pmu name to struct perf_pmu_alias Message-ID: <20210208185732.GK920417@kernel.org> References: <1612797946-18784-1-git-send-email-kan.liang@linux.intel.com> <1612797946-18784-28-git-send-email-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1612797946-18784-28-git-send-email-kan.liang@linux.intel.com> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Feb 08, 2021 at 07:25:24AM -0800, kan.liang@linux.intel.com escreveu: > From: Jin Yao > > On hybrid platform, one event is available on one pmu > (such as, cpu_core or cpu_atom). > > This patch saves the pmu name to the pmu field of struct perf_pmu_alias. > Then next we can know the pmu where the event can be enabled. > > Reviewed-by: Andi Kleen > Signed-off-by: Jin Yao > --- > tools/perf/util/pmu.c | 17 +++++++++++++---- > tools/perf/util/pmu.h | 1 + > 2 files changed, 14 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c > index 44ef283..0c25457 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; > @@ -311,7 +316,8 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, > char *unit, char *perpkg, > char *metric_expr, > char *metric_name, > - char *deprecated) > + char *deprecated, > + char *pmu) > { > struct parse_events_term *term; > struct perf_pmu_alias *alias; > @@ -382,6 +388,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; > @@ -407,7 +414,7 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI > strim(buf); > > return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL, NULL, > - NULL, NULL, NULL, NULL); > + NULL, NULL, NULL, NULL, NULL); > } > > static inline bool pmu_alias_info_file(char *name) > @@ -797,7 +804,8 @@ void pmu_add_cpu_aliases_map(struct list_head *head, struct perf_pmu *pmu, > (char *)pe->unit, (char *)pe->perpkg, > (char *)pe->metric_expr, > (char *)pe->metric_name, > - (char *)pe->deprecated); > + (char *)pe->deprecated, > + (char *)pe->pmu); > } > } > > @@ -870,7 +878,8 @@ static int pmu_add_sys_aliases_iter_fn(struct pmu_event *pe, void *data) > (char *)pe->perpkg, > (char *)pe->metric_expr, > (char *)pe->metric_name, > - (char *)pe->deprecated); > + (char *)pe->deprecated, > + NULL); At some point I think passing the whole 'struct pme_event' pointer should be better? > } > > return 0; > diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h > index 8164388..0e724d5 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.7.4 > -- - Arnaldo