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: 10775909 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 425106C2 for ; Tue, 22 Jan 2019 18:13:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 302192B924 for ; Tue, 22 Jan 2019 18:13:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23DF72B9C2; Tue, 22 Jan 2019 18:13:44 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BB4C02B924 for ; Tue, 22 Jan 2019 18:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=FK1NZUI4yWjm18DrbpNA8zS7ijUd3t1n3dIYMI4djwE=; b=Wm1Z1WeJf+7cSe/tS9DJpNB3yr 47uFk9EJ2ztT1hIMfs+oCU+vVkPZRyyVwpxFQoEWGgmNFcSdTcbS0uqTncsUT9jTZ79xaaKKmTJZE Ftg8yWSpE4K1yrmpst6Y23WgwCgj9bsYUKzkafvJM1eK3uQdktRIq4+cyW72y/tm/zrKpbdMpC5am mwuQtbGNeyRCfqCVRDZaQjX/1k1eWPV4pqAWo1GmlixOUuiZBneF2MheP3Mj5Qccfbn7plKRuRF9V HIZGab7ddEJym0gJO4LTqmd1k0yxXFfI9qjwCgTSbcp4fNkjzELvA/guPSCoj8TL0zh4IkNR3in2H 6Rw8VmMQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gm0YQ-00069b-0p; Tue, 22 Jan 2019 18:13:42 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gm0Wi-0004LZ-6z for linux-arm-kernel@lists.infradead.org; Tue, 22 Jan 2019 18:12:05 +0000 Received: by mail-pl1-x642.google.com with SMTP id g9so11869568plo.3 for ; Tue, 22 Jan 2019 10:11:56 -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=JWrD4LR5JuyDreeS4D4QjFm43qIgUq8r+r/FY6+YFFhnGiwtXgJAK6IzNj4DnA6ZMS 29xj2LaVMygsYysRpPHawur8PDEAxtNOfwdklSKjGQSrZdyzUHxV9mt3l+Zq+BZTG091 4O4brnZWRJlMyp+fEUFysDSmmPUbv5X1f9YRnEwXtaRGnSPoFtoY06XsqbqY8kxnMK6D hm6SmLCeNKg8BUxvHefTkgLRPpYcGmNxeex2xS9G6+tx8Q6+AbzAIWL2jYIqi2/d3TZ/ Nhr6+RCUgSiiXAysNAvkOFPnEXnfmBUDriGt8oVslkTvCHr3Lkw0s4/fP40q0ymlxn1U Om3A== X-Gm-Message-State: AJcUukdpZnRxAzXC4t+USBAYfSBDIp2tQKDVjoU6z4mwrUCfz28hl5Ey YzETVi8bjvl4E/nrJsZ+rWHjXg== X-Google-Smtp-Source: ALg8bN50K9CCQUy91XGFFBkpnYXAI21ijsQ/W0uSghpC2CpGuirb++J5orUtFwY/BMG+xSDj49+OJg== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190122_101156_624471_405693CE X-CRM114-Status: GOOD ( 14.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, linux-s390@vger.kernel.org, suzuki.poulose@arm.com, alexander.shishkin@linux.intel.com, gregkh@linuxfoundation.org, heiko.carstens@de.ibm.com, adrian.hunter@intel.com, will.deacon@arm.com, ast@kernel.org, mingo@redhat.com, linux-arm-kernel@lists.infradead.org, hpa@zytor.com, schwidefsky@de.ibm.com, namhyung@kernel.org, tglx@linutronix.de, jolsa@redhat.com, linux-kernel@vger.kernel.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 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(+) 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);