From patchwork Mon Aug 15 18:17:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 9281851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A4D3160839 for ; Mon, 15 Aug 2016 18:19:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9846928E39 for ; Mon, 15 Aug 2016 18:19:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D11F28E3B; Mon, 15 Aug 2016 18:19:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9D71628E39 for ; Mon, 15 Aug 2016 18:19:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZMSa-00063R-Sx; Mon, 15 Aug 2016 18:18:04 +0000 Received: from mail-io0-x22d.google.com ([2607:f8b0:4001:c06::22d]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZMSX-0005vz-4w for linux-arm-kernel@lists.infradead.org; Mon, 15 Aug 2016 18:18:02 +0000 Received: by mail-io0-x22d.google.com with SMTP id b62so86501193iod.3 for ; Mon, 15 Aug 2016 11:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=sKutRAZPFl1anvZn7DhtIDe3a4THIRbM6DNk1u7FTT8=; b=MHZfg4gKhzyLk5w3gF+EsUYJkQY7Ol/PUpq1PMsV+SANQjcys1BAmlxXroURRMmPWq G7rqbX3SHh5ekRN/O2D1rRWZJmtiaGrQNShCly1FN0C4R8OB8QdNBD010Wp8zM1oYrvK jHcTpnBI8+ZNhoiVVC/40GoC0wYKAayFa8Kq8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=sKutRAZPFl1anvZn7DhtIDe3a4THIRbM6DNk1u7FTT8=; b=Hz027+V3pRUFJGRNbJTMM6sfeEjqf5Alw1KPqYtfUWA391dz3LyJv+yxEgYhcH9YCL EnHqqPBSduLmU2PezrzkMqy0zV04il9iAMEx+uHgG0AS9CHoJW/SYRMCgIqDGVT4n0+5 z1vDlmMwfWG2vfowzYkjcXnSWit9sUToq7lGXVYu9loxnmKuwbCM8G4JWwlKw2AMDdHn YZgAGEmCRXLmDUt4BDg4Dsh6KVd4v23eNJ2fVP4y9cvkLvsjeszYYc/WK4Ro5Hv7Oqwa XRXtFVJP5O9L6CCQqdKrjMc7OrOMYWRdEdMIsllvlyYItvmK7TN0QIISxZhNe8NOoVNj qutw== X-Gm-Message-State: AEkoouveunveRM6UTzN5K0KF87e5BYvtwXHjOm0owg6GbdiXJ8zI2uBrzeHDYWZZ1uUSrN2X X-Received: by 10.107.48.76 with SMTP id w73mr38495762iow.172.1471285059991; Mon, 15 Aug 2016 11:17:39 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id j129sm432219iof.35.2016.08.15.11.17.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Aug 2016 11:17:38 -0700 (PDT) From: Mathieu Poirier To: acme@kernel.org Subject: [PATCH RFC] perf tools: Adding event type for HW tracers Date: Mon, 15 Aug 2016 12:17:37 -0600 Message-Id: <1471285057-8327-1-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160815_111801_290258_ADE9D9C9 X-CRM114-Status: GOOD ( 14.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peterz@infradead.org, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, mingo@redhat.com, jolsa@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP It is now possible to use the kernel's perf filter framework to reduce the amount of trace collected by IntelPT and CoreSight tracers. To collect address filter specifics from the perf tool command line function parse_filter() is used, which in turn calls set_filter(). In the latter only events with a PERF_TYPE_TRACEPOINT attribute type are accepted. Since IntelPT and CoreSight PMUs don't have a PERF_TYPE_TRACEPOINT type, filter specification from the command line fails. This patch adds a new PERF_TYPE_HW_TRACER PMU type. From there set_filter() is enhanced to accept filter definition for tracepoint and HW tracer PMUs. CC: Alexander Shishkin Signed-off-by: Mathieu Poirier --- arch/x86/events/intel/pt.c | 2 +- drivers/hwtracing/coresight/coresight-etm-perf.c | 4 +++- include/uapi/linux/perf_event.h | 1 + tools/include/uapi/linux/perf_event.h | 1 + tools/perf/util/parse-events.c | 10 ++++++++-- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index 5178c5de0b19..f828eae05a0e 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -1419,7 +1419,7 @@ static __init int pt_init(void) pt_pmu.pmu.nr_addr_filters = pt_cap_get(PT_CAP_num_address_ranges); - ret = perf_pmu_register(&pt_pmu.pmu, "intel_pt", -1); + ret = perf_pmu_register(&pt_pmu.pmu, "intel_pt", PERF_TYPE_HW_TRACER); return ret; } diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 7ae2a884ae5c..0b0bc81b58ba 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -631,7 +631,9 @@ static int __init etm_perf_init(void) etm_pmu.addr_filters_validate = etm_addr_filters_validate; etm_pmu.nr_addr_filters = ETM_ADDR_CMP_MAX; - ret = perf_pmu_register(&etm_pmu, CORESIGHT_ETM_PMU_NAME, -1); + ret = perf_pmu_register(&etm_pmu, + CORESIGHT_ETM_PMU_NAME, + PERF_TYPE_HW_TRACER); if (ret == 0) etm_perf_up = true; diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h index ce969677dab3..8b223d66694a 100644 --- a/include/uapi/linux/perf_event.h +++ b/include/uapi/linux/perf_event.h @@ -32,6 +32,7 @@ enum perf_type_id { PERF_TYPE_HW_CACHE = 3, PERF_TYPE_RAW = 4, PERF_TYPE_BREAKPOINT = 5, + PERF_TYPE_HW_TRACER = 6, PERF_TYPE_MAX, /* non-ABI */ }; diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h index ce969677dab3..8b223d66694a 100644 --- a/tools/include/uapi/linux/perf_event.h +++ b/tools/include/uapi/linux/perf_event.h @@ -32,6 +32,7 @@ enum perf_type_id { PERF_TYPE_HW_CACHE = 3, PERF_TYPE_RAW = 4, PERF_TYPE_BREAKPOINT = 5, + PERF_TYPE_HW_TRACER = 6, PERF_TYPE_MAX, /* non-ABI */ }; diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 2eb8b1ed4cc8..bb14cd63cba9 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1761,9 +1761,15 @@ static int set_filter(struct perf_evsel *evsel, const void *arg) { const char *str = arg; - if (evsel == NULL || evsel->attr.type != PERF_TYPE_TRACEPOINT) { + if (evsel == NULL) + return -1; + + if (evsel->attr.type != PERF_TYPE_TRACEPOINT && + evsel->attr.type != PERF_TYPE_HW_TRACER) { fprintf(stderr, - "--filter option should follow a -e tracepoint option\n"); + "--filter option should follow a -e tracepoint or HW tracer option\n"); + fprintf(stderr, "evsel->name: %s type: 0x%x\n", + evsel->name, evsel->attr.type); return -1; }