From patchwork Fri Sep 16 15:50:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 76398 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp565199qgf; Fri, 16 Sep 2016 08:51:15 -0700 (PDT) X-Received: by 10.66.147.105 with SMTP id tj9mr11936792pab.42.1474041075771; Fri, 16 Sep 2016 08:51:15 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si10835561pay.113.2016.09.16.08.51.15; Fri, 16 Sep 2016 08:51:15 -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 S964992AbcIPPvF (ORCPT + 27 others); Fri, 16 Sep 2016 11:51:05 -0400 Received: from mail-it0-f41.google.com ([209.85.214.41]:38219 "EHLO mail-it0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753955AbcIPPuU (ORCPT ); Fri, 16 Sep 2016 11:50:20 -0400 Received: by mail-it0-f41.google.com with SMTP id n143so19936201ita.1 for ; Fri, 16 Sep 2016 08:50:20 -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=5yz8MinWTJmnk1+8P8VYE3/ej21Oy1MTqmE1bRTG0w4=; b=EGRLR6yg1SdJZVwl2xAB1afcQ60TTg3872BM3N1tgG8LAZzwWLqGo93Ix8Pdrda47I Mbj8mKsZ9mTnvcA4K1Eu2KcDc5aI2h23abIxDKV5GPc4D600aOZWkU/zIDGv63GU0SGt 1xgcRonslmVD7SaFuXR5uJXxP7/BOv1yeV5vo= 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=5yz8MinWTJmnk1+8P8VYE3/ej21Oy1MTqmE1bRTG0w4=; b=MN64pXe/K7FYlM2Os/7n5ggBsDUw+p8Wpj9nzpZoG7VeZ3YTArUEbxffx+FTQ/5SoA nJMnYTb9KIrvkwqT7p0MD3qtsjS35INONdt3PT1o1YuQSUC0NKkcm0q2BL7t5OdjASp9 r59GlIwB66vEcTY5SBJW4sgvcUF5bX+/MBxWumQ1EzggR0WHQ3aShATzSblLI5dB09sI WVo1P6phEM6Yc2EbyhDsD6usnlqYaOhNZu1Bgj2LQwk9hmds6o/U37t52FW5ENNKhBLH yGZjlnc2I6cuV5q1Iue3mkGdooCMkrv7M3YpxDX2QjmbCmRfFusGWZ0FHWYQCKRI3r0B qgPw== X-Gm-Message-State: AE9vXwN/oulNYvwjgOVThPgRG6Xo5Qza+SlAbkQfcvkkgpct9AgWoIY6WAD5TuiDUMxRj8kl X-Received: by 10.36.91.213 with SMTP id g204mr6504483itb.42.1474041019477; Fri, 16 Sep 2016 08:50:19 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h63sm3177750ita.12.2016.09.16.08.50.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Sep 2016 08:50:18 -0700 (PDT) From: Mathieu Poirier To: acme@kernel.org Cc: acme@infradead.org, peterz@infradead.org, jolsa@kernel.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH V8 6/7] perf tools: adding PMU configuration to tools Date: Fri, 16 Sep 2016 09:50:03 -0600 Message-Id: <1474041004-13956-7-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474041004-13956-1-git-send-email-mathieu.poirier@linaro.org> References: <1474041004-13956-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that the required mechanic is there to deal with PMU specific configuration, add the functionality to the tools where events can be selected. Signed-off-by: Mathieu Poirier Acked-by: Jiri Olsa --- tools/perf/builtin-record.c | 10 ++++++++++ tools/perf/builtin-stat.c | 9 +++++++++ tools/perf/builtin-top.c | 13 +++++++++++++ 3 files changed, 32 insertions(+) -- 2.7.4 diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 6355902fbfc8..ada7fa29ec3f 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -22,6 +22,7 @@ #include "util/evlist.h" #include "util/evsel.h" #include "util/debug.h" +#include "util/drv_configs.h" #include "util/session.h" #include "util/tool.h" #include "util/symbol.h" @@ -383,6 +384,7 @@ static int record__open(struct record *rec) struct perf_evlist *evlist = rec->evlist; struct perf_session *session = rec->session; struct record_opts *opts = &rec->opts; + struct perf_evsel_config_term *err_term; int rc = 0; perf_evlist__config(evlist, opts, &callchain_param); @@ -412,6 +414,14 @@ try_again: goto out; } + if (perf_evlist__apply_drv_configs(evlist, &pos, &err_term)) { + error("failed to set config \"%s\" on event %s with %d (%s)\n", + err_term->val.drv_cfg, perf_evsel__name(pos), errno, + strerror_r(errno, msg, sizeof(msg))); + rc = -1; + goto out; + } + rc = record__mmap(rec); if (rc) goto out; diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 3c7452b39f57..6b85eecdd1bc 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -52,6 +52,7 @@ #include "util/evlist.h" #include "util/evsel.h" #include "util/debug.h" +#include "util/drv_configs.h" #include "util/color.h" #include "util/stat.h" #include "util/header.h" @@ -539,6 +540,7 @@ static int __run_perf_stat(int argc, const char **argv) int status = 0; const bool forks = (argc > 0); bool is_pipe = STAT_RECORD ? perf_stat.file.is_pipe : false; + struct perf_evsel_config_term *err_term; if (interval) { ts.tv_sec = interval / 1000; @@ -610,6 +612,13 @@ try_again: return -1; } + if (perf_evlist__apply_drv_configs(evsel_list, &counter, &err_term)) { + error("failed to set config \"%s\" on event %s with %d (%s)\n", + err_term->val.drv_cfg, perf_evsel__name(counter), errno, + strerror_r(errno, msg, sizeof(msg))); + return -1; + } + if (STAT_RECORD) { int err, fd = perf_data_file__fd(&perf_stat.file); diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 418ed94756d3..0ce3852daaa0 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -24,6 +24,7 @@ #include "util/annotate.h" #include "util/config.h" #include "util/color.h" +#include "util/drv_configs.h" #include "util/evlist.h" #include "util/evsel.h" #include "util/machine.h" @@ -940,6 +941,10 @@ static int callchain_param__setup_sample_type(struct callchain_param *callchain) static int __cmd_top(struct perf_top *top) { + char msg[512]; + struct perf_evsel *pos; + struct perf_evsel_config_term *err_term; + struct perf_evlist *evlist = top->evlist; struct record_opts *opts = &top->record_opts; pthread_t thread; int ret; @@ -976,6 +981,14 @@ static int __cmd_top(struct perf_top *top) if (ret) goto out_delete; + ret = perf_evlist__apply_drv_configs(evlist, &pos, &err_term); + if (ret) { + error("failed to set config \"%s\" on event %s with %d (%s)\n", + err_term->val.drv_cfg, perf_evsel__name(pos), errno, + strerror_r(errno, msg, sizeof(msg))); + goto out_delete; + } + top->session->evlist = top->evlist; perf_session__set_id_hdr_size(top->session);