From patchwork Tue Jan 22 18:11:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 156309 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7883076jaa; Tue, 22 Jan 2019 10:12:04 -0800 (PST) X-Google-Smtp-Source: ALg8bN6O22wr2BSqt0rYGU2iKfwYBMx3W8ts+Tx86NldCMRhelyLcOhQwCksQm/IxZ2jxbDEBC8B X-Received: by 2002:a63:bc02:: with SMTP id q2mr33239434pge.116.1548180724150; Tue, 22 Jan 2019 10:12:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548180724; cv=none; d=google.com; s=arc-20160816; b=AKHLl/W1wtfQTng1pVYk143o+WoTFJAxcivVftUACDDgq/tr4DRsY42HK5/SQLLPLj /C9dHaPSU+qJbZ2d1vRWC8cS2pNPyrrp3rCHxqxTPHKJCaneXLsKFScSWoiusMt6gmu0 xQAebzXOXS7kuXb4/xj/uRRYbIqIVVAjEoeGTZC1/TdFNJyhiPnUQbfnBttIJIk3aJwo 7ISF9zXpmtTC/uStFDT02PJhyrkHe15I7rMU0jdzJlGqFTxFT/Irffra6QbrYdLSJU9w Fzr1hAS12FfxXpWKUZZVSGUczvoj6RBXUhn1twd5qjnhOG1egCvYvvhLXe5yGzMVCZk7 9Daw== 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=L7eckfF2Zrk2L2hw3XycylNkNnZH54URJARS3kpuRe8=; b=WR4gTykVWwJnkyvqgTsN5I7USU0Wae+NTgZfrwHqswIvwuLWot4uTp2sZs+/OIrEZS jrBTsj9TXu+nk3rPFu8WU83EzUKZ2TPwQ2fgJiZt3YkblKQQ1hkFFyTAwk0POFQKeY4K DzzHB1wcAroQHJcegS31wkgJrvOU+6PWN2fnPkWRkgPZvjyVJaHdpAA5udY+hbN1N3CO fnfwg1mNyd1Hf4H85GBzz1HRW9elJjulrRv6LLk8A2BJTUZS0gVj66wDpi5kZVIMRVhz FeQwoEEl/RHWj3rqY45Ze28yQEhK+0k6mzSyELMpUzY8WPWXA9ST/b/LZa0VKzpwyFyi /0wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BXYfPlRL; 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 d12si3937022pgf.470.2019.01.22.10.12.03; Tue, 22 Jan 2019 10:12:04 -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=BXYfPlRL; 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 S1726881AbfAVSMB (ORCPT + 27 others); Tue, 22 Jan 2019 13:12:01 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39883 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbfAVSL4 (ORCPT ); Tue, 22 Jan 2019 13:11:56 -0500 Received: by mail-pl1-f196.google.com with SMTP id 101so11852040pld.6 for ; Tue, 22 Jan 2019 10:11: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=L7eckfF2Zrk2L2hw3XycylNkNnZH54URJARS3kpuRe8=; b=BXYfPlRL/9ULQcWr54dC4Mv2z/oOD8AjTw4ZdXGJQ1iEcfPruZ0t2Ee5oxI2xeqkKQ zZuB9nQGg/x3AhZO/WvtTANu86lPvz3/+BEeNFID5LoCybqLtWt0rGH6WMxNgJ+x+iqp f/Q3rrcN9wAp5j9rzoUfwSKYkgFALFWt9zIgc= 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=L7eckfF2Zrk2L2hw3XycylNkNnZH54URJARS3kpuRe8=; b=sR/l8+D16rvwjkWQlb8uxUijApHSx3IyVVkRog4LH1XWkYD2RxpimJ91jhVFeUt2IJ K/OXRnWtf1NVEk1Nh12QSrOHpfxLETi7oX9AicDmKe3Au1+eyxBLaLpFd5FPrMyZOKI5 UOk2LykWsizQmLqPdGmBhJwyAgCjSxLEeelTtbzIMYOrppGT5NNDsnJJWu77RU96PUlL 5m2A1r7m5tBvjsqeLaoSX6sX+jgf4CUMBN/0RrEbUtSDFc1r2mg6b9wsEri9crfR2QO/ QDCy+DHjAsvWQtq5Q/EydLImBZZ9WtJdL5hux69kUjuhB+dIpGsNpgKnKLBoCWyMRZig FfJA== X-Gm-Message-State: AJcUukd2HuqU39Lt+E5TMstVrkgLtz4ErSd1rU3/75xiTyWWQpqWzGL2 kxDog9WREaoflh4yxiZDGcx59w== X-Received: by 2002:a17:902:f091:: with SMTP id go17mr35959173plb.235.1548180715665; Tue, 22 Jan 2019 10:11:55 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id a18sm23489919pgj.30.2019.01.22.10.11.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 10:11:55 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org Cc: gregkh@linuxfoundation.org, 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, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com Subject: [PATCH v2 5/7] perf tools: Use event attributes to send sink information to kernel Date: Tue, 22 Jan 2019 11:11:42 -0700 Message-Id: <20190122181144.26645-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190122181144.26645-1-mathieu.poirier@linaro.org> References: <20190122181144.26645-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 one 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);