From patchwork Fri Apr 17 10:41:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11494733 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B1BCE6CA for ; Fri, 17 Apr 2020 10:46:35 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 862F7221EC for ; Fri, 17 Apr 2020 10:46:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kNj+SrfR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 862F7221EC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jjjLO1fZRZt3oLzE3ADfqx3I6XQ+Epf8VwMF/IzJXGs=; b=kNj+SrfR6Q1w3v ab6d0m7+vk0fcNntA+wVETiOFJpM8TTSUzh2KywVemfBTo6k23Bfz9xRhJl3yMMLoaat2RqUlACBb z/9yCoS9LqUXJVRNEjmxx/7TK7XvbRQ0i6HhcD4gSjquwBj7B4wXAuLYw+UdaneefqVt8TjWFPjDL OWCQeji7IvLItMERUFTSlAHkiPjqN8MLGpW8hF+jTIsriFNUuqqUkWZBQ2OADdUkop71pqIOXAGyK 6v5hB0U/nxJPXU5GXDD6uOOeh7NKOO/LbZ2bRG1HuqpdaY++pcMWSArq9oZ36o58+CE9HYDjpulSX C+ATk1XseHFbnR+0h9Hw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOVv-0001Wj-Oj; Fri, 17 Apr 2020 10:46:27 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOV0-0000gl-HL for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 10:45:32 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A5516EDDB903E51E6C70; Fri, 17 Apr 2020 18:45:26 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Apr 2020 18:45:18 +0800 From: John Garry To: , , , , , , , Subject: [RFC PATCH v2 01/13] perf parse-events: Fix comparison of evsel and leader pmu name Date: Fri, 17 Apr 2020 18:41:12 +0800 Message-ID: <1587120084-18990-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1587120084-18990-1-git-send-email-john.garry@huawei.com> References: <1587120084-18990-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_034531_151853_344C7D3B X-CRM114-Status: GOOD ( 11.31 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.32 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: irogers@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, John Garry , qiangqing.zhang@nxp.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Since we now strdup() the pmu name for the event selector, use strcmp() instead of pointer equality for comparison. Fixes: d4953f7ef1a2 ("perf parse-events: Fix 3 use after frees found with clang ASANutil/parse-events.c") Signed-off-by: John Garry --- I am not 100% sure that this is the right fix.... tools/perf/util/parse-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 10107747b361..90ddade1ba23 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1629,7 +1629,7 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list, * event. That can be used to distinguish the leader from * other members, even they have the same event name. */ - if ((leader != evsel) && (leader->pmu_name == evsel->pmu_name)) { + if ((leader != evsel) && !strcmp(leader->pmu_name, evsel->pmu_name)) { is_leader = false; continue; } From patchwork Fri Apr 17 10:41:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11494753 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C02B1174A for ; Fri, 17 Apr 2020 10:49:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 9DADA221EC for ; Fri, 17 Apr 2020 10:49:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="vDeX0bbT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DADA221EC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dxgPzsTZO7b0cFXtk1I8gArCB4NozLnqZAE0c3kNzmo=; b=vDeX0bbTaNyG+k Fbt4YzfdFqVFCxk4uxQ/ehqNk9CWHvD+gIyxpRAZuF7LiMJs+X9tUa2VFQo8vGT8aO/mk7/BMRbPv 6xa8LoYMsHXSLMC9quODj1WNp/gFNFMUiSzcj81vB2hDUGBsUL9yo3QJG1GHLgDxAmtLvUlWW0uEV po1hXyOUvG6YbvURMZfA3/ETI848pcH7z5Pr8u22jK9xS18YERgonu31pa8Hut1ai+8qYX6pVnINx HkbF+lN5W/+H/uvOnuQxplZKKac6QIxAvocV9hGzcn9MCdNgqtED8xHpYk+9wf4G7VMjV5foSdsJw yU9bpYr1KKIX1DZJKJBg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOYn-00059C-ED; Fri, 17 Apr 2020 10:49:25 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOV3-0000n5-UZ for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 10:45:36 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id DCF8FAE0DC5FB7C399EA; Fri, 17 Apr 2020 18:45:26 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Apr 2020 18:45:18 +0800 From: John Garry To: , , , , , , , Subject: [RFC PATCH v2 02/13] perf jevents: Add support for an extra directory level Date: Fri, 17 Apr 2020 18:41:13 +0800 Message-ID: <1587120084-18990-3-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1587120084-18990-1-git-send-email-john.garry@huawei.com> References: <1587120084-18990-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_034534_198693_3FFF0E08 X-CRM114-Status: GOOD ( 12.14 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.32 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: irogers@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, John Garry , qiangqing.zhang@nxp.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Currently we support upto a level 2 directory, and level 2 would be in the form vendor/platform. Add support for a further level, to hold specific categories of events for when we want to segregate them for matching purposes. Signed-off-by: John Garry --- tools/perf/pmu-events/jevents.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index fa86c5f997cc..c7868d0a7a6b 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -981,15 +981,20 @@ static int process_one_file(const char *fpath, const struct stat *sb, int level = ftwbuf->level; int err = 0; - if (level == 2 && is_dir) { + if (level >= 2 && is_dir) { + int count = 0; /* * For level 2 directory, bname will include parent name, * like vendor/platform. So search back from platform dir * to find this. + * Something similar for level 3 directory, but we're a PMU + * category folder, like vendor/platform/cpu. */ bname = (char *) fpath + ftwbuf->base - 2; for (;;) { if (*bname == '/') + count++; + if (count == level - 1) break; bname--; } @@ -1002,13 +1007,13 @@ static int process_one_file(const char *fpath, const struct stat *sb, level, sb->st_size, bname, fpath); /* base dir or too deep */ - if (level == 0 || level > 3) + if (level == 0 || level > 4) return 0; /* model directory, reset topic */ if ((level == 1 && is_dir && is_leaf_dir(fpath)) || - (level == 2 && is_dir)) { + (level >= 2 && is_dir && is_leaf_dir(fpath))) { if (close_table) print_events_table_suffix(eventsfp); From patchwork Fri Apr 17 10:41:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11494739 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B9BD6CA for ; Fri, 17 Apr 2020 10:47:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B979021D91 for ; Fri, 17 Apr 2020 10:47:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="K3WpCXZZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B979021D91 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DiDYfuRVbdzjsgWWwKTPBYGRj6SdulUvRyCdU6wP6kk=; b=K3WpCXZZBZoFoZ lzQFjgN/hm29hlakJQNAmOE+BjHmU65M7XXsA69zT1WJsJCBGcK5vJ8SPQK7N00YezRkP3J4G+TKT NWTnFuco2YMKjmXXBTYTVhAnGQ4Nn+tG8Wm2YXFCpx+6N9AZd3Iwe01XLMdacg5audqiqD2E2xRJR xTnQsUYzXX0SFq8kjzvNfD4Jc5+tiSsgtRuovhmKETpphPxO2wdWU7oWy8l4DwwvdUsP4yKiZnKQs z1ruG3IbKZeAcr1B2/1VPS/LPZMBSkl+4glDI0UxLLzTq2B2xhHfPWuE6Ykjh+BI2EPmyFpFq9G+J Lszy5nCk/jara4tO8SUQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOWf-0002CO-4i; Fri, 17 Apr 2020 10:47:13 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOUz-0000iS-Oq for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 10:45:33 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B943DE884C3B6392A709; Fri, 17 Apr 2020 18:45:26 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Apr 2020 18:45:19 +0800 From: John Garry To: , , , , , , , Subject: [RFC PATCH v2 03/13] perf jevents: Add support for system events tables Date: Fri, 17 Apr 2020 18:41:14 +0800 Message-ID: <1587120084-18990-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1587120084-18990-1-git-send-email-john.garry@huawei.com> References: <1587120084-18990-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_034530_186974_B3E03885 X-CRM114-Status: GOOD ( 19.42 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.32 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: irogers@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, John Garry , qiangqing.zhang@nxp.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Process the JSONs to find support for "system" events, which are not tied to a specific CPUID. We now use a "COMPAT" property to match against the namespace ID from the kernel PMU driver. The generated pmu-events.c will now have 2 tables: a. As before, we will have the event table for CPU events. b. New pmu_sys_event_tables[] table, which will have events matched to SoCs. It will look like this: struct pmu_event pme_hisilicon_hip08_sys[] = { { .name = "cycles", .compat = "HIP08", .event = "event=0", .desc = "Clock cycles", .topic = "smmu v3 pmcg", .long_desc = "Clock cycles", }, { .name = "smmuv3_pmcg.l1_tlb", .compat = "HIP08", .event = "event=0x8a", .desc = "SMMUv3 PMCG l1_tlb. Unit: smmuv3_pmcg ", .topic = "smmu v3 pmcg", .long_desc = "SMMUv3 PMCG l1_tlb", .pmu = "smmuv3_pmcg", }, ... }; struct pmu_event pme_arm_cortex_a53[] = { { .name = "ext_mem_req", .event = "event=0xc0", .desc = "External memory request", .topic = "memory", }, { .name = "ext_mem_req_nc", .event = "event=0xc1", .desc = "Non-cacheable external memory request", .topic = "memory", }, ... }; struct pmu_event pme_hisilicon_hip08_cpu[] = { { .name = "l2d_cache_refill_wr", .event = "event=0x53", .desc = "L2D cache refill, write", .topic = "core imp def", .long_desc = "Attributable Level 2 data cache refill, write", }, ... }; struct pmu_events_map pmu_events_map[] = { { .cpuid = "0x00000000410fd030", .version = "v1", .type = "core", .table = pme_arm_cortex_a53 }, { .cpuid = "0x00000000480fd010", .version = "v1", .type = "core", .table = pme_hisilicon_hip08_cpu }, { .table = 0 }, }; struct pmu_event pme_hisilicon_hip08_cpu[] = { { .name = "uncore_hisi_l3c.rd_cpipe", .event = "event=0", .desc = "Total read accesses. Unit: hisi_sccl,l3c ", .topic = "uncore l3c", .long_desc = "Total read accesses", .pmu = "hisi_sccl,l3c", }, { .name = "uncore_hisi_l3c.wr_cpipe", .event = "event=0x1", .desc = "Total write accesses. Unit: hisi_sccl,l3c ", .topic = "uncore l3c", .long_desc = "Total write accesses", .pmu = "hisi_sccl,l3c", }, ... }; struct pmu_sys_events pmu_sys_event_tables[] = { { .table = pme_hisilicon_hip08_sys, }, ... }; Signed-off-by: John Garry --- tools/perf/pmu-events/jevents.c | 138 ++++++++++++++++++++++++++++--------- tools/perf/pmu-events/jevents.h | 11 ++- tools/perf/pmu-events/pmu-events.h | 6 ++ 3 files changed, 118 insertions(+), 37 deletions(-) diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index c7868d0a7a6b..acb6b77bddc0 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -53,6 +53,23 @@ int verbose; char *prog; +static LIST_HEAD(sys_event_tables); + +struct sys_event_table { + struct list_head list; + char *name; +}; + +static void free_sys_event_tables(void) +{ + struct sys_event_table *et, *next; + + list_for_each_entry_safe(et, next, &sys_event_tables, list) { + free(et->name); + free(et); + } +} + int eprintf(int level, int var, const char *fmt, ...) { @@ -318,12 +335,12 @@ static void print_events_table_prefix(FILE *fp, const char *tblname) close_table = 1; } -static int print_events_table_entry(void *data, char *name, char *event, - char *desc, char *long_desc, +static int print_events_table_entry(void *data, char *name, char *compat, + char *event, char *desc, char *long_desc, char *pmu, char *unit, char *perpkg, - char *metric_expr, - char *metric_name, char *metric_group, - char *deprecated, char *metric_constraint) + char *metric_expr, char *metric_name, + char *metric_group, char *deprecated, + char *metric_constraint) { struct perf_entry_data *pd = data; FILE *outfp = pd->outfp; @@ -337,6 +354,9 @@ static int print_events_table_entry(void *data, char *name, char *event, if (name) fprintf(outfp, "\t.name = \"%s\",\n", name); + if (compat) + fprintf(outfp, "\t.compat = \"%s\",\n", compat); + if (event) fprintf(outfp, "\t.event = \"%s\",\n", event); fprintf(outfp, "\t.desc = \"%s\",\n", desc); @@ -367,6 +387,7 @@ static int print_events_table_entry(void *data, char *name, char *event, struct event_struct { struct list_head list; char *name; + char *compat; char *event; char *desc; char *long_desc; @@ -421,11 +442,12 @@ static void free_arch_std_events(void) } } -static int save_arch_std_events(void *data, char *name, char *event, - char *desc, char *long_desc, char *pmu, - char *unit, char *perpkg, char *metric_expr, - char *metric_name, char *metric_group, - char *deprecated, char *metric_constraint) +static int save_arch_std_events(void *data, char *name, char *compat, + char *event, char *desc, char *long_desc, + char *pmu, char *unit, char *perpkg, + char *metric_expr, char *metric_name, + char *metric_group, char *deprecated, + char *metric_constraint) { struct event_struct *es; @@ -513,12 +535,11 @@ try_fixup(const char *fn, char *arch_std, char **event, char **desc, /* Call func with each event in the json file */ int json_events(const char *fn, - int (*func)(void *data, char *name, char *event, char *desc, - char *long_desc, - char *pmu, char *unit, char *perpkg, - char *metric_expr, - char *metric_name, char *metric_group, - char *deprecated, char *metric_constraint), + int (*func)(void *data, char *name, char *compat, char *event, + char *desc, char *long_desc, char *pmu, char *unit, + char *perpkg, char *metric_expr, char *metric_name, + char *metric_group, char *deprecated, + char *metric_constraint), void *data) { int err; @@ -537,7 +558,7 @@ int json_events(const char *fn, EXPECT(tokens->type == JSMN_ARRAY, tokens, "expected top level array"); tok = tokens + 1; for (i = 0; i < tokens->size; i++) { - char *event = NULL, *desc = NULL, *name = NULL; + char *event = NULL, *desc = NULL, *name = NULL, *compat = NULL; char *long_desc = NULL; char *extra_desc = NULL; char *pmu = NULL; @@ -584,6 +605,8 @@ int json_events(const char *fn, free(code); } else if (json_streq(map, field, "EventName")) { addfield(map, &name, "", "", val); + } else if (json_streq(map, field, "Compat")) { + addfield(map, &compat, "", "", val); } else if (json_streq(map, field, "BriefDescription")) { addfield(map, &desc, "", "", val); fixdesc(desc); @@ -680,13 +703,15 @@ int json_events(const char *fn, if (err) goto free_strings; } - err = func(data, name, real_event(name, event), desc, long_desc, - pmu, unit, perpkg, metric_expr, metric_name, - metric_group, deprecated, metric_constraint); + err = func(data, name, compat, real_event(name, event), desc, + long_desc, pmu, unit, perpkg, metric_expr, + metric_name, metric_group, deprecated, + metric_constraint); free_strings: + free(name); + free(compat); free(event); free(desc); - free(name); free(long_desc); free(extra_desc); free(pmu); @@ -750,6 +775,25 @@ static char *file_name_to_table_name(char *fname) return tblname; } +static bool is_sys_dir(char *fname) +{ + char *pos; + + while (true) { + pos = strchr(fname, '/'); + + if (!pos) { + if (!strcmp(fname, "sys")) + return true; + return false; + } + + fname = pos + 1; + } + + return false; +} + static void print_mapping_table_prefix(FILE *outfp) { fprintf(outfp, "struct pmu_events_map pmu_events_map[] = {\n"); @@ -784,6 +828,23 @@ static void print_mapping_test_table(FILE *outfp) fprintf(outfp, "},\n"); } +static int process_system_event_tables(FILE *outfp) +{ + struct sys_event_table *sys_event_table; + + fprintf(outfp, "struct pmu_sys_events pmu_sys_event_tables[] = {"); + + list_for_each_entry(sys_event_table, &sys_event_tables, list) { + fprintf(outfp, "\n\t{\n\t\t.table = %s,\n\t},", + sys_event_table->name); + } + fprintf(outfp, "\n\t{\n\t\t.table = 0\n\t},"); + + fprintf(outfp, "\n};\n"); + + return 0; +} + static int process_mapfile(FILE *outfp, char *fpath) { int n = 16384; @@ -1029,6 +1090,18 @@ static int process_one_file(const char *fpath, const struct stat *sb, return -1; } + if (is_sys_dir(bname)) { + struct sys_event_table *sys_event_table; + + sys_event_table = malloc(sizeof(*sys_event_table)); + if (!sys_event_table) + return -1; + + sys_event_table->name = strdup(tblname); + list_add_tail(&sys_event_table->list, + &sys_event_tables); + } + print_events_table_prefix(eventsfp, tblname); return 0; } @@ -1180,7 +1253,6 @@ int main(int argc, char *argv[]) } else if (rc < 0) { /* Make build fail */ fclose(eventsfp); - free_arch_std_events(); ret = 1; goto out_free_mapfile; } else if (rc) { @@ -1206,27 +1278,31 @@ int main(int argc, char *argv[]) if (close_table) print_events_table_suffix(eventsfp); - if (!mapfile) { - pr_info("%s: No CPU->JSON mapping?\n", prog); - goto empty_map; + if (mapfile) { + if (process_mapfile(eventsfp, mapfile)) { + pr_err("%s: Error processing mapfile %s\n", prog, + mapfile); + /* Make build fail */ + fclose(eventsfp); + ret = 1; + } + } else { + pr_err("%s: No CPU->JSON mapping?\n", prog); } - if (process_mapfile(eventsfp, mapfile)) { - pr_info("%s: Error processing mapfile %s\n", prog, mapfile); - /* Make build fail */ + if (process_system_event_tables(eventsfp)) { fclose(eventsfp); - free_arch_std_events(); ret = 1; } - goto out_free_mapfile; empty_map: fclose(eventsfp); create_empty_mapping(output_file); - free_arch_std_events(); out_free_mapfile: + free_arch_std_events(); + free_sys_event_tables(); free(mapfile); return ret; } diff --git a/tools/perf/pmu-events/jevents.h b/tools/perf/pmu-events/jevents.h index 2afc8304529e..7e324b210747 100644 --- a/tools/perf/pmu-events/jevents.h +++ b/tools/perf/pmu-events/jevents.h @@ -3,12 +3,11 @@ #define JEVENTS_H 1 int json_events(const char *fn, - int (*func)(void *data, char *name, char *event, char *desc, - char *long_desc, - char *pmu, - char *unit, char *perpkg, char *metric_expr, - char *metric_name, char *metric_group, - char *deprecated, char *metric_constraint), + int (*func)(void *data, char *name, char *compat, char *event, + char *desc, char *long_desc, char *pmu, char *unit, + char *perpkg, char *metric_expr, char *metric_name, + char *metric_group, char *deprecated, + char *metric_constraint), void *data); char *get_cpu_str(void); diff --git a/tools/perf/pmu-events/pmu-events.h b/tools/perf/pmu-events/pmu-events.h index 53e76d5d5b37..cc6de8c5af49 100644 --- a/tools/perf/pmu-events/pmu-events.h +++ b/tools/perf/pmu-events/pmu-events.h @@ -7,6 +7,7 @@ */ struct pmu_event { const char *name; + const char *compat; const char *event; const char *desc; const char *topic; @@ -37,10 +38,15 @@ struct pmu_events_map { struct pmu_event *table; }; +struct pmu_sys_events { + struct pmu_event *table; +}; + /* * Global table mapping each known CPU for the architecture to its * table of PMU events. */ extern struct pmu_events_map pmu_events_map[]; +extern struct pmu_sys_events pmu_sys_event_tables[]; #endif From patchwork Fri Apr 17 10:41:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11494745 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D87D6CA for ; Fri, 17 Apr 2020 10:48:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E862121D91 for ; Fri, 17 Apr 2020 10:48:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="GPoEyh+7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E862121D91 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3gFxQwTkWODSqV9SImT45yQUCRqLfG2dqJ15yYF5MtY=; b=GPoEyh+72yw6Qj 6EmqYiOM/TPEL1ij9QIjL/8eIkfvftpzDermYFU36Br+oo+HMfq+TUGlmkWmouYp4dYJkISEKUaJG IRtGtNNJOT9RC4aianQw3FPOkCdTpROqVpeWp63DvmCp91jVUiaIqF+Q7av6QMcm47hhsTR3MvgKr 7Xgs5F7EAbfjcuhUO7UelkF9f2i3nTo1EMjEfrKXsmFhGHDaKLfbNPC26axQjXzHh9AdbBNEyVu3z PlCraiunT74CxzRQ3vo3U+sYFrSSPwUXn/0vPTecpD7b5V0UxwuPK+ptoTQEfVsEUO9YKAWmtwsxY e5ZTk1B0l1bRDlVPkGQQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOXQ-0002xj-93; Fri, 17 Apr 2020 10:48:00 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOV2-0000ml-Ku for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 10:45:34 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id CC7BD718B77B28E81237; Fri, 17 Apr 2020 18:45:26 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Apr 2020 18:45:19 +0800 From: John Garry To: , , , , , , , Subject: [RFC PATCH v2 04/13] perf vendor events arm64: Relocate hip08 events Date: Fri, 17 Apr 2020 18:41:15 +0800 Message-ID: <1587120084-18990-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1587120084-18990-1-git-send-email-john.garry@huawei.com> References: <1587120084-18990-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_034532_876497_EC35C3AC X-CRM114-Status: UNSURE ( 7.64 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.32 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: irogers@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, John Garry , qiangqing.zhang@nxp.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Relocate the core events JSONs to match to future structure, which will have separate folders for CPU and system events. Signed-off-by: John Garry --- .../pmu-events/arch/arm64/hisilicon/hip08/{ => cpu}/core-imp-def.json | 0 .../pmu-events/arch/arm64/hisilicon/hip08/{ => cpu}/uncore-ddrc.json | 0 .../pmu-events/arch/arm64/hisilicon/hip08/{ => cpu}/uncore-hha.json | 0 .../pmu-events/arch/arm64/hisilicon/hip08/{ => cpu}/uncore-l3c.json | 0 tools/perf/pmu-events/arch/arm64/mapfile.csv | 2 +- 5 files changed, 1 insertion(+), 1 deletion(-) rename tools/perf/pmu-events/arch/arm64/hisilicon/hip08/{ => cpu}/core-imp-def.json (100%) rename tools/perf/pmu-events/arch/arm64/hisilicon/hip08/{ => cpu}/uncore-ddrc.json (100%) rename tools/perf/pmu-events/arch/arm64/hisilicon/hip08/{ => cpu}/uncore-hha.json (100%) rename tools/perf/pmu-events/arch/arm64/hisilicon/hip08/{ => cpu}/uncore-l3c.json (100%) diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/core-imp-def.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/cpu/core-imp-def.json similarity index 100% rename from tools/perf/pmu-events/arch/arm64/hisilicon/hip08/core-imp-def.json rename to tools/perf/pmu-events/arch/arm64/hisilicon/hip08/cpu/core-imp-def.json diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-ddrc.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/cpu/uncore-ddrc.json similarity index 100% rename from tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-ddrc.json rename to tools/perf/pmu-events/arch/arm64/hisilicon/hip08/cpu/uncore-ddrc.json diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-hha.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/cpu/uncore-hha.json similarity index 100% rename from tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-hha.json rename to tools/perf/pmu-events/arch/arm64/hisilicon/hip08/cpu/uncore-hha.json diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-l3c.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/cpu/uncore-l3c.json similarity index 100% rename from tools/perf/pmu-events/arch/arm64/hisilicon/hip08/uncore-l3c.json rename to tools/perf/pmu-events/arch/arm64/hisilicon/hip08/cpu/uncore-l3c.json diff --git a/tools/perf/pmu-events/arch/arm64/mapfile.csv b/tools/perf/pmu-events/arch/arm64/mapfile.csv index 0d609149b82a..c92cb3b519fc 100644 --- a/tools/perf/pmu-events/arch/arm64/mapfile.csv +++ b/tools/perf/pmu-events/arch/arm64/mapfile.csv @@ -20,5 +20,5 @@ 0x00000000410fd0c0,v1,arm/cortex-a76-n1,core 0x00000000420f5160,v1,cavium/thunderx2,core 0x00000000430f0af0,v1,cavium/thunderx2,core -0x00000000480fd010,v1,hisilicon/hip08,core +0x00000000480fd010,v1,hisilicon/hip08/cpu,core 0x00000000500f0000,v1,ampere/emag,core From patchwork Fri Apr 17 10:41:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11494731 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F36616CA for ; Fri, 17 Apr 2020 10:46:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 AB27D221EC for ; Fri, 17 Apr 2020 10:46:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hsX9Sduh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB27D221EC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=avw+zkCsKydxVgF/QDVBjQ8CpQhBWBT7XJ6lueYII5U=; b=hsX9SduhS9Hzs7 zu5dAs39Egk7huH2pUd8rlHjUSgW6I7Xk59AtV7DMUzAA/epBvYiWfC+QFfVXsCdFuur7SeofUR3c G5fzGfPO3ZZb4ErsXHrz++5VXtITmjQzTCIwLnmc5tsfohP3AJNV8MX8uJUknb9qL+DYhRurkLUiZ CUjIyJgHLs9amZRfR+TsmLsXcpGljvvQ942DT/ziRT/8RmuIn0RyCqqwkg2liApx5NeHoylhQmHOc p8ZEWefGDd1mDpkaXZzCyGPTJQWQ+2e+D7sJBSFqXmHVUO93bB4+7TPgYaOECyVwqinrFofjkjeqD E2pNvyLFUQkYtxzre49Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOVP-00018I-KN; Fri, 17 Apr 2020 10:45:55 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOUz-0000hj-AT for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 10:45:31 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B04BA5E66BAE7093905A; Fri, 17 Apr 2020 18:45:26 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Apr 2020 18:45:19 +0800 From: John Garry To: , , , , , , , Subject: [RFC PATCH v2 05/13] perf vendor events arm64: Add Architected events smmuv3-pmcg.json Date: Fri, 17 Apr 2020 18:41:16 +0800 Message-ID: <1587120084-18990-6-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1587120084-18990-1-git-send-email-john.garry@huawei.com> References: <1587120084-18990-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_034529_525100_25FCB2AC X-CRM114-Status: GOOD ( 11.21 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.32 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: irogers@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, John Garry , qiangqing.zhang@nxp.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add JSON for Architected events from [0], Section 10.3 . [0] https://static.docs.arm.com/ihi0070/a/IHI_0070A_SMMUv3.pdf Signed-off-by: John Garry --- tools/perf/pmu-events/arch/arm64/smmuv3-pmcg.json | 58 +++++++++++++++++++++++ tools/perf/pmu-events/jevents.c | 2 + 2 files changed, 60 insertions(+) create mode 100644 tools/perf/pmu-events/arch/arm64/smmuv3-pmcg.json diff --git a/tools/perf/pmu-events/arch/arm64/smmuv3-pmcg.json b/tools/perf/pmu-events/arch/arm64/smmuv3-pmcg.json new file mode 100644 index 000000000000..7ceb2b4372fa --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/smmuv3-pmcg.json @@ -0,0 +1,58 @@ +[ + { + "PublicDescription": "Clock cycles", + "EventCode": "0x00", + "EventName": "smmuv3_pmcg.CYCLES", + "BriefDescription": "Clock cycles" + "Unit": "smmuv3_pmcg", + }, + { + "PublicDescription": "Transaction", + "EventCode": "0x01", + "EventName": "smmuv3_pmcg.TRANSACTION", + "BriefDescription": "Transaction" + "Unit": "smmuv3_pmcg", + }, + { + "PublicDescription": "TLB miss caused by incomingtransaction or (ATS or non-ATS) translation request", + "EventCode": "0x02", + "EventName": "smmuv3_pmcg.TLB_MISS", + "BriefDescription": "TLB miss caused by incomingtransaction or (ATS or non-ATS) translation request" + "Unit": "smmuv3_pmcg", + }, + { + "PublicDescription": "Configuration cache miss caused by transaction or(ATS or non-ATS)translation request", + "EventCode": "0x03", + "EventName": "smmuv3_pmcg.CONFIG_CACHE_MISS", + "BriefDescription": "Configuration cache miss caused by transaction or(ATS or non-ATS)translation request" + "Unit": "smmuv3_pmcg", + }, + { + "PublicDescription": "Translation table walk access", + "EventCode": "0x04", + "EventName": "smmuv3_pmcg.TRANS_TABLE_WALK_ACCESS", + "BriefDescription": "Translation table walk access" + "Unit": "smmuv3_pmcg", + }, + { + "PublicDescription": "Configuration structure access", + "EventCode": "0x05", + "EventName": "smmuv3_pmcg.CONFIG_STRUCT_ACCESS", + "BriefDescription": "Configuration structure access" + "Unit": "smmuv3_pmcg", + }, + { + "PublicDescription": "PCIe ATS Translation Request received", + "EventCode": "0x06", + "EventName": "smmuv3_pmcg.PCIE_ATS_TRANS_RQ", + "BriefDescription": "PCIe ATS Translation Request received" + "Unit": "smmuv3_pmcg", + }, + { + "PublicDescription": "PCIe ATS Translated Transaction passed through SMMU", + "EventCode": "0x07", + "EventName": "smmuv3_pmcg.PCIE_ATS_TRANS_PASSED", + "BriefDescription": "PCIe ATS Translated Transaction passed through SMMU" + "Unit": "smmuv3_pmcg", + } +] diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index acb6b77bddc0..76a84ec2ffc8 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -256,6 +256,8 @@ static struct map { { "hisi_sccl,ddrc", "hisi_sccl,ddrc" }, { "hisi_sccl,hha", "hisi_sccl,hha" }, { "hisi_sccl,l3c", "hisi_sccl,l3c" }, + /* it's not realistic to keep adding these, we need something more scalable ... */ + { "smmuv3_pmcg", "smmuv3_pmcg" }, { "L3PMC", "amd_l3" }, {} }; From patchwork Fri Apr 17 10:41:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11494735 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0440B6CA for ; Fri, 17 Apr 2020 10:46:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D16D9221F7 for ; Fri, 17 Apr 2020 10:46:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="h1lcXBvL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D16D9221F7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QwTMXHCp9Ao2/sk/Z1A5wByJSvPujPBj2oMTwD01++g=; b=h1lcXBvLJcNr/I ALf6b19rtRxVIOGutoY0+WgEE1Lj65nAY2DEwe0OjIsBa43oDna6W6lO4WwUNaheFh5xbXblpDtYN CbF8RA+9K4ARtcX+6Ot1fWkfowWLbJTYx2n/DJfPb1noHb7WUDbeJwM1IDiEbGHwqUEJw7uvQndvr /mtHgP+Ay8diki6ReU3Q+aqAG+b4gM7fBoT7Cm8tlc2TsHMrBGB7JAZ+6rhYXve6YORGi6smLO02m QpSieOINL0/+BkFvtCw2uBcX2SpviUAxtzH0ZKlpt27POuB2TcEGcPxVgSXdLYKBg13Qaj6KWrLfd hYm7XTJrInYoG0ni0wtQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOWD-0001lE-12; Fri, 17 Apr 2020 10:46:45 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOUz-0000fi-9d for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 10:45:32 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 8DCDC2D37064B8C8AEBB; Fri, 17 Apr 2020 18:45:26 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Apr 2020 18:45:20 +0800 From: John Garry To: , , , , , , , Subject: [RFC PATCH v2 06/13] perf vendor events arm64: Add hip08 SMMUv3 PMCG events Date: Fri, 17 Apr 2020 18:41:17 +0800 Message-ID: <1587120084-18990-7-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1587120084-18990-1-git-send-email-john.garry@huawei.com> References: <1587120084-18990-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_034529_546619_FA8B8B59 X-CRM114-Status: UNSURE ( 9.00 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.32 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: irogers@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, John Garry , qiangqing.zhang@nxp.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add the SMMUv3 PMCG (Performance Monitor Event Group) events for hip08 platform. This contains a mix of architected and IMP def events Signed-off-by: John Garry --- .../arm64/hisilicon/hip08/sys/smmu-v3-pmcg.json | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tools/perf/pmu-events/arch/arm64/hisilicon/hip08/sys/smmu-v3-pmcg.json diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/sys/smmu-v3-pmcg.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/sys/smmu-v3-pmcg.json new file mode 100644 index 000000000000..f2a1cb0332a6 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/sys/smmu-v3-pmcg.json @@ -0,0 +1,42 @@ +[ + { + "ArchStdEvent": "smmuv3_pmcg.CYCLES" + "Compat": "hip08" + }, + { + "ArchStdEvent": "smmuv3_pmcg.TRANSACTION" + "Compat": "hip08" + }, + { + "ArchStdEvent": "smmuv3_pmcg.TLB_MISS" + "Compat": "hip08" + }, + { + "ArchStdEvent": "smmuv3_pmcg.CONFIG_CACHE_MISS" + "Compat": "hip08" + }, + { + "ArchStdEvent": "smmuv3_pmcg.TRANS_TABLE_WALK_ACCESS" + "Compat": "hip08" + }, + { + "ArchStdEvent": "smmuv3_pmcg.CONFIG_STRUCT_ACCESS" + "Compat": "hip08" + }, + { + "ArchStdEvent": "smmuv3_pmcg.PCIE_ATS_TRANS_RQ" + "Compat": "hip08" + }, + { + "ArchStdEvent": "smmuv3_pmcg.PCIE_ATS_TRANS_PASSED" + "Compat": "hip08" + }, + { + "EventCode": "0x8a", + "EventName": "smmuv3_pmcg.L1_TLB", + "BriefDescription": "SMMUv3 PMCG L1 TABLE transation", + "PublicDescription": "SMMUv3 PMCG L1 TABLE transation", + "Unit": "smmuv3_pmcg", + "Compat": "hip08" + }, +] From patchwork Fri Apr 17 10:41:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11494747 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3AD96CA for ; Fri, 17 Apr 2020 10:48:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 6872F221EC for ; Fri, 17 Apr 2020 10:48:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="F51ygZz5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6872F221EC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WTsgHUNM2gy1fO912LnlJmUg3D8OkzjpD+DKnSoKISk=; b=F51ygZz5VFUoMi IycpXhBNwTNZA9RMC8DBJyY5ddz5KY673be5Ga9kYKp1ARo5v5X8e+VOj0odvLnoBJsQfau78GBmV X51r12H/653huJqtqna7jzoPqAuAfJ8NcQaFKeGrxlYG0/SUaAPKhMaIzS3EzlzNtaZSwG5Cn89BG 6KWMYhQcu3CLiON0trp1eSzUQUJJtdJirJdVRS0KHiH+XMb1VGRu/9rAPoYdSKzjYa39TKwxICJja B33J7aZ4htBZMdmOoyfvYwLlO1aRgtbu3kCjGa6FRYHfKEr4VDI5qiu240FPJo34eL+tNeK6jgzUT Ijg6sfWNjHc0WFBS7HGw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOXh-0003DP-O7; Fri, 17 Apr 2020 10:48:17 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOV3-0000n3-EA for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 10:45:35 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D4E62AB3D0B362BDEA7C; Fri, 17 Apr 2020 18:45:26 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Apr 2020 18:45:20 +0800 From: John Garry To: , , , , , , , Subject: [RFC PATCH v2 07/13] perf pmu: Add pmu_id() Date: Fri, 17 Apr 2020 18:41:18 +0800 Message-ID: <1587120084-18990-8-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1587120084-18990-1-git-send-email-john.garry@huawei.com> References: <1587120084-18990-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_034533_700340_4D90B333 X-CRM114-Status: GOOD ( 11.02 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.32 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: irogers@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, John Garry , qiangqing.zhang@nxp.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add a function to read the PMU id sysfs entry. We only do it for uncore PMUs where this would be relevant. Signed-off-by: John Garry --- tools/perf/util/pmu.c | 36 ++++++++++++++++++++++++++++++++++++ tools/perf/util/pmu.h | 1 + 2 files changed, 37 insertions(+) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index ef6a63f3d386..6a67c6a28d08 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -594,6 +594,7 @@ static struct perf_cpu_map *__pmu_cpumask(const char *path) * Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64) * may have a "cpus" file. */ +#define CPUS_TEMPLATE_ID "%s/bus/event_source/devices/%s/identifier" #define CPUS_TEMPLATE_UNCORE "%s/bus/event_source/devices/%s/cpumask" #define CPUS_TEMPLATE_CPU "%s/bus/event_source/devices/%s/cpus" @@ -632,6 +633,39 @@ static bool pmu_is_uncore(const char *name) return file_available(path); } +static char *pmu_id(const char *name) +{ + char path[PATH_MAX], *id; + const char *sysfs; + FILE *file; + int n; + + sysfs = sysfs__mountpoint(); + snprintf(path, PATH_MAX, CPUS_TEMPLATE_ID, sysfs, name); + + id = malloc(PATH_MAX); + if (!id) + return NULL; + + file = fopen(path, "r"); + if (!file) { + free(id); + return NULL; + } + + n = fscanf(file, "%s", id); + + fclose(file); + + if (!n) { + free(id); + return NULL; + } + + return id; +} + + /* * PMU CORE devices have different name other than cpu in sysfs on some * platforms. @@ -844,6 +878,8 @@ static struct perf_pmu *pmu_lookup(const char *name) pmu->name = strdup(name); pmu->type = type; pmu->is_uncore = pmu_is_uncore(name); + if (pmu->is_uncore) + pmu->id = pmu_id(name); pmu->max_precise = pmu_max_precise(name); pmu_add_cpu_aliases(&aliases, pmu); diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 5fb3f16828df..62ebca9481fe 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -24,6 +24,7 @@ struct perf_event_attr; struct perf_pmu { char *name; + char *id; __u32 type; bool selectable; bool is_uncore; From patchwork Fri Apr 17 10:41:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11494729 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CEE3D6CA for ; Fri, 17 Apr 2020 10:45:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 AC15B221EC for ; Fri, 17 Apr 2020 10:45:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Kg72kvM/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC15B221EC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8FYMHhRiovXrSYfl3/TtMHmd6b/k0OVJ4XeJ7lSONog=; b=Kg72kvM/m87biQ /Suvf5EOXP6Mfx8kbhL2uIJdn0t9Xw6fWOq29NCD/VNhOdOpdwJ93imSCoVX+vutNtEEq4YQ72Wsq vPei/BY2XKHP9aEB3MmtXwif4AIPulP8PhJFPZpa0rQV25ffZZEt3L595gqGKY28gVjoHgxYFG6eG CJW04KghYddmKXSteEjyRMLwGGjLOX2HNvnbTg4dsIiGH6JTAy2R2ffZ1lr/20GLCZfCq4sfUvLhk 2ingovxCwsl0Kx5DZQH7WLkkrkzwCc3cPYeOqmCdGRXOYZhgpMLcUnjNFoMZg2prSl+C5sUN8ii5i 0Z1B1mlmPtC0tCj6Zqww==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOV5-0000oR-5n; Fri, 17 Apr 2020 10:45:35 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOUy-0000fx-JS for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 10:45:30 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 99262AD9048FCD38B932; Fri, 17 Apr 2020 18:45:26 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Apr 2020 18:45:20 +0800 From: John Garry To: , , , , , , , Subject: [RFC PATCH v2 08/13] perf pmu: Add pmu_add_sys_aliases() Date: Fri, 17 Apr 2020 18:41:19 +0800 Message-ID: <1587120084-18990-9-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1587120084-18990-1-git-send-email-john.garry@huawei.com> References: <1587120084-18990-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_034529_223344_257787AC X-CRM114-Status: GOOD ( 10.42 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.32 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: irogers@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, John Garry , qiangqing.zhang@nxp.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add pmu_add_sys_aliases() to add system PMU events aliases. For adding system PMU events, we iterate through all the events per SoC event table in pmu_sys_event_tables[]. Matches must satisfy both: - PMU identifier matches event "compat" value - like uncore event matching, the event "Unit" member must match; this match under return value of pmu_uncore_alias_match() (maybe rename that function?) Signed-off-by: John Garry --- tools/perf/util/pmu.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/pmu.h | 5 ++++ 2 files changed, 84 insertions(+) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 6a67c6a28d08..2f38465e8a73 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -827,6 +827,84 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu) pmu_add_cpu_aliases_map(head, pmu, map); } +void pmu_for_each_sys_event(struct perf_pmu *pmu, pmu_sys_event_iter_fn fn, + void *data) +{ + struct pmu_event *pe; + int i = 0; + + if (!pmu->id) + return; + + while (1) { + struct pmu_sys_events *event_table; + int j = 0; + + event_table = &pmu_sys_event_tables[i++]; + + if (!event_table->table) + break; + + while (1) { + int ret; + + pe = &event_table->table[j++]; + + if (!pe->name && !pe->metric_group && !pe->metric_name) + break; + + ret = fn(pmu, pe, data); + if (ret) + break; + } + } +} + +struct pmu_sys_event_iter_data { + struct list_head *head; +}; + +static int pmu_add_sys_aliases_iter_fn(struct perf_pmu *pmu, + struct pmu_event *pe, void *data) +{ + struct pmu_sys_event_iter_data *idata = data; + + if (!pe->name) { + if (pe->metric_group || pe->metric_name) + return 0; + return -EINVAL; + } + + if (!pe->compat || !pe->pmu) + return 0; + + if (!strcmp(pmu->id, pe->compat) && + pmu_uncore_alias_match(pe->pmu, pmu->name)) { + __perf_pmu__new_alias(idata->head, NULL, + (char *)pe->name, + (char *)pe->desc, + (char *)pe->event, + (char *)pe->long_desc, + (char *)pe->topic, + (char *)pe->unit, + (char *)pe->perpkg, + (char *)pe->metric_expr, + (char *)pe->metric_name, + (char *)pe->deprecated); + } + + return 0; +} + +static void pmu_add_sys_aliases(struct list_head *head, struct perf_pmu *pmu) +{ + struct pmu_sys_event_iter_data idata = { + .head = head, + }; + + pmu_for_each_sys_event(pmu, pmu_add_sys_aliases_iter_fn, &idata); +} + struct perf_event_attr * __weak perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused) { @@ -882,6 +960,7 @@ static struct perf_pmu *pmu_lookup(const char *name) pmu->id = pmu_id(name); pmu->max_precise = pmu_max_precise(name); pmu_add_cpu_aliases(&aliases, pmu); + pmu_add_sys_aliases(&aliases, pmu); INIT_LIST_HEAD(&pmu->format); INIT_LIST_HEAD(&pmu->aliases); diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 62ebca9481fe..e4bc9d192236 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -106,6 +106,11 @@ void pmu_add_cpu_aliases_map(struct list_head *head, struct perf_pmu *pmu, struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu); bool pmu_uncore_alias_match(const char *pmu_name, const char *name); +typedef int (*pmu_sys_event_iter_fn)(struct perf_pmu *, struct pmu_event *pe, + void *data); + +void pmu_for_each_sys_event(struct perf_pmu *pmu, pmu_sys_event_iter_fn fn, + void *data); int perf_pmu__convert_scale(const char *scale, char **end, double *sval); #endif /* __PMU_H */ From patchwork Fri Apr 17 10:41:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11494749 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A69FE6CA for ; Fri, 17 Apr 2020 10:48:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 7BEB721D91 for ; Fri, 17 Apr 2020 10:48:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="EI4sNCVy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7BEB721D91 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iAJHbwyWiIxGaI+QxM7GFbF/Q9++M7yZf1sqi+3jkos=; b=EI4sNCVyitztoB Xx6GR87FVMo86i3ne9VU4MGlOx0pE0m9BNkNunt9uYPo57eOiG1XVSWD2T1lzPb0PSuicDJJpS6P5 zs/mUkVF4XMjrWrdq4a0b6lAF1Xr3dM+7PNAwzA/V9IptrvGzhQ/s9TdLdhxLFBIQjWc1V4/UwzYm WweQJCrywOUMwEPUKobTFJHH435EgVr8jwBronNuBlKwsDUpYTfHQsbUX6JNjaWIyuNIsef9PJJnQ UKjUUcbYvdKynH98dwMM30+n3EtisNC7ncvim9XR9Gw+kV0nnPvF7tmSEe5NAfDeDjMfJlmyeJRxl pYJwcevZpL6ENuO5Mvew==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOYB-00045H-8v; Fri, 17 Apr 2020 10:48:47 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOV5-0000oU-78 for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 10:45:38 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 99D9CE0BDA7C0A56020B; Fri, 17 Apr 2020 18:45:31 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Apr 2020 18:45:21 +0800 From: John Garry To: , , , , , , , Subject: [RFC PATCH v2 09/13] perf vendor events: Add JSON metrics for imx8mm DDR Perf Date: Fri, 17 Apr 2020 18:41:20 +0800 Message-ID: <1587120084-18990-10-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1587120084-18990-1-git-send-email-john.garry@huawei.com> References: <1587120084-18990-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_034535_873109_B189B2E3 X-CRM114-Status: GOOD ( 12.26 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.35 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: irogers@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, John Garry , qiangqing.zhang@nxp.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Joakim Zhang Add JSON metrics for imx8mm DDR Perf. Signed-off-by: Joakim Zhang Signed-off-by: John Garry --- .../arch/arm64/freescale/imx8mm/sys/ddrc.json | 39 ++++++++++++++++++++++ .../arch/arm64/freescale/imx8mm/sys/metrics.json | 18 ++++++++++ tools/perf/pmu-events/jevents.c | 1 + 3 files changed, 58 insertions(+) create mode 100644 tools/perf/pmu-events/arch/arm64/freescale/imx8mm/sys/ddrc.json create mode 100644 tools/perf/pmu-events/arch/arm64/freescale/imx8mm/sys/metrics.json diff --git a/tools/perf/pmu-events/arch/arm64/freescale/imx8mm/sys/ddrc.json b/tools/perf/pmu-events/arch/arm64/freescale/imx8mm/sys/ddrc.json new file mode 100644 index 000000000000..8a3dae61a48f --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/freescale/imx8mm/sys/ddrc.json @@ -0,0 +1,39 @@ +[ + { + "BriefDescription": "ddr cycles event", + "EventCode": "0x00", + "EventName": "imx8_ddr.cycles", + "Unit": "imx8_ddr", + "Compat": "i.mx8mm" + }, + { + "BriefDescription": "ddr read-cycles event", + "EventCode": "0x2a", + "EventName": "imx8_ddr.read_cycles", + "Unit": "imx8_ddr", + "Compat": "i.mx8mm" + }, + { + "BriefDescription": "ddr write-cycles event", + "EventCode": "0x2b", + "EventName": "imx8_ddr.write_cycles", + "Unit": "imx8_ddr", + "Compat": "i.mx8mm" + }, + { + "BriefDescription": "ddr read event", + "EventCode": "0x35", + "EventName": "imx8_ddr.read", + "Unit": "imx8_ddr", + "Compat": "i.mx8mm" + }, + { + "BriefDescription": "ddr write event", + "EventCode": "0x38", + "EventName": "imx8_ddr.write", + "Unit": "imx8_ddr", + "Compat": "i.mx8mm" + } +] + + diff --git a/tools/perf/pmu-events/arch/arm64/freescale/imx8mm/sys/metrics.json b/tools/perf/pmu-events/arch/arm64/freescale/imx8mm/sys/metrics.json new file mode 100644 index 000000000000..b6a776ca7cc2 --- /dev/null +++ b/tools/perf/pmu-events/arch/arm64/freescale/imx8mm/sys/metrics.json @@ -0,0 +1,18 @@ +[ + { + "BriefDescription": "bytes all masters read from ddr based on read-cycles event", + "MetricName": "imx8mm_ddr_read.all", + "MetricExpr": "imx8_ddr.read_cycles * 4 * 4", + "ScaleUnit": "9.765625e-4MB", + "Unit": "imx8_ddr", + "Compat": "i.mx8mm" + }, + { + "BriefDescription": "bytes all masters write to ddr based on write-cycles event", + "MetricName": "imx8mm_ddr_write.all", + "MetricExpr": "imx8_ddr.write_cycles * 4 * 4", + "ScaleUnit": "9.765625e-4MB", + "Unit": "imx8_ddr", + "Compat": "i.mx8mm" + } +] \ No newline at end of file diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c index 76a84ec2ffc8..efdade0194af 100644 --- a/tools/perf/pmu-events/jevents.c +++ b/tools/perf/pmu-events/jevents.c @@ -257,6 +257,7 @@ static struct map { { "hisi_sccl,hha", "hisi_sccl,hha" }, { "hisi_sccl,l3c", "hisi_sccl,l3c" }, /* it's not realistic to keep adding these, we need something more scalable ... */ + { "imx8_ddr", "imx8_ddr" }, { "smmuv3_pmcg", "smmuv3_pmcg" }, { "L3PMC", "amd_l3" }, {} From patchwork Fri Apr 17 10:41:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11494743 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 735FD6CA for ; Fri, 17 Apr 2020 10:47:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 A2C1621D91 for ; Fri, 17 Apr 2020 10:47:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="b0r+tbwA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2C1621D91 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=E34z4plsa3BSYPY+6/8nedcFtMRzRbsHRLepQdVuf+Q=; b=b0r+tbwAQXN7LO XRODyfD4tL7hNLcEdwo+KDPa6RxKMDKESUf5lbUuKQ0tQhrg22O8LGL/x0atxBAE4mD03x2EW4SRi LN09oDoySuECsT05v7MOW7hdT3S94L/WNgoP7RheYRDzl6AmwTZD+HuECSHKBMUlQwquNvxcs0XmC hH/9BYdhVelYnjij+yyHDAocIwchN2tMQbtrkNXQOd+HL/oaGlKOgb7283kC29hcaBJogzZnZTeqT Fg8qMqywTm5nmV8yXu1KZe8WvJGrxuU2CzEERF0QC54NQwIMhb/b+maS7uLRhJID/gjVU/FhEQ5QC +YW7pRFSyf81h2QHW99g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOX5-0002g2-DV; Fri, 17 Apr 2020 10:47:39 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOV5-0000oV-GA for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 10:45:38 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A3ACF16856F9D903B27A; Fri, 17 Apr 2020 18:45:31 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Apr 2020 18:45:21 +0800 From: John Garry To: , , , , , , , Subject: [RFC PATCH v2 10/13] perf metricgroup: Split up metricgroup__add_metric() Date: Fri, 17 Apr 2020 18:41:21 +0800 Message-ID: <1587120084-18990-11-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1587120084-18990-1-git-send-email-john.garry@huawei.com> References: <1587120084-18990-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_034535_789867_EA8BFA05 X-CRM114-Status: GOOD ( 12.46 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.35 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: irogers@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, John Garry , qiangqing.zhang@nxp.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org To aid supporting system event metric groups, break up the function metricgroup__add_metric() into a part which iterates metrics and a part which actually "adds" the metric. No functional change intended. Signed-off-by: John Garry --- tools/perf/util/metricgroup.c | 75 ++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 926449a7cdbf..d1033756a1bc 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -231,6 +231,12 @@ static bool match_metric(const char *n, const char *list) return false; } +static bool match_pe_metric(struct pmu_event *pe, const char *metric) +{ + return match_metric(pe->metric_group, metric) || + match_metric(pe->metric_name, metric); +} + struct mep { struct rb_node nd; const char *name; @@ -485,6 +491,40 @@ static bool metricgroup__has_constraint(struct pmu_event *pe) return false; } +static int metricgroup__add_metric_pmu_event(struct pmu_event *pe, + struct strbuf *events, + struct list_head *group_list) +{ + const char **ids; + int idnum; + struct egroup *eg; + + pr_debug("metric expr %s for %s\n", pe->metric_expr, pe->metric_name); + + if (expr__find_other(pe->metric_expr, NULL, &ids, &idnum) < 0) + return 0; + + if (events->len > 0) + strbuf_addf(events, ","); + + if (metricgroup__has_constraint(pe)) + metricgroup__add_metric_non_group(events, ids, idnum); + else + metricgroup__add_metric_weak_group(events, ids, idnum); + + eg = malloc(sizeof(*eg)); + if (!eg) + return -ENOMEM; + eg->ids = ids; + eg->idnum = idnum; + eg->metric_name = pe->metric_name; + eg->metric_expr = pe->metric_expr; + eg->metric_unit = pe->unit; + list_add_tail(&eg->nd, group_list); + + return 0; +} + static int metricgroup__add_metric(const char *metric, struct strbuf *events, struct list_head *group_list) { @@ -502,37 +542,12 @@ static int metricgroup__add_metric(const char *metric, struct strbuf *events, break; if (!pe->metric_expr) continue; - if (match_metric(pe->metric_group, metric) || - match_metric(pe->metric_name, metric)) { - const char **ids; - int idnum; - struct egroup *eg; - - pr_debug("metric expr %s for %s\n", pe->metric_expr, pe->metric_name); - if (expr__find_other(pe->metric_expr, - NULL, &ids, &idnum) < 0) - continue; - if (events->len > 0) - strbuf_addf(events, ","); - - if (metricgroup__has_constraint(pe)) - metricgroup__add_metric_non_group(events, ids, idnum); - else - metricgroup__add_metric_weak_group(events, ids, idnum); - - eg = malloc(sizeof(struct egroup)); - if (!eg) { - ret = -ENOMEM; - break; - } - eg->ids = ids; - eg->idnum = idnum; - eg->metric_name = pe->metric_name; - eg->metric_expr = pe->metric_expr; - eg->metric_unit = pe->unit; - list_add_tail(&eg->nd, group_list); - ret = 0; + if (match_pe_metric(pe, metric)) { + ret = metricgroup__add_metric_pmu_event(pe, events, + group_list); + if (ret) + return ret; } } return ret; From patchwork Fri Apr 17 10:41:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11494737 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDA3B6CA for ; Fri, 17 Apr 2020 10:47:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 A5CD221D91 for ; Fri, 17 Apr 2020 10:47:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="g5VFQtIF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5CD221D91 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=He+uxtilB9hOvddWndlzpr03kbjIfZBEWBSo2bjAAWc=; b=g5VFQtIFTQMQSH i+65bpQ+IXjFKZiNdCbtbNN3vb30xz135S2GUo/ENnK7KD2fSalJeT+AsWM1z/rmsVSWbn0oqL/D+ yrW305y5AV3EYZKU/dr+r5T9tkI9L2Nr5MNYUGq7Y5w3I4uCrwy0vCoDyMu/2irbChqNpxrpkDYIM MRIOQ/PCtzuVOvHv7K5+5viF2ehSvfg9/JjTAiP7V1rV4D3c96rO9jm/95Z84IQYPzAqkVMntxMA1 ye5XS4PHDSDKMMfO70Fp1awAl82+sKqDnSgzpprkhTNfoM8Ew4CXrT7DWO4XKA1P2B/bxlJCvBjNz 80gOqkSG5ytmXOYOFOnA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOWU-00020Q-VA; Fri, 17 Apr 2020 10:47:02 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOV5-0000oS-7l for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 10:45:38 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id CA8E422B716E232EB4CD; Fri, 17 Apr 2020 18:45:31 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Apr 2020 18:45:21 +0800 From: John Garry To: , , , , , , , Subject: [RFC PATCH v2 11/13] perf metricgroup: Split up metricgroup__print() Date: Fri, 17 Apr 2020 18:41:22 +0800 Message-ID: <1587120084-18990-12-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1587120084-18990-1-git-send-email-john.garry@huawei.com> References: <1587120084-18990-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_034535_528302_3B1A18C7 X-CRM114-Status: GOOD ( 12.00 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.35 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: irogers@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, John Garry , qiangqing.zhang@nxp.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org To aid supporting system event metric groups, break up the function metricgroup__print() into a part which iterates metrics and a part which actually "prints" the metric. No functional change intended. Signed-off-by: John Garry --- tools/perf/util/metricgroup.c | 117 ++++++++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 51 deletions(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index d1033756a1bc..31e97e24c2b0 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -315,6 +315,68 @@ static void metricgroup__print_strlist(struct strlist *metrics, bool raw) putchar('\n'); } + +static void metricgroup__print_pmu_event(struct pmu_event *pe, + bool metricgroups, char *filter, + bool raw, bool details, + struct rblist *groups, + struct strlist *metriclist) +{ + const char *g; + + g = pe->metric_group; + if (!g && pe->metric_name) { + if (pe->name) + return; + g = "No_group"; + } + + if (g) { + char *omg; + char *mg = strdup(g); + + if (!mg) + return; + omg = mg; + while ((g = strsep(&mg, ";")) != NULL) { + struct mep *me; + char *s; + + g = skip_spaces(g); + if (*g == 0) + g = "No_group"; + if (filter && !strstr(g, filter)) + continue; + if (raw) + s = (char *)pe->metric_name; + else { + if (asprintf(&s, "%s\n%*s%s]", pe->metric_name, + 8, "[", pe->desc) < 0) + return; + + if (details) { + if (asprintf(&s, "%s\n%*s%s]", s, 8, + "[", pe->metric_expr) < 0) + return; + } + } + + if (!s) + continue; + + if (!metricgroups) { + strlist__add(metriclist, s); + } else { + me = mep_lookup(groups, g); + if (!me) + continue; + strlist__add(me->metrics, s); + } + } + free(omg); + } +} + void metricgroup__print(bool metrics, bool metricgroups, char *filter, bool raw, bool details) { @@ -339,63 +401,15 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter, groups.node_cmp = mep_cmp; groups.node_delete = mep_delete; for (i = 0; ; i++) { - const char *g; pe = &map->table[i]; if (!pe->name && !pe->metric_group && !pe->metric_name) break; if (!pe->metric_expr) continue; - g = pe->metric_group; - if (!g && pe->metric_name) { - if (pe->name) - continue; - g = "No_group"; - } - if (g) { - char *omg; - char *mg = strdup(g); - - if (!mg) - return; - omg = mg; - while ((g = strsep(&mg, ";")) != NULL) { - struct mep *me; - char *s; - - g = skip_spaces(g); - if (*g == 0) - g = "No_group"; - if (filter && !strstr(g, filter)) - continue; - if (raw) - s = (char *)pe->metric_name; - else { - if (asprintf(&s, "%s\n%*s%s]", - pe->metric_name, 8, "[", pe->desc) < 0) - return; - - if (details) { - if (asprintf(&s, "%s\n%*s%s]", - s, 8, "[", pe->metric_expr) < 0) - return; - } - } - - if (!s) - continue; - if (!metricgroups) { - strlist__add(metriclist, s); - } else { - me = mep_lookup(&groups, g); - if (!me) - continue; - strlist__add(me->metrics, s); - } - } - free(omg); - } + metricgroup__print_pmu_event(pe, metricgroups, filter, raw, + details, &groups, metriclist); } if (metricgroups && !raw) @@ -407,7 +421,8 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter, struct mep *me = container_of(node, struct mep, nd); if (metricgroups) - printf("%s%s%s", me->name, metrics && !raw ? ":" : "", raw ? " " : "\n"); + printf("%s%s%s", me->name, metrics && !raw ? ":" : "", + raw ? " " : "\n"); if (metrics) metricgroup__print_strlist(me->metrics, raw); next = rb_next(node); From patchwork Fri Apr 17 10:41:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11494741 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52C90186E for ; Fri, 17 Apr 2020 10:47:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 31B3B221F4 for ; Fri, 17 Apr 2020 10:47:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SghWyEyD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31B3B221F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qcyVGbUZeFDSSx5WlQ1K9qAPf3vRp3HKiIoGkphdckI=; b=SghWyEyDFo61fX OXhndtS8IYF8wgbMlzCup8ZoBPeJHunADs3CzxHkyrSVSsMEpkkydXmXzbAuIaNjvY4kXLCDaskBn 5unmhgusD8k9lXzre/BCnIaT0I3MMkcr6xcOMUKXDP0eK9lw5YfG33RXC5Kyp7tLJKVeubVCD6KdA q+0KAQL+2sF31PuK00BtCYSi3K5kyBu/cTz5Vekh7reMtAmoUw/9Gbk0FXnxtFGZCn7U63OZz4vil j2xs7A8++iOUyrCj5dDprdHklcnSmmb4nZAmXzynfzZuicif8UI1HI+9IvM3D5TyNUtQzO2McAQjT JDhH7Yy9yZ5nLuO92Ekg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOWr-0002Qf-86; Fri, 17 Apr 2020 10:47:25 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOV5-0000oT-6Z for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 10:45:37 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B57A69A7C71A36E71477; Fri, 17 Apr 2020 18:45:31 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Apr 2020 18:45:22 +0800 From: John Garry To: , , , , , , , Subject: [RFC PATCH v2 12/13] perf metricgroup: Support printing metric groups for system PMUs Date: Fri, 17 Apr 2020 18:41:23 +0800 Message-ID: <1587120084-18990-13-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1587120084-18990-1-git-send-email-john.garry@huawei.com> References: <1587120084-18990-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_034535_484073_89BC6FFD X-CRM114-Status: GOOD ( 11.32 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.35 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: irogers@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, John Garry , qiangqing.zhang@nxp.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Currently only metricgroups for core- or uncore-based events is supported. Extend this for system events. Signed-off-by: John Garry --- tools/perf/util/metricgroup.c | 61 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 31e97e24c2b0..81a6aa04a601 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -377,19 +377,55 @@ static void metricgroup__print_pmu_event(struct pmu_event *pe, } } +struct metricgroup_print_sys_idata { + struct strlist *metriclist; + bool metricgroups; + char *filter; + bool raw; + bool details; + struct rblist *groups; +}; + +typedef int (*metricgroup_sys_event_iter_fn)(struct pmu_event *pe, void *); + +struct metricgroup_iter_data { + metricgroup_sys_event_iter_fn fn; + void *data; +}; + +static int metricgroup__sys_event_iter(struct perf_pmu *pmu, + struct pmu_event *pe, + void *data) +{ + struct metricgroup_iter_data *d = data; + + if (!pe->metric_expr || !pe->compat || strcmp(pe->compat, pmu->id)) + return 0; + + return d->fn(pe, d->data); +} + +static int metricgroup__print_sys_event_iter(struct pmu_event *pe, void *data) +{ + struct metricgroup_print_sys_idata *d = data; + + metricgroup__print_pmu_event(pe, d->metricgroups, d->filter, d->raw, + d->details, d->groups, d->metriclist); + + return 0; +} + 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_event *pe; + struct perf_pmu *pmu = NULL; int i; struct rblist groups; struct rb_node *node, *next; struct strlist *metriclist = NULL; - if (!map) - return; - if (!metricgroups) { metriclist = strlist__new(NULL, NULL); if (!metriclist) @@ -400,7 +436,7 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter, groups.node_new = mep_new; groups.node_cmp = mep_cmp; groups.node_delete = mep_delete; - for (i = 0; ; i++) { + for (i = 0; map; i++) { pe = &map->table[i]; if (!pe->name && !pe->metric_group && !pe->metric_name) @@ -412,6 +448,23 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter, details, &groups, metriclist); } + while ((pmu = perf_pmu__scan(pmu)) != NULL) { + struct metricgroup_iter_data data = { + .fn = metricgroup__print_sys_event_iter, + .data = (void *) &(struct metricgroup_print_sys_idata){ + .metriclist = metriclist, + .metricgroups = metricgroups, + .filter = filter, + .raw = raw, + .details = details, + .groups = &groups, + }, + }; + + pmu_for_each_sys_event(pmu, metricgroup__sys_event_iter, + &data); + } + if (metricgroups && !raw) printf("\nMetric Groups:\n\n"); else if (metrics && !raw) From patchwork Fri Apr 17 10:41:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 11494755 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D01D6CA for ; Fri, 17 Apr 2020 10:49:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 0B903221F4 for ; Fri, 17 Apr 2020 10:49:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HC74Y0TV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B903221F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YxkWJo0Fgqcia9QPg4UTol+0ARB9TsEPXYwY0boJGrc=; b=HC74Y0TVYSXsX0 zjOLVAnFBE0LC0ubyQ02J2M+v7w8WQLrR8mMiZY35hfmbLq53EtR9birvbIjc5JmAy1C6H3QINE73 7O6lnU1W2ABS9q1GbWF7r30G/5SVDkN3LG5l2fHdNXbwo0ngNzw25/aup4UfT4hLrgWoMn3rpgR75 9BdQx4R1abUucgtcKkJYxX4vw5f1BddtfdoNM4yvuR/LvuNvsu9kx+ZbmBTJGm+a6TWLtqy6eu7ae id0z7YEjJSCSsCOpEhvXXeo8ZmD6lYINP+dJsetHGuSHJQSinleEU6Dj7uJc+Kw0+YuzpqgaipirK vSUhjEHnjdV2TpkVhXdA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOZ8-0005ZJ-Tr; Fri, 17 Apr 2020 10:49:46 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jPOV5-0000q3-Oo for linux-arm-kernel@lists.infradead.org; Fri, 17 Apr 2020 10:45:39 +0000 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id ACD165155E2A6DD9803C; Fri, 17 Apr 2020 18:45:31 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Apr 2020 18:45:22 +0800 From: John Garry To: , , , , , , , Subject: [RFC PATCH v2 13/13] perf metricgroup: Support adding metrics for system PMUs Date: Fri, 17 Apr 2020 18:41:24 +0800 Message-ID: <1587120084-18990-14-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1587120084-18990-1-git-send-email-john.garry@huawei.com> References: <1587120084-18990-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_034536_035088_8A35987E X-CRM114-Status: GOOD ( 12.24 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.35 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: irogers@google.com, ak@linux.intel.com, linux-kernel@vger.kernel.org, John Garry , qiangqing.zhang@nxp.com, linuxarm@huawei.com, zhangshaokun@hisilicon.com, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Currently only adding metrics for core- or uncore-based events is supported. Extend this for system events. Signed-off-by: John Garry --- tools/perf/util/metricgroup.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index 81a6aa04a601..85bf5333e4c6 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -593,17 +593,34 @@ static int metricgroup__add_metric_pmu_event(struct pmu_event *pe, return 0; } +struct metricgroup_add_iter_data { + const char *metric; + struct strbuf *events; + struct list_head *group_list; + int *ret; +}; + +static int metricgroup__add_metric_sys_event_iter(struct pmu_event *pe, + void *data) +{ + struct metricgroup_add_iter_data *d = data; + + if (!match_pe_metric(pe, d->metric)) + return 0; + + return (*d->ret = metricgroup__add_metric_pmu_event(pe, d->events, + d->group_list)); +} + static int metricgroup__add_metric(const char *metric, struct strbuf *events, struct list_head *group_list) { struct pmu_events_map *map = perf_pmu__find_map(NULL); + struct perf_pmu *pmu = NULL; struct pmu_event *pe; int i, ret = -EINVAL; - if (!map) - return 0; - - for (i = 0; ; i++) { + for (i = 0; map; i++) { pe = &map->table[i]; if (!pe->name && !pe->metric_group && !pe->metric_name) @@ -618,6 +635,21 @@ static int metricgroup__add_metric(const char *metric, struct strbuf *events, return ret; } } + + while ((pmu = perf_pmu__scan(pmu)) != NULL) { + struct metricgroup_iter_data data = { + .fn = metricgroup__add_metric_sys_event_iter, + .data = (void *) &(struct metricgroup_add_iter_data){ + .metric = metric, + .events = events, + .group_list = group_list, + .ret = &ret, + }, + }; + + pmu_for_each_sys_event(pmu, metricgroup__sys_event_iter, &data); + } + return ret; }