From patchwork Thu Jan 31 18:47:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 157153 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7555181jaa; Thu, 31 Jan 2019 10:47:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN7VZ2rKmWt1B49/+ci9gSydxA54H7X7xDsYXNrB3NSOQ3J7ovufJ/O4e/7pDVMAJnj+aN71 X-Received: by 2002:a62:931a:: with SMTP id b26mr37531817pfe.65.1548960458585; Thu, 31 Jan 2019 10:47:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548960458; cv=none; d=google.com; s=arc-20160816; b=bRWh1lCCcJBUu74wrWSF9fWRmOvIQSOdNphTbmHod37YlqPCIXMwsd/pORwej3aaEy T7BmGvhIRW9EfKZjm+yuIeRxbScb6SP1KoC6LNijDYgtQEJev4bt6YpRYBvHtpZhvLHq F/EbtJlQ2kBC7OtE/ZWYGeCz/TNd5Bm/VoKlwqP61k7NUFEPlsYpYIK6ZHvIyINapnwQ 50sGFwh8jRrgaPm50qk/9/zhxFYnAfGdUDM6RIQ2Bg6pSNQ6MS+XrlW8jattmYmR65z+ 60qKYBtwwVZfgoz2OT9jREvUTM82Xsqnd1DtChgo1pB8rr4JRvI0rBOniZZC4WWkZLIp HlNA== 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=bRWUwYnj28kBvbJLtyjNHTdBWqKDkbKXjpXnSK8ue0c=; b=srwFqGVVMK9TbSnrzJCjAxrGhrLZla0KoXIuMjXhIPOYwC8m0VjqPyIBn/OmmvK0dr t70R4FZQcjQX8lv4soipSs0/S+o2wC+prGU8r5iUrvRwlutyhtgNzv0/T2aEw0jY5+iO ipSwlMhZU3UpeylWTmyPDlUhMHD5jp1r6l0fsV+Ncs3wY6bYnfRmrird/Cn8hfs70zWS //jBpEjdUq6do1zhbiL4t4w2MVIMnGCY/ZRMh3ZAjHhoulw9tKmhkd0eU4/4qnkLOLgU ndSCGA2krUkAdWHlQ5PsJScG6ehc8XKvh5pYDmvyGo4WfJkc8QoD7Ee7b1uNKOHcQHht TCtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="dKYMv/vV"; 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 u28si4889340pgn.436.2019.01.31.10.47.38; Thu, 31 Jan 2019 10:47:38 -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="dKYMv/vV"; 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 S1728239AbfAaSrb (ORCPT + 31 others); Thu, 31 Jan 2019 13:47:31 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:37695 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728147AbfAaSr0 (ORCPT ); Thu, 31 Jan 2019 13:47:26 -0500 Received: by mail-pl1-f194.google.com with SMTP id b5so1882192plr.4 for ; Thu, 31 Jan 2019 10:47:25 -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=bRWUwYnj28kBvbJLtyjNHTdBWqKDkbKXjpXnSK8ue0c=; b=dKYMv/vVYjuiSgre0jRV1GEM0M8C+cEcETL2BWXZTHSoZiQ2SEBsPqSDRsCr6Kw8i8 2JqPlL+ehsAS6kHAuDvFUkBhGrI/ScPCk3OTLiTA7lA6IIn2SZcJrNcOvWrK7oqKNSoN aDTrlc5k9W6W1uUmX+BIemad6qq/WMVyMiTd0= 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=bRWUwYnj28kBvbJLtyjNHTdBWqKDkbKXjpXnSK8ue0c=; b=c5ZroRUBddUnx2425ET+PiVbjNl+rtDRsQp1yYBGNipIxsFGC1jl6cdpFed4RQBt2K Wi+Fe3O5VmtDHxzrktH/jq329C6lSEM7P+3DXuopFggsv3NenRKLR+EI0Ck08q8GKnVA suWnMTbhZZSTmmahmZKoxhhSKEgYPUU3ni5ppqbw8KAC524l8B4DriD+ON/KpQFPHYE+ F53OzkkXXNIbj2XBO372u6ujQSo0nEYnlKFhRCEOSJ/zJo1ZOGygC4pwqUEyitXuNmpI ga7iH6LBPn/a3uYuNXg8cPnXWxaG3AgB2UL3Ri/yq69nhTfqnPIzoLGbmMxismXV/IhS DEcg== X-Gm-Message-State: AJcUuke5aLxPEBWvC6+rBMH+BnRG/8wbJD1T7NlDdoI6JX9vBm6oSu66 Y5Lx1EfRGDnaQZZXy7H5qLmKlA== X-Received: by 2002:a17:902:28e6:: with SMTP id f93mr35604380plb.239.1548960445634; Thu, 31 Jan 2019 10:47:25 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o66sm6236234pgo.75.2019.01.31.10.47.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 10:47:24 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org Cc: suzuki.poulose@arm.com, 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 Subject: [PATCH v3 5/7] perf tools: Use event attributes to send sink information to kernel Date: Thu, 31 Jan 2019 11:47:12 -0700 Message-Id: <20190131184714.20388-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190131184714.20388-1-mathieu.poirier@linaro.org> References: <20190131184714.20388-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 | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 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..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);