From patchwork Tue Jan 15 23:07:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 155679 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5454653jaa; Tue, 15 Jan 2019 15:08:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN5Z7eHcsxguX1aCW6xq1jOBxyxH7OURj5WUlDPMNSWt7mZXdV66d2lp4SFAN4J0xyepA2ZH X-Received: by 2002:a17:902:7581:: with SMTP id j1mr6628344pll.308.1547593683119; Tue, 15 Jan 2019 15:08:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547593683; cv=none; d=google.com; s=arc-20160816; b=Eim+u7UQAOo5zhQp7eyVcXUiTFpE3udlrdnDd0tFJO3LmKL/wHPrb0mP8D+j3N+5e+ /gBqkEzbFJNVtkaGKBzbau4P9kOhTFM6H5XmPKDsDxtLcwlfhRetQSWl3pdGpIl8cXy3 yY1YbOtac2pQZukJug9pZyd3rSABvDL4P7v4Ox9AO7/JnB0LAv0Y23P+lZCzh+VZA3Ol 0SsjLNmAU4jNQNOIm7DwRJd5WclR06zR95SLAaxlZjFGA4W9SB6G3McOtQsxBJ2cGWWw hCfqgIB/tMwGj7OFuivNSKDwFwJh1Q/O9FLOFwHMbvhXUxlI26yEwq2Q+eQohxhC7OgG VjWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=gPrWMMpDRosRuuCKq7RVqqPV5xVc5OS0HdA7yr9gVbk=; b=y8ejYSa4j0eWPLr2BmjDzIc58neXaEdDiclwE1ocIfS+Mece+qCi0+CqwttYgZXtsq czeJpYHiDqKE5JCWkSd/KrrLcnD8z66xnPnfAOULVXrsJd2xndEvpab24ybCgOfrkWx5 edQn6W0otFM8ux2g9ttaQe/PnNLtRbPTT3rpF5txOzQuV91vGy5I2F+hqifJvunav4XB 4DMCGJQzhk3tXbDTmwfRpdqI29MWa2LAJF3e6TPjr+hzADKM1floKN7gPcNr6VAvVgkM RY0bhdIrUL4dNVHVtQPURlqtpLwpp0bEF8EfpMJUK7/288jUCEPjJUTVMzQ24L017huB EU6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QqRrsVaB; 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 sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e8si2217435pfc.248.2019.01.15.15.08.02; Tue, 15 Jan 2019 15:08:03 -0800 (PST) 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 header.s=google header.b=QqRrsVaB; 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 sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391344AbfAOXIB (ORCPT + 31 others); Tue, 15 Jan 2019 18:08:01 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:47069 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391292AbfAOXH4 (ORCPT ); Tue, 15 Jan 2019 18:07:56 -0500 Received: by mail-pf1-f195.google.com with SMTP id c73so2013922pfe.13 for ; Tue, 15 Jan 2019 15:07:55 -0800 (PST) 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=gPrWMMpDRosRuuCKq7RVqqPV5xVc5OS0HdA7yr9gVbk=; b=QqRrsVaBJ7rICeZftdrm7Ke54BLqO4IpJ+ykpcY8TsczjNwJap13T56otWVRsJ2+6d HQIW4hI5sXRNBTbBG/FIL660lxD3zLbuIlWAXp0VjrpyFfrw5YhfqDp4DSvpo7XBtL+/ qN5NlzimZrdkkaRSehkgJWGsM4F4jzcZMfrAU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gPrWMMpDRosRuuCKq7RVqqPV5xVc5OS0HdA7yr9gVbk=; b=jT1e/aCUZjo530Syqbjo2E//q5Y/2OGLoJhu+s1Bco3QMviZvaIiyaG6mK9To7Q/qZ a+TDLTdI+hIZUvT8bq3cYW7Vd/r60xmWK32FkIFl8yBvTHwGu1yq7IyeTcEgxJ0bvA7j k4z2siB7LAGxwbMpCHuwwNf8lMyEs6DIj/Tn+wyDKCk45VZZaRdDD4Qv1mfXvBIb7rlq AfmZLlDMDQoe8k9cyLZ0qMglES6jPhhpzRbq/gDuFwaRb5fg/Qez8EvG/Dd4ZNqdD773 3YQYe+HWnR/EKM85B4kKUpdQGv15639ds6rPqn0WLoRthtp91N6T/d9eSUVgCJeFGQJ9 M0yg== X-Gm-Message-State: AJcUukfbH8fLY1cSuk74MdFSXCkIB2bVwd7aqZ6URPiCiDgB8EwkUhUZ ZEBzfBtXiIQ0GwZ3xeFQeTCfLA== X-Received: by 2002:a63:6cc:: with SMTP id 195mr5958903pgg.401.1547593675503; Tue, 15 Jan 2019 15:07:55 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h19sm4985928pfn.114.2019.01.15.15.07.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 15:07:54 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org, gregkh@linuxfoundation.org Cc: mingo@redhat.com, tglx@linutronix.de, alexander.shishkin@linux.intel.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, will.deacon@arm.com, mark.rutland@arm.com, jolsa@redhat.com, namhyung@kernel.org, adrian.hunter@intel.com, ast@kernel.org, hpa@zytor.com, suzuki.poulose@arm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/7] perf tools: Use event attributes to send sink information to kernel Date: Tue, 15 Jan 2019 16:07:40 -0700 Message-Id: <20190115230742.13730-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190115230742.13730-1-mathieu.poirier@linaro.org> References: <20190115230742.13730-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The communication of sink information for a trace session doesn't work when more than on CPU is involved in the scenario due to the static nature of sysfs. As such communicate the sink information to each event by using the perf_event::attr:config2 attribute. The information sent to the kernel is an hash of the sink's name, which is unique in a system. Signed-off-by: Mathieu Poirier --- tools/perf/arch/arm/util/cs-etm.c | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) -- 2.17.1 diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 2f595cd73da6..4aa6193dcb50 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -22,6 +22,7 @@ #include "../../util/thread_map.h" #include "../../util/cs-etm.h" +#include #include #include @@ -60,10 +61,45 @@ static int cs_etm_parse_snapshot_options(struct auxtrace_record *itr, return 0; } +static int cs_etm_set_sink_attr(struct perf_pmu *pmu, + struct perf_evsel *evsel) +{ + char msg[BUFSIZ], path[PATH_MAX], *sink; + struct perf_evsel_config_term *term; + int ret = -EINVAL; + u32 hash; + + list_for_each_entry(term, &evsel->config_terms, list) { + if (term->type != PERF_EVSEL__CONFIG_TERM_DRV_CFG) + continue; + + sink = term->val.drv_cfg; + snprintf(path, PATH_MAX, "sinks/%s", sink); + + ret = perf_pmu__scan_file(pmu, path, "%x", &hash); + if (ret != 1) { + pr_err("failed to set sink \"%s\" on event %s with %d (%s)\n", + sink, perf_evsel__name(evsel), errno, + str_error_r(errno, msg, sizeof(msg))); + return ret; + } + + evsel->attr.config2 = (u64)hash; + return 0; + } + + /* + * No sink was provided on the command line - for _now_ treat + * this as an error. + */ + return ret; +} + static int cs_etm_recording_options(struct auxtrace_record *itr, struct perf_evlist *evlist, struct record_opts *opts) { + int ret; struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr); struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; @@ -92,6 +128,10 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, if (!cs_etm_evsel) return 0; + ret = cs_etm_set_sink_attr(cs_etm_pmu, cs_etm_evsel); + if (ret) + return ret; + if (opts->use_clockid) { pr_err("Cannot use clockid (-k option) with %s\n", CORESIGHT_ETM_PMU_NAME);