From patchwork Thu Sep 15 16:37:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 9334257 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 6F2C9601C2 for ; Thu, 15 Sep 2016 16:42:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63BB929A78 for ; Thu, 15 Sep 2016 16:42:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 588F329A7B; Thu, 15 Sep 2016 16:42:58 +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 1CF8529A78 for ; Thu, 15 Sep 2016 16:42:57 +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 1bkZj8-0002Eh-JS; Thu, 15 Sep 2016 16:41:30 +0000 Received: from mail-oi0-x229.google.com ([2607:f8b0:4003:c06::229]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bkZfM-0006Fy-2M for linux-arm-kernel@lists.infradead.org; Thu, 15 Sep 2016 16:37:38 +0000 Received: by mail-oi0-x229.google.com with SMTP id q188so77619654oia.3 for ; Thu, 15 Sep 2016 09:37:15 -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:in-reply-to:references; bh=52G3Ny49aizDcV0qPpZLEXibfbh0MAuFIS/e1CS2IcQ=; b=R8V0Hn2r6PbDadJMBwZvMLv+Pro8FYOZpo9c23ttcyA3jDioxa6/eosFwUTFT139TP R0PM+cSDcAEfRCWdr6bMGDv+dJgcqc32mSKpqoMkgdtpNlLeGYydJr4gAysb3Tx9G/W2 wq9cfRsncRIxJ+OVnnw67HEmvCC9NeIl2BCUU= 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:in-reply-to :references; bh=52G3Ny49aizDcV0qPpZLEXibfbh0MAuFIS/e1CS2IcQ=; b=nFqGBuJfd50eR6PheZntea+E1kah4SJ+eEo+svkiIATNs/hQTsQSJrq9r4LRJhPjFt qBj1eTMo/ur9NZ5cW0JA8nEg5queIXp49sVzaBuiiUgC9l7mbj4BX9C6ZYBgG7kR67yQ u+Jr3FKrP2RlzlqTUohoPz745YxFFzmneUIPajq/uB+ETLOztRoduwiTx4XW27O0NvPS sQ1k9xpAOXnpib83sXGX/Wekc8cpJA5iPwi9v7VQL3PwlmnhXUvVBxKcDZic1rB37hKS rEdk4iUztK0IPS4vA6MNOZ38haWx1R44BB+t3aptWtPUhX50xfVHyeRF78NEcXpVtxqS PfHQ== X-Gm-Message-State: AE9vXwOhmHeRYd/AALiPczqpHs6iGIpVar6z1RZ0TwgX9mzDlMmG1BJpE34W2QwJ+WgC8som X-Received: by 10.107.132.157 with SMTP id o29mr21030456ioi.109.1473957434882; Thu, 15 Sep 2016 09:37:14 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id i80sm1253646ita.5.2016.09.15.09.37.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Sep 2016 09:37:14 -0700 (PDT) From: Mathieu Poirier To: acme@kernel.org, adrian.hunter@intel.com Subject: [PATCH V6 2/3] perf tools: new tracepoint specific function Date: Thu, 15 Sep 2016 10:37:07 -0600 Message-Id: <1473957428-28311-3-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473957428-28311-1-git-send-email-mathieu.poirier@linaro.org> References: <1473957428-28311-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160915_093736_367532_7346EA3C X-CRM114-Status: GOOD ( 13.21 ) 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 Making function perf_evsel__append_filter() static and introducing a new tracepoint specific function to append filters. That way we eliminate redundant code and avoid formatting mistake. Signed-off-by: Mathieu Poirier Acked-by: Adrian Hunter --- tools/perf/builtin-trace.c | 7 +++---- tools/perf/util/evsel.c | 9 +++++++-- tools/perf/util/evsel.h | 3 +-- tools/perf/util/parse-events.c | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 4c2704332c14..34effab09f39 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2148,11 +2148,10 @@ static int trace__set_ev_qualifier_filter(struct trace *trace) if (filter == NULL) goto out_enomem; - if (!perf_evsel__append_filter(trace->syscalls.events.sys_enter, - "(%s) && (%s)", filter)) { + if (!perf_evsel__append_tp_filter(trace->syscalls.events.sys_enter, + filter)) { sys_exit = trace->syscalls.events.sys_exit; - err = perf_evsel__append_filter(sys_exit, - "(%s) && (%s)", filter); + err = perf_evsel__append_tp_filter(sys_exit, filter); } free(filter); diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index b93369745e08..a99e82d97df2 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1045,8 +1045,8 @@ int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter) return -1; } -int perf_evsel__append_filter(struct perf_evsel *evsel, - const char *fmt, const char *filter) +static int perf_evsel__append_filter(struct perf_evsel *evsel, + const char *fmt, const char *filter) { char *new_filter; @@ -1062,6 +1062,11 @@ int perf_evsel__append_filter(struct perf_evsel *evsel, return -1; } +int perf_evsel__append_tp_filter(struct perf_evsel *evsel, const char *filter) +{ + return perf_evsel__append_filter(evsel, "(%s) && (%s)", filter); +} + int perf_evsel__enable(struct perf_evsel *evsel) { int nthreads = thread_map__nr(evsel->threads); diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 7ab59f15892f..36ed0997e65b 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -233,8 +233,7 @@ void perf_evsel__set_sample_id(struct perf_evsel *evsel, bool use_sample_identifier); int perf_evsel__set_filter(struct perf_evsel *evsel, const char *filter); -int perf_evsel__append_filter(struct perf_evsel *evsel, - const char *fmt, const char *filter); +int perf_evsel__append_tp_filter(struct perf_evsel *evsel, const char *filter); int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads, const char *filter); int perf_evsel__enable(struct perf_evsel *evsel); diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 9692300585f6..751b48fc641c 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1762,7 +1762,7 @@ static int set_filter(struct perf_evsel *evsel, const void *arg) return -1; } - if (perf_evsel__append_filter(evsel, "(%s) && (%s)", str) < 0) { + if (perf_evsel__append_tp_filter(evsel, str) < 0) { fprintf(stderr, "not enough memory to hold filter string\n"); return -1; @@ -1793,7 +1793,7 @@ static int add_exclude_perf_filter(struct perf_evsel *evsel, snprintf(new_filter, sizeof(new_filter), "common_pid != %d", getpid()); - if (perf_evsel__append_filter(evsel, "(%s) && (%s)", new_filter) < 0) { + if (perf_evsel__append_tp_filter(evsel, new_filter) < 0) { fprintf(stderr, "not enough memory to hold filter string\n"); return -1;