Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp93725pxb; Mon, 8 Feb 2021 16:21:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrkkKhOLzcQQDZ4EDkHEcx62yxcnksBiZk6qQqHKP8OTjt0ccAAeSvCbjTuFlt1rfETGrN X-Received: by 2002:a50:e186:: with SMTP id k6mr14520466edl.215.1612830105979; Mon, 08 Feb 2021 16:21:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612830105; cv=none; d=google.com; s=arc-20160816; b=PA1BNn7bVxl+9hiwYzimcDaHBiWRPDh3Vn1VMJ4alqk5f3r+XZs5PG7L3O6iR2HpNW iey+u9uRWyrkHbY4OVztUoo+GJ5ruzpGuTaPLaZyUg9PSqoCB3oGY5NSQ+ckBBXupD4W HNOcr1jrAn8bg1cSeFrgugPvQfNSSlT3xduyMUXG7hSQcCabzl/9YAmHLiVkY+VrYKUG 0AefBft9eIadzVkSKqdfUxWShRDYNk0sHCCnNgVIoz29iDoIddGJxOGmYv2raBTukwZw uoZVvEbdN6zGWn+B4BNVnEWVFEXaHN3dBU60hPLlcS4Ccq2cJkahczwtKErlmAuf5BlZ lPXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=k2+KIHPUXXpEqHfHUUk0r/LlWuERb8VhsWjWMb8UuRM=; b=yGKmlcg5EGOKM5dhMvlVdGUenD7gdJHiQP1/CrgVO5futw+0v3GftLg8RmD/ZyeaCD iDONe7U+V1HdqeDvDKeeR9K/XiQERo0MbT4pBevfxdien57Aj6m7glSzq20T6lv5kkd3 4LEviJpSYigvR+B2knqcFYFqIIsH9zznXaTtNEXDtvGi5mjjyoOGfw1kVEmIv1rRiFOl BoOgBb9wpvO0qT34ZWay/KjOWi1aeXLrrgDR+k5GlZ4KVEe3dt9hquWCqU2YyJzYlw26 6sK5zbuqo13SGAKRWFM4HQUsWgC/KH+t44akr8ZcYAWervHk44AIdZYd6i9Hurje6W1c rqlg== 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 da23si51343edb.584.2021.02.08.16.21.22; Mon, 08 Feb 2021 16:21:45 -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 S229671AbhBIAT2 (ORCPT + 99 others); Mon, 8 Feb 2021 19:19:28 -0500 Received: from mga12.intel.com ([192.55.52.136]:47541 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbhBIAT1 (ORCPT ); Mon, 8 Feb 2021 19:19:27 -0500 IronPort-SDR: ZJQCO/A3787mfUV0ZUWZHh+9B5Rumv23ViYKSf79xhWk51zaQ5CRHEftU34X972bBF/SKU1ggM O6WFflld8Gxg== X-IronPort-AV: E=McAfee;i="6000,8403,9889"; a="160957488" X-IronPort-AV: E=Sophos;i="5.81,163,1610438400"; d="scan'208";a="160957488" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2021 16:17:41 -0800 IronPort-SDR: u6DxJ2vfJjDslyiSUWZ5Rx31sPnoNoA2G2fmV4r476kY2YGGWEQ1GsT5+NEri8VCZKLFjD+g0u ppdDucux2tlQ== X-IronPort-AV: E=Sophos;i="5.81,163,1610438400"; d="scan'208";a="395797398" Received: from yjin15-mobl1.ccr.corp.intel.com (HELO [10.238.4.27]) ([10.238.4.27]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2021 16:17:38 -0800 Subject: Re: [PATCH 27/49] perf util: Save pmu name to struct perf_pmu_alias To: Arnaldo Carvalho de Melo , 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, alexander.shishkin@linux.intel.com, adrian.hunter@intel.com, "Jin, Yao" References: <1612797946-18784-1-git-send-email-kan.liang@linux.intel.com> <1612797946-18784-28-git-send-email-kan.liang@linux.intel.com> <20210208185732.GK920417@kernel.org> From: "Jin, Yao" Message-ID: <07a75656-a49d-0ca9-b1f5-e69501a5dd9c@linux.intel.com> Date: Tue, 9 Feb 2021 08:17:35 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210208185732.GK920417@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnaldo, On 2/9/2021 2:57 AM, Arnaldo Carvalho de Melo wrote: > 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? > Yes, I'm thinking the changes as following, Before: static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, char *desc, char *val, char *long_desc, char *topic, char *unit, char *perpkg, char *metric_expr, char *metric_name, char *deprecated); After: static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name, char *desc, char *val, struct pmu_event *pe); That looks much simpler than before. Thanks Jin Yao >> } >> >> 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 >> >