From patchwork Thu Jul 28 21:42:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 9251751 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 9D30E60757 for ; Thu, 28 Jul 2016 21:45:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F3EE27EED for ; Thu, 28 Jul 2016 21:45:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 838A927F17; Thu, 28 Jul 2016 21:45:00 +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 281DA27EED for ; Thu, 28 Jul 2016 21:45:00 +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 1bSt5h-0005EG-7X; Thu, 28 Jul 2016 21:43:41 +0000 Received: from mail-it0-x22a.google.com ([2607:f8b0:4001:c0b::22a]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bSt4t-0004oo-TR for linux-arm-kernel@lists.infradead.org; Thu, 28 Jul 2016 21:42:54 +0000 Received: by mail-it0-x22a.google.com with SMTP id j124so92746294ith.1 for ; Thu, 28 Jul 2016 14:42:31 -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=O8+boH7gPVoup221S2by43EYENIewuifyiCA279hyPI=; b=Sgo1Wj69M2ydq4Gj15F/f73obNN8UGtV85fk1k5LGT8oKVC5B7tWD2MmKzaDIp9DhM JcHQk5BIswJ/2Qd4wOa8p+2R1wBte/xlcMF47W6/H6Mc5hvRmeZIdeltwPCA4sqXeCvz 0Eu0WkO0T+W6rU9TFWJmCnJ/LRIBX1QhIY4JE= 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=O8+boH7gPVoup221S2by43EYENIewuifyiCA279hyPI=; b=VLz1koHKk/S5MLQBo6rsrTfV9v3VIFX9hc2amUKpgAp6B1Lkz+0AJzKu111lusGNIV AwIPeihotHlOklOf6UZ5SDIDYVVEvJ9IKbr81Igq3L+Hmw1aQkaP6fYQRnRA7gwQb0YL WNxiUHEfoKwtG6i/CMQEn4Qx24165qkg0gxBls/Gxp/fjerEHIvYK/VpPT9ueaN3WO3F RawXCpUuazCt8+qY8rhVnl+0pPVEdCrc1jm60YoIJtsnpZhBDiYN7LAK8oIsCk7p+mYQ kNLW568+GBzxN7w9YTsDOKOsgWPGXGIMd0u0p7n20thxozKPVcCc8Z62X75IEZSsHF7F GlLw== X-Gm-Message-State: AEkoouuvzbDWnFxGCxMCFO6EY5SqiNxnrtBXoYp9QqKj6PsJ9zx1pCf46Q8/eT6/4jAzdKJS X-Received: by 10.36.200.131 with SMTP id w125mr3988236itf.33.1469742151062; Thu, 28 Jul 2016 14:42:31 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h99sm5808499iod.9.2016.07.28.14.42.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jul 2016 14:42:30 -0700 (PDT) From: Mathieu Poirier To: acme@kernel.org, jolsa@kernel.org Subject: [PATCH V3 4/6] perf tools: pushing driver configuration down to the kernel Date: Thu, 28 Jul 2016 15:42:21 -0600 Message-Id: <1469742143-22245-5-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469742143-22245-1-git-send-email-mathieu.poirier@linaro.org> References: <1469742143-22245-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160728_144252_218941_42C3FE9C X-CRM114-Status: GOOD ( 13.83 ) 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: peterz@infradead.org, Mathieu Poirier , mingo@redhat.com, linux-kernel@vger.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 Now that PMU specific driver configuration are queued in evsel::config_terms, all we need to do is re-use the current ioctl() mechanism to push down the information to the kernel driver. Signed-off-by: Mathieu Poirier --- tools/perf/builtin-record.c | 9 +++++++++ tools/perf/builtin-stat.c | 8 ++++++++ tools/perf/util/evlist.c | 21 +++++++++++++++++++++ tools/perf/util/evlist.h | 3 +++ tools/perf/util/evsel.c | 24 ++++++++++++++++++++++++ tools/perf/util/evsel.h | 3 +++ 6 files changed, 68 insertions(+) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 8f2c16d9275f..185e2f7cd307 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -383,6 +383,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 +413,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 0c16d20d7e32..f003a9e50f4e 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -533,6 +533,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; @@ -604,6 +605,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/util/evlist.c b/tools/perf/util/evlist.c index 2a40b8e1def7..dd20a182b5a3 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1433,6 +1433,27 @@ int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **e return err; } +int perf_evlist__apply_drv_configs(struct perf_evlist *evlist, + struct perf_evsel **err_evsel, + struct perf_evsel_config_term **err_term) +{ + struct perf_evsel *evsel; + int err = 0; + const int ncpus = cpu_map__nr(evlist->cpus), + nthreads = thread_map__nr(evlist->threads); + + evlist__for_each_entry(evlist, evsel) { + err = perf_evsel__apply_drv_configs(evsel, ncpus, + nthreads, err_term); + if (err) { + *err_evsel = evsel; + break; + } + } + + return err; +} + int perf_evlist__set_filter(struct perf_evlist *evlist, const char *filter) { struct perf_evsel *evsel; diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 4fd034f22d2f..bf7ed0be3f33 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -232,6 +232,9 @@ void perf_evlist__set_maps(struct perf_evlist *evlist, struct cpu_map *cpus, struct thread_map *threads); int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target); int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **err_evsel); +int perf_evlist__apply_drv_configs(struct perf_evlist *evlist, + struct perf_evsel **err_evsel, + struct perf_evsel_config_term **term); void __perf_evlist__set_leader(struct list_head *list); void perf_evlist__set_leader(struct perf_evlist *evlist); diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 8c54df61fe64..e0c44ee586ee 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1034,6 +1034,30 @@ int perf_evsel__append_filter(struct perf_evsel *evsel, return -1; } +int perf_evsel__apply_drv_configs(struct perf_evsel *evsel, + int ncpus, int nthreads, + struct perf_evsel_config_term **err_term) +{ + int err = 0; + struct perf_evsel_config_term *term; + + list_for_each_entry(term, &evsel->config_terms, list) { + if (term->type != PERF_EVSEL__CONFIG_TERM_DRV_CFG) + continue; + + err = perf_evsel__run_ioctl(evsel, ncpus, nthreads, + PERF_EVENT_IOC_SET_DRV_CONFIGS, + (void *)term->val.drv_cfg); + + if (err) { + *err_term = term; + break; + } + } + + return err; +} + 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 e398b5cb70a1..221eb7cc9795 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -237,6 +237,9 @@ int perf_evsel__append_filter(struct perf_evsel *evsel, const char *op, const char *filter); int perf_evsel__apply_filter(struct perf_evsel *evsel, int ncpus, int nthreads, const char *filter); +int perf_evsel__apply_drv_configs(struct perf_evsel *evsel, + int ncpus, int nthreads, + struct perf_evsel_config_term **err_term); int perf_evsel__enable(struct perf_evsel *evsel); int perf_evsel__disable(struct perf_evsel *evsel);