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: 73925 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1575695qga; Mon, 15 Aug 2016 11:18:06 -0700 (PDT) X-Received: by 10.66.217.170 with SMTP id oz10mr56135199pac.61.1471285086056; Mon, 15 Aug 2016 11:18:06 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x4si27678065pfa.54.2016.08.15.11.18.05; Mon, 15 Aug 2016 11:18:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753299AbcHOSRs (ORCPT + 27 others); Mon, 15 Aug 2016 14:17:48 -0400 Received: from mail-io0-f182.google.com ([209.85.223.182]:35691 "EHLO mail-io0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753204AbcHOSRp (ORCPT ); Mon, 15 Aug 2016 14:17:45 -0400 Received: by mail-io0-f182.google.com with SMTP id m101so86493387ioi.2 for ; Mon, 15 Aug 2016 11:17:45 -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=ka7w4wnO6wv81wKO0QAgVKLpYa1+2I8unmoBZfjj7xVKrX77pxjs2wqPGIrYuYhoKy yPbk75U/djrVjsslEodImhWau4DKiynpLdJ96El4Ozul0c4H6TlGLO3yb81PSzqPAImV e4Z+gmOeOvbJTQu8RE9BI4TabMqndgmA7P98s15Wc6rbZOA1+zJaLYiSBXzRcjU/R5u0 i3askusakB5UqO6VhssVdZdnU7InZ2LISt1UP8arZT7stk6jv+v+WZ5CM69F3JWvTJJ9 tFGW01r1nrLKkgxjAFlJ9KN1J9FD/D5kE9UsMSaaYu6nM1IAbtJiIF25Am/SAQyRfZwf a44g== X-Gm-Message-State: AEkoouudE4Dw8U/NwDE70HSea9qkfLJgspXtoDOhaiLD/3spV3FNlYxAk335/wZTcRcnLOwv 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 Cc: mingo@redhat.com, peterz@infradead.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.7.4 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; }