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=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, 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 AD6ABC433DB for ; Thu, 4 Mar 2021 20:08:55 +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 386E664F69 for ; Thu, 4 Mar 2021 20:08:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 386E664F69 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=TSgZi5Khvr4IAauGK9kfcJK6qc20ZyAbmL9XyLkOz+w=; b=VRMJlilM5sErzKH0XTL/E9wYA x4Y89ugX4uaRXm/x6nsTWFC6C9CoIDuq28KwpPFSO2XQgB7hVGpIT1zsTs51hxKsAPEithgRhwqmD 79gp0XHVOAh6nFCP3PEz1lR49Hdq33xwls1mxM5uMkiF28AhGXp+zX/1uIceeA0/Jy63OSu5OSKYy 8kz6j5zCX+PqAYuUX2ukOyWudMcZDNuUolCDN1b0w4Pf7pUgtCJPjgopPuKR5ugxygIEWAY1Pep3k 2buX7/X+dQnQcw2Qws2jqzcJXueCwt3bOJX4L2F7btqF6lshMz3Gq3C4REIeFd2eHpDFkFa2Rxqts NpgFQHhGg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHuFW-009tEs-5c; Thu, 04 Mar 2021 20:07:06 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHuFQ-009tCd-8z for linux-arm-kernel@desiato.infradead.org; Thu, 04 Mar 2021 20:07:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=TOSnIoRGX/IFskCbEXE1PadKf5zKC7G0GnjlRFK0Mu4=; b=Xhdye87rWClFR7uIWy69CW6xaM TF8uOWL/szf0Y0+QV0qWj7xqAZHslQeu6ZhWOYFg3wm6R0YcO0zvUIUX2M3sdYDYEkMBx/kkRbQYo nFixdiUieNHNHNlv0z8HzgJ3H3doXaekQckiYphClDv7B49obY3jFbPWs6GpGCumPHzmsz3MwA89W Qn5uCy3UhIRNWLeQL0t7Ju0ajCRlsPRxNl6aAhCyFLXddAXsjQPGWFwTDj55YLVolS8+EvCP2TBfp Afw94ljtwUjWWZKwMSgo6EB4iEXaslvah9ny5jv1OsB6U4YHOdzmgy4Olut/XyiCqMWlXxVXTBqzi lXg4/HlA==; Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHuEr-008VXI-Ea for linux-arm-kernel@lists.infradead.org; Thu, 04 Mar 2021 20:06:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614888364; 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=TOSnIoRGX/IFskCbEXE1PadKf5zKC7G0GnjlRFK0Mu4=; b=hvN8bBQ2jgiEazoNWfRQNIyN+Kfxyeu9T54S09HOf0/nheh7ztWxgT8Bajxkc0Nri6Gfi7 Ys4GS1AyVvnaCeON9SEkDnOXXO3Wu+DGXobvn/T58zjlNay5MRHJvwygOoVOT4uXTM2qKT mLqUsle4MMZvOFv8A88icCRNjvBAQok= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614888378; 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=TOSnIoRGX/IFskCbEXE1PadKf5zKC7G0GnjlRFK0Mu4=; b=NZ4dej9WM39mS35706t/5lxnApTgA6V69i2An9sWmoXh/F7gFMxcKPOmcTktrSUIJsZyhU tXN03ufQR37on4Y3gKO5+Nz9p76cfz3BfiaVELk6D1JVS82Qbey7Pa+1VFNzreGWOgrxLl 9eCp4yvvuD0kgy5OQr2vcxxnj7OtBhg= 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-229-mx1nsWEMOXKXN1D-2itr8g-1; Thu, 04 Mar 2021 15:06:00 -0500 X-MC-Unique: mx1nsWEMOXKXN1D-2itr8g-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 82670193F560; Thu, 4 Mar 2021 20:05:57 +0000 (UTC) Received: from krava (unknown [10.40.196.20]) by smtp.corp.redhat.com (Postfix) with SMTP id E10DD5D9C6; Thu, 4 Mar 2021 20:05:53 +0000 (UTC) Date: Thu, 4 Mar 2021 21:05:52 +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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1614784938-27080-2-git-send-email-john.garry@huawei.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210304_200643_784369_732381B8 X-CRM114-Status: GOOD ( 23.67 ) 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 Wed, Mar 03, 2021 at 11:22:14PM +0800, John Garry wrote: > Calling perf_pmu__find_map(NULL) returns the cpumap for the common CPU > PMU. However arm64 supports heterogeneous-CPU based systems, and so there > may be no common CPU PMU. As such, perf_pmu__find_map(NULL) returns NULL > for arm64. > > To support printing metrics for arm64, iterate through all PMUs, looking > for a CPU PMU, and use the cpumap there for determining supported metrics. > > For heterogeneous systems (like arm big.LITTLE), supporting metrics has > potential challenges, like not all CPUs in a system not supporting a > specific metric event. So just don't support it for now. > > Signed-off-by: John Garry > --- > tools/perf/util/metricgroup.c | 24 +++++++++++++++++++++++- > 1 file changed, 23 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c > index 26c990e32378..9a2a23093961 100644 > --- a/tools/perf/util/metricgroup.c > +++ b/tools/perf/util/metricgroup.c > @@ -6,6 +6,7 @@ > /* Manage metrics and groups of metrics from JSON files */ > > #include "metricgroup.h" > +#include "cpumap.h" > #include "debug.h" > #include "evlist.h" > #include "evsel.h" > @@ -615,10 +616,31 @@ static int metricgroup__print_sys_event_iter(struct pmu_event *pe, void *data) > d->details, d->groups, d->metriclist); > } > > +static struct pmu_events_map *find_cpumap(void) > +{ > + struct perf_pmu *pmu = NULL; > + > + while ((pmu = perf_pmu__scan(pmu))) { > + if (!is_pmu_core(pmu->name)) > + continue; > + > + /* > + * The cpumap should cover all CPUs. Otherwise, some CPUs may > + * not support some events or have different event IDs. > + */ > + if (pmu->cpus && pmu->cpus->nr != cpu__max_cpu()) > + return NULL; > + > + return perf_pmu__find_map(pmu); > + } > + > + return NULL; > +} > + > 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 = find_cpumap(); so this is just for arm at the moment right? 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? thanks, jirka > struct pmu_event *pe; > int i; > struct rblist groups; > -- > 2.26.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel