From patchwork Tue Aug 30 16:10:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 9305623 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 0BFFB60756 for ; Tue, 30 Aug 2016 16:12:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F06522015F for ; Tue, 30 Aug 2016 16:12:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4BC528C7E; Tue, 30 Aug 2016 16:12: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=ham 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 719A72015F for ; Tue, 30 Aug 2016 16:12:19 +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 1belcc-0002Xa-OP; Tue, 30 Aug 2016 16:10:46 +0000 Received: from mail-it0-x232.google.com ([2607:f8b0:4001:c0b::232]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1belcV-0001oB-V3 for linux-arm-kernel@lists.infradead.org; Tue, 30 Aug 2016 16:10:42 +0000 Received: by mail-it0-x232.google.com with SMTP id x131so173298786ite.0 for ; Tue, 30 Aug 2016 09:10:18 -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=3xFok2g9rnFDkh7gj5+59+U4AybajIJTpLt75AhrK1A=; b=bufHypbN1X8S/09ge+p0LShReYay8nM8wTdOLLq+U7162zmQx7UdzTv0Tnx0kOyPYO CVfCyc5OsfibaeyM5ztqMJ6QF1dN9uLvRI1zCnON6GJ6IfpxcVsOorgNa/kHab5hkPlC O13wsVmD3Xt8NNxUkFri+VR6KAm/SWz2qVJXM= 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=3xFok2g9rnFDkh7gj5+59+U4AybajIJTpLt75AhrK1A=; b=QPR3P701JAdkSMTDU02QGy8ATqGkwNWFGzqLUqHHhBp1IPx3lF17oToeO3u5GMxA/p nUq20zgl5NL5DrDIae2lAQKbAizzA29vZQi/W204Ht2hVTy3fvFXWxHiKfpJjuYAp7L0 cIFyUhwwZJzhf8OEQZOuEmjqsB65a5oS0XfEC0o4lW2W0TeNJejy5XZ/0Z49w95UWmp/ S4a1ZBkc7yFnq8tuhEk8k/Zisl0/1+REzOTHhm6k5DCzTrF7C9wCB2r3I2Vql5vMBdkk 4bgPihcs5KuBHrc3gdaE4QkdXv/11jq8o3rGK9wn8ylsGrA4gWeZqZp2K2ZgRLdKFo0S H5eQ== X-Gm-Message-State: AE9vXwNB1mfcJg1NHV5Z/1TmRhKFaoSviFGrGw8KDDCdu0crjLmkEKRZE4v7z8KUa/fieOoB X-Received: by 10.36.46.4 with SMTP id i4mr26866626ita.27.1472573417717; Tue, 30 Aug 2016 09:10:17 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id f126sm3472378ith.7.2016.08.30.09.10.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Aug 2016 09:10:17 -0700 (PDT) From: Mathieu Poirier To: acme@kernel.org Subject: [PATCH V2] perf tools: adding support for address filters Date: Tue, 30 Aug 2016 10:10:15 -0600 Message-Id: <1472573415-3618-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-20160830_091040_078949_4F98F5DD X-CRM114-Status: GOOD ( 14.93 ) 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: acme@infradead.org, 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 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 V2: - Rebased to v4.8-rc4. - Revisited error path. --- tools/perf/util/parse-events.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) 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,