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: 9317457 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 8EF4F60752 for ; Tue, 6 Sep 2016 16:21:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77CCF28DFF for ; Tue, 6 Sep 2016 16:21:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C97128E17; Tue, 6 Sep 2016 16:21:44 +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 0090828DFF for ; Tue, 6 Sep 2016 16:21:43 +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 1bhJ6F-0006wG-OT; Tue, 06 Sep 2016 16:19:51 +0000 Received: from mail-yb0-x22b.google.com ([2607:f8b0:4002:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bhJ6B-0006rA-KL for linux-arm-kernel@lists.infradead.org; Tue, 06 Sep 2016 16:19:49 +0000 Received: by mail-yb0-x22b.google.com with SMTP id g5so25613836yba.2 for ; Tue, 06 Sep 2016 09:19:27 -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=N+GROHXBeJQXWunahP0oBxPbK3SRzQFr5qazX7wwh5c6lVt+rW52WnqmPcACyoJtrk 8JS7nHDnQY6tV1ZAteMpjq+mgOSs/K/E6HYEd17TpGH8URXy6luw8rcKwMuDNny5j3Ju 4aHueHJwYd0ZVigoQU7I+ajY92qsyckwBURMF1Pgd6YHX4bqn6NFwB8K0M74VscLGtfe QiyRq64TEvfWXQZcJY4BX57sMbYrpVT8xCQeUrwfu4A6IblfZaISVqyDsCfydj3d3hka cczmW8Krzpt8WoLIs8/kUkzPgve2eFtpuvd9+i671lhp5fpi1bfNH5yoCKV9Ck31AF9x iUzQ== X-Gm-Message-State: AE9vXwNiv1yU3tLwxc/TbqFNVCgjOXdN44gBcuT4kGdATfONEwWdrBKEfgLYMjLoch5uvVkJ 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160906_091947_994475_A7BAACF1 X-CRM114-Status: GOOD ( 15.02 ) 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 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(-) 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,