From patchwork Wed Feb 6 18:48:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 157657 Delivered-To: patch@linaro.org Received: by 2002:ac9:7558:0:0:0:0:0 with SMTP id r24csp6437458oct; Wed, 6 Feb 2019 10:50:35 -0800 (PST) X-Google-Smtp-Source: AHgI3IbJitYx5m3h8gjSuEEooNu4LKXKsp1VgV3W79E31J5QYxVn+VC/cGLRFhW9MvTzj/dgl4s8 X-Received: by 2002:a62:2547:: with SMTP id l68mr11773863pfl.131.1549479035631; Wed, 06 Feb 2019 10:50:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549479035; cv=none; d=google.com; s=arc-20160816; b=Y6dua6vwNmCo2z2iURk28UEaI8EAZepIyXVzns7XlNv3bZk+PNmA5ajFeM0qqshB/o 9/E7bmTm3jDEtl+n8p5IhnLsj9drsDeG49wGWk8RD9qbo0USc5/cBNp18A0mIkFiMdfh 4cB4XXCOE+dIWl1hcUxWQm+N7F1ZJ/KVuKoPoLRE6okl+FcFhdHDxcTVV43wwCaeu096 y6uJKxcRUh+XO/MCVsoBMkBHSXZIsbVLdQqcVO6Wg01f9Wd5A77QkbFUJakOoZOx6iUk krzAju1NRSV2aJf9rFaJlYc9kElqPT1/toToz7NHaR7fKEW3lXcOYwNUiIJ8kMgjE1lc Tn7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xG8UFAWZX8T8/9pTQDQ5ATzvIzFWd3mHIYwUkVZP0c0=; b=znrOhsbCcvXH/WoJ2wprfhCcr37QLaIjAhXOX4x1jCVy+lsCDejYEVj6GErsF0e3zx mcVK+XFYHDGMGey63zJ2O04FBN6d8Y5fTIxxb6aMIhUvhw/SPhJvSzPUWHZ+v9J1p9CS G58rIdAN6253VIXRIE4lkcmrz+MzVk9dwtkba974DwmtURe4RBK4/Z9d9XJQ81nxQ0GS T3VHFPcS6irazIJtazAAntpIQmUJ5bdfeVPDHxmrnlYIAhLO86ox8Z1WwME6s3NClqXn Uz03y1iFcgle+UZ+ybokkktJEdNBTx+vS78nQp83ohkk+WJEY09H90bwNTJ6dlyShLDL VyPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ff4z7pC7; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si4220078pgq.310.2019.02.06.10.50.35; Wed, 06 Feb 2019 10:50:35 -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=@kernel.org header.s=default header.b=Ff4z7pC7; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727654AbfBFSud (ORCPT + 31 others); Wed, 6 Feb 2019 13:50:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:44788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727532AbfBFSub (ORCPT ); Wed, 6 Feb 2019 13:50:31 -0500 Received: from quaco.ghostprotocols.net (unknown [179.97.41.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BAC23218B0; Wed, 6 Feb 2019 18:50:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549479030; bh=pI53blAe3kiE+V6T5S4GLEI9yiUKCwBVRmFf0b6kdK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ff4z7pC77EbgNPC7pQXf/QONfSIVjXsb5hpfN/t9jfo9sAlKLmSIHzc8hkXdRfClZ uTfzX2KcPh/PoKca3THyI04Hgx2P/RdMTHx1l78ew0XrcgMo9DuASD7V16yMOE8eIG LAxwenx+AF+2faiF5E/fKbdEX1Gb+Fgs8yx0PRhA= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Mathieu Poirier , Suzuki K Poulouse , Adrian Hunter , Alexander Shishkin , Alexei Starovoitov , Greg Kroah-Hartman , "H . Peter Anvin" , Heiko Carstens , Jiri Olsa , Mark Rutland , Martin Schwidefsky , Peter Zijlstra , Thomas Gleixner , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, Arnaldo Carvalho de Melo Subject: [PATCH 24/53] perf arm cs-etm: Use event attributes to send sink information to kernel Date: Wed, 6 Feb 2019 15:48:34 -0300 Message-Id: <20190206184903.24054-25-acme@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190206184903.24054-1-acme@kernel.org> References: <20190206184903.24054-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Poirier 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 Acked-by: Suzuki K Poulouse Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Alexei Starovoitov Cc: Greg Kroah-Hartman Cc: H. Peter Anvin Cc: Heiko Carstens Cc: Jiri Olsa Cc: Mark Rutland Cc: Martin Schwidefsky Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Cc: linux-s390@vger.kernel.org Link: http://lkml.kernel.org/r/20190131184714.20388-6-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm/util/cs-etm.c | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) -- 2.20.1 diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 2f595cd73da6..4f31cf0d1e6d 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -22,6 +23,7 @@ #include "../../util/thread_map.h" #include "../../util/cs-etm.h" +#include #include #include @@ -60,10 +62,48 @@ 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; + + if (evsel->attr.config2 & GENMASK(31, 0)) + return 0; + + 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 |= 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 +132,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);