From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B4F1C433DB for ; Sat, 6 Mar 2021 19:36:09 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D368F650CC for ; Sat, 6 Mar 2021 19:36:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D368F650CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=e/YpvHoKtG7wON0+yxZYFGjf2eUZRWvXc+g0N/LI0D8=; b=CEI+/7fw/UaHeH97U9saXQNrR k0MjggWGbN1Uo8w/CJvME8hN3op4B7ZZIVD+2tIn29pIdOVxXWFALYpchA8PTfKmVCvWMHqeDKQup 6EI2vYUGZ+yvJEfbeumztmC3htMTGI/feE/nVQjXBZFyC6uVRBD8LblYD9m9vW6C9W0/H3dnqZ2o9 F9KqMpxhCq6Z1nxKOBfolNHOoq6yulrrP+T2R1bCB5tc+PUZkGtNyso7GDsv4iSTcLKNCr1bwTkJ3 2cLmgzmTyimdvmQrlXASLB4r1ZDn/smOhHwJdAdXUrjsMxvGnMvAsM1w9Pq5/TNrM52/G7IJprbsB cWNKr0SSQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lIch4-004QuH-Tw; Sat, 06 Mar 2021 19:34:31 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1234::107]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lIch2-004Qtc-I7 for linux-arm-kernel@lists.infradead.org; Sat, 06 Mar 2021 19:34:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=cZ/0UpjlDaAlIEYFykpQQPa4f11Jamk3TyEJDHiIAHk=; b=BerpCgyuaRN75qeJPK+E57Axt1 SQ4rWo/ysCMnWri609+UnW1QnCOl4gv2Dus7eP3nt83iPj0I0SQ5/kvxQSjBKKPCIIEfkpr/7Ik6N Yjsw2IGhFWwAz9hztgBuqSj/NKhJGtt87PvOGKEp/FCPrhIJmJefbEecpyx3E7hO1HiCsBFGXbIZW DSsjnAURukmLubBwhgvcRjP1ZHG5L8ccNPS2zDsw4Eh3t7bq/Q44vcGP7zRrlh2KOMVztOpele0Ph rCInerwTlizSU3gj71aTwvPQgLxbqW6hgCZXQ9rGCqZuWltcoyDkF/y22a/ZO7ahbnxAOV/XLAWXN j9fWD4UQ==; Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by merlin.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lIch0-000GMi-CT for linux-arm-kernel@lists.infradead.org; Sat, 06 Mar 2021 19:34:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615059263; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cZ/0UpjlDaAlIEYFykpQQPa4f11Jamk3TyEJDHiIAHk=; b=G9OOg7QjwUcef5CRrVMkqQ1b7HO9LBEmW5yvppo6NIBJGoJCPN7ugHtRUlwFRmcMAoAssa eGdDGcyCnf2Fq9jYf9G/kaKjH0JOBs8ljKDkWqGPY/I9DefniT7/DlO++oYlMqI2nbjEA3 lLZL7s1Vxvpuj8oRuNZCnMYtMMFM+A8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-403-eYgJsONjPtOXUcjdSwp13g-1; Sat, 06 Mar 2021 14:34:21 -0500 X-MC-Unique: eYgJsONjPtOXUcjdSwp13g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E86951074644; Sat, 6 Mar 2021 19:34:18 +0000 (UTC) Received: from krava (unknown [10.40.192.64]) by smtp.corp.redhat.com (Postfix) with SMTP id 6BC135D9C6; Sat, 6 Mar 2021 19:34:15 +0000 (UTC) Date: Sat, 6 Mar 2021 20:34:14 +0100 From: Jiri Olsa To: John Garry Cc: will@kernel.org, mathieu.poirier@linaro.org, leo.yan@linaro.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org, irogers@google.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com, zhangshaokun@hisilicon.com, qiangqing.zhang@nxp.com, kjain@linux.ibm.com Subject: Re: [PATCH 1/5] perf metricgroup: Support printing metrics for arm64 Message-ID: References: <1614784938-27080-1-git-send-email-john.garry@huawei.com> <1614784938-27080-2-git-send-email-john.garry@huawei.com> <95205463-4c80-4e8a-a7c0-c2a4e4553838@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <95205463-4c80-4e8a-a7c0-c2a4e4553838@huawei.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Mar 05, 2021 at 11:06:58AM +0000, John Garry wrote: > > Hi Jirka, > > > > - struct pmu_events_map *map = perf_pmu__find_map(NULL); > > > + struct pmu_events_map *map = find_cpumap(); > > so this is just for arm at the moment right? > > > > Yes - but to be more accurate, arm64. > > At the moment, from the archs which use pmu-events, only arm64 and nds32 > have versions of get_cpuid_str() which require a non-NULL pmu argument. > > But then apparently nds32 only supports a single CPU, so this issue of > heterogeneous CPUs should not be a concern there :) > > > could we rather make this arch specific code, so we don't need > > to do the scanning on archs where this is not needed? > > > > like marking perf_pmu__find_map as __weak and add arm specific > > version? > > Well I was thinking that this code should not be in metricgroup.c anyway. > > So there is code which is common in current perf_pmu__find_map() for all > archs. > > I could factor that out into a common function, below. Just a bit worried > about perf_pmu__find_map() and perf_pmu__find_pmu_map() being confused. right, so perf_pmu__find_map does not take perf_pmu as argument anymore, so the prefix does not fit, how about pmu_events_map__find ? thanks, jirka > > Here's how that would look: > > +++ b/tools/perf/arch/arm64/util/pmu.c > > #include "../../util/cpumap.h" > #include "../../util/pmu.h" > > struct pmu_events_map *perf_pmu__find_map(void) > { > struct perf_pmu *pmu = perf_pmu__find("armv8_pmuv3_0"); > > if (!pmu || !pmu->cpus || pmu->cpus->nr != cpu__max_cpu()) > return NULL; > > return perf_pmu__find_pmu_map(pmu); > } > > And: > > diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c > index 26c990e32378..312164ce9299 100644 > --- a/tools/perf/util/metricgroup.c > +++ b/tools/perf/util/metricgroup.c > @@ -618,7 +618,7 @@ static int metricgroup__print_sys_event_iter(struct > pmu_event *pe, void *data) > void metricgroup__print(bool metrics, bool metricgroups, char *filter, > bool raw, bool details) > { > - struct pmu_events_map *map = perf_pmu__find_map(NULL); > + struct pmu_events_map *map = perf_pmu__find_map(); > struct pmu_event *pe; > int i; > struct rblist groups; > @@ -1253,8 +1253,7 @@ int metricgroup__parse_groups(const struct option > *opt, > struct rblist *metric_events) > { > struct evlist *perf_evlist = *(struct evlist **)opt->value; > - struct pmu_events_map *map = perf_pmu__find_map(NULL); > - > + struct pmu_events_map *map = perf_pmu__find_map(); > > return parse_groups(perf_evlist, str, metric_no_group, > metric_no_merge, NULL, metric_events, map); > @@ -1273,7 +1272,7 @@ int metricgroup__parse_groups_test(struct evlist > *evlist, > > bool metricgroup__has_metric(const char *metric) > { > - struct pmu_events_map *map = perf_pmu__find_map(NULL); > + struct pmu_events_map *map = perf_pmu__find_map(); > struct pmu_event *pe; > int i; > > diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c > index 44ef28302fc7..d49bf20b6058 100644 > --- a/tools/perf/util/pmu.c > +++ b/tools/perf/util/pmu.c > @@ -690,7 +690,7 @@ static char *perf_pmu__getcpuid(struct perf_pmu *pmu) > return cpuid; > } > > -struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu) > +struct pmu_events_map *perf_pmu__find_pmu_map(struct perf_pmu *pmu) > { > struct pmu_events_map *map; > char *cpuid = perf_pmu__getcpuid(pmu); > @@ -717,6 +717,11 @@ struct pmu_events_map *perf_pmu__find_map(struct > perf_pmu *pmu) > return map; > } > > +struct pmu_events_map *__weak perf_pmu__find_map(void) > +{ > + return perf_pmu__find_pmu_map(NULL); > +} > + > bool pmu_uncore_alias_match(const char *pmu_name, const char *name) > { > char *tmp = NULL, *tok, *str; > @@ -805,7 +810,7 @@ static void pmu_add_cpu_aliases(struct list_head *head, > struct perf_pmu *pmu) > { > struct pmu_events_map *map; > > - map = perf_pmu__find_map(pmu); > + map = perf_pmu__find_pmu_map(pmu); > if (!map) > return; > > > Thoughts? > > Thanks! > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel