From patchwork Tue Sep 6 16:19:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 75560 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp632129qgf; Tue, 6 Sep 2016 09:19:54 -0700 (PDT) X-Received: by 10.66.148.202 with SMTP id tu10mr73419707pab.52.1473178794788; Tue, 06 Sep 2016 09:19:54 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si28818805pfi.286.2016.09.06.09.19.53; Tue, 06 Sep 2016 09:19:54 -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 S935358AbcIFQTm (ORCPT + 27 others); Tue, 6 Sep 2016 12:19:42 -0400 Received: from mail-yb0-f172.google.com ([209.85.213.172]:34490 "EHLO mail-yb0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934203AbcIFQT1 (ORCPT ); Tue, 6 Sep 2016 12:19:27 -0400 Received: by mail-yb0-f172.google.com with SMTP id x93so88190387ybh.1 for ; Tue, 06 Sep 2016 09:19:26 -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=ntbko8zmqhKNsAc6Ej6rm9V83Dt+r9RQNZJSqxn8JSk=; b=KX3DbnSfl8J2PYCXW74cvE49lrvaChqVy6Y30IBRshd9sxiCSLXSFaP4dkwr0B9cYF Zky1DssNBKeXVmdqPb0KV7celncmrWVpZp8j+78ScqFFWc/AbR7xS9mcWwr5LaC+qqEh x3Gy3GFYd0rbkInwamfc8E0U+TQJKhFNEjZiw= 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=ntbko8zmqhKNsAc6Ej6rm9V83Dt+r9RQNZJSqxn8JSk=; b=OAgHR0b3pyPe1H13wrY/tsMx+VDd2QqP+BdKwaIIQi0SJhGQHLLkCROx306yelZj2h yHRi12u5TjXKTSLnHMLJyX/RcbJ5U5pRZHlYpqPjtIFqB2E8CGV3NGMWi777oIPyCubF pUrtMvc3aitzxUldULSGQX7KyIGblniONCA9nCYqZEpwOLBIaODUjhWBAE6xmH4c9Q7A Vv79jHRss6vgq8qgjVsHA7sBRfOtZpKhMiOpeNgM3WOIXW5Pe48XbLpfDnyZXhBS4HN5 TS1A4NZOSJ21ZO/EUIzXHw76H+83hko2QyXKGvJRhs//0tiZV1HrEjX/Bes5qDOfO1+h hHpA== X-Gm-Message-State: AE9vXwO9ttX+LK3OWQ5FPvZIeujaMi5tiX4xMhk+LqGiZ8lJ5oZtsIMFLjYSae3HoXwUwDEr X-Received: by 10.36.77.85 with SMTP id l82mr30917768itb.77.1473178766222; Tue, 06 Sep 2016 09:19:26 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x64sm12383973ite.8.2016.09.06.09.19.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Sep 2016 09:19:25 -0700 (PDT) From: Mathieu Poirier To: acme@kernel.org Cc: mingo@redhat.com, peterz@infradead.org, alexander.shishkin@linux.intel.com, jolsa@kernel.org, acme@infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH V3] perf tools: adding support for address filters Date: Tue, 6 Sep 2016 10:19:23 -0600 Message-Id: <1473178763-2870-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 This patch makes it possible to use the current filter framework with address filters. That way address filters for HW tracers such as CoreSight and IntelPT can be communicated to the kernel drivers. CC: Alexander Shishkin Signed-off-by: Mathieu Poirier Acked-by: Jiri Olsa --- Changes for V3: - Added Jiri's ack. - Rebased to v4.8-rc5. Changes for V2: - Rebased to v4.8-rc4. - Revisited error path. --- tools/perf/util/parse-events.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 2eb8b1ed4cc8..1df413fbf7f8 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1760,12 +1760,26 @@ foreach_evsel_in_last_glob(struct perf_evlist *evlist, static int set_filter(struct perf_evsel *evsel, const void *arg) { const char *str = arg; + bool found = false; + int nr_addr_filters = 0; + struct perf_pmu *pmu = NULL; - if (evsel == NULL || evsel->attr.type != PERF_TYPE_TRACEPOINT) { - fprintf(stderr, - "--filter option should follow a -e tracepoint option\n"); - return -1; - } + if (evsel == NULL) + goto err; + + while ((pmu = perf_pmu__scan(pmu)) != NULL) + if (pmu->type == evsel->attr.type) { + found = true; + break; + } + + if (found) + perf_pmu__scan_file(pmu, "nr_addr_filters", + "%d", &nr_addr_filters); + + + if (evsel->attr.type != PERF_TYPE_TRACEPOINT && !nr_addr_filters) + goto err; if (perf_evsel__append_filter(evsel, "&&", str) < 0) { fprintf(stderr, @@ -1774,6 +1788,12 @@ static int set_filter(struct perf_evsel *evsel, const void *arg) } return 0; + +err: + fprintf(stderr, + "--filter option should follow a -e tracepoint or HW tracer option\n"); + + return -1; } int parse_filter(const struct option *opt, const char *str,