From patchwork Thu Aug 4 16:53:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 73296 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1495752qga; Thu, 4 Aug 2016 09:56:59 -0700 (PDT) X-Received: by 10.67.3.164 with SMTP id bx4mr129750968pad.9.1470329819526; Thu, 04 Aug 2016 09:56:59 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ib2si5171322pad.209.2016.08.04.09.56.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 09:56:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bVLw5-0002Av-SL; Thu, 04 Aug 2016 16:55:57 +0000 Received: from mail-it0-x22f.google.com ([2607:f8b0:4001:c0b::22f]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bVLu7-0008RB-Me for linux-arm-kernel@lists.infradead.org; Thu, 04 Aug 2016 16:53:57 +0000 Received: by mail-it0-x22f.google.com with SMTP id j124so841190ith.1 for ; Thu, 04 Aug 2016 09:53:35 -0700 (PDT) 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=5cXCxshSZyi1hEHkz+yVbnH8h89Bjhv4AW+TfX3P9bU=; b=XjAi7Jh04XktYb4R+57Nfvig5f+V4F8jRB9dI5blWlwRH7evhitlgE+sAtPRR1olaZ 4KgCGpMUKicqlk1V7i96Q/ovoKLu53RLZPy7oGZhLIyEfpARqh0kiAtO7zFbxLFXtdVi RMtK9HU+baVtCcvtp/RORq9hutDaLrTzIgbLE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5cXCxshSZyi1hEHkz+yVbnH8h89Bjhv4AW+TfX3P9bU=; b=HvhgSBuPJAu36P/jCQknNWbnHJEU3sXjrjRhiXemxEKIuz8J54e+mIkNxacNN8yTqp Y/7rnfu7PQZ07yxHW0GVIsjAb9ihf9WQ8m+MhY9RfQrdwZHob2HxKjEBZL8rI7bGnoo+ W6xrqOGL5zj9faIp/oLj6GOBT2R+bdbF/LF+y6OhrGymfs5dl9nIofM/GDzo5whPWdVc w8SOyw6BZvoAgd+/66drXaVHm/Krnpc6RfPIuSbz5JCAl1oZQvuvjUlQA71mmZwctx7O L58PA3qUbQw9NJEmuvX7VSpNn+i1eP0X7AFbL/EXHWaSJeVdA0Q21kzWmyAhLMz5Zfdv y5LA== X-Gm-Message-State: AEkoouvWsvfgjn9Hl5vx80D3gB0mMVeREUEPf18jH9zfJnubflflxxqEwgDnsrt3XAgPnTfu X-Received: by 10.36.112.11 with SMTP id f11mr65115457itc.57.1470329614638; Thu, 04 Aug 2016 09:53:34 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id l19sm6117846iod.10.2016.08.04.09.53.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Aug 2016 09:53:34 -0700 (PDT) From: Mathieu Poirier To: acme@kernel.org, jolsa@kernel.org Subject: [PATCH V4 6/6] coresight: etm-perf: incorporating sink definition from cmd line Date: Thu, 4 Aug 2016 10:53:24 -0600 Message-Id: <1470329604-14356-7-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470329604-14356-1-git-send-email-mathieu.poirier@linaro.org> References: <1470329604-14356-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160804_095355_934958_E3789A47 X-CRM114-Status: GOOD ( 20.07 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:4001:c0b:0:0:0:22f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Now that PMU specific configuration is available as part of the event, lookup the sink identified by users from the perf command line and build a path from source to sink. With this functionality it is no longer required to select a sink in a separate step (from sysFS) before a perf trace session can be started. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-etm-perf.c | 101 ++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index f8c7a8733b23..5658a7411a66 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -71,11 +72,20 @@ static const struct attribute_group *etm_pmu_attr_groups[] = { static void etm_event_read(struct perf_event *event) {} +static void etm_event_destroy(struct perf_event *event) +{ + kfree(event->hw.drv_configs); + event->hw.drv_configs = NULL; +} + static int etm_event_init(struct perf_event *event) { if (event->attr.type != etm_pmu.type) return -ENOENT; + event->destroy = etm_event_destroy; + event->hw.drv_configs = NULL; + return 0; } @@ -159,6 +169,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, int nr_pages, bool overwrite) { int cpu; + char *cmdl_sink; cpumask_t *mask; struct coresight_device *sink; struct etm_event_data *event_data = NULL; @@ -171,6 +182,12 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, mask = &event_data->mask; + /* + * If a sink was specified from the perf cmdline it will be part of + * the event's drv_configs. + */ + cmdl_sink = (char *)event->hw.drv_configs; + /* Setup the path for each CPU in a trace session */ for_each_cpu(cpu, mask) { struct coresight_device *csdev; @@ -184,7 +201,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, * list of devices from source to sink that can be * referenced later when the path is actually needed. */ - event_data->path[cpu] = coresight_build_path(csdev, NULL); + event_data->path[cpu] = coresight_build_path(csdev, cmdl_sink); if (!event_data->path[cpu]) goto err; } @@ -342,6 +359,87 @@ static void etm_event_del(struct perf_event *event, int mode) etm_event_stop(event, PERF_EF_UPDATE); } +enum { + ETM_TOKEN_SINK_CPU, + ETM_TOKEN_SINK, + ETM_TOKEN_ERR, +}; + +static const match_table_t drv_cfg_tokens = { + {ETM_TOKEN_SINK_CPU, "sink=cpu%d:%s"}, + {ETM_TOKEN_SINK, "sink=%s"}, + {ETM_TOKEN_ERR, NULL}, +}; + +static int etm_set_drv_configs(struct perf_event *event, void __user *arg) +{ + char *config, *sink = NULL; + int cpu = -1, token, ret = 0; + substring_t args[MAX_OPT_ARGS]; + + /* Only one sink per event */ + if (event->hw.drv_configs != NULL) { + ret = -EINVAL; + goto err; + } + + /* Make user supplied input usable */ + config = strndup_user(arg, PAGE_SIZE); + if (IS_ERR(config)) { + ret = PTR_ERR(config); + goto err; + } + + /* See above declared @drv_cfg_tokens for the usable formats */ + token = match_token(config, drv_cfg_tokens, args); + switch (token) { + case ETM_TOKEN_SINK: + /* Just a sink has been specified */ + sink = match_strdup(&args[0]); + if (IS_ERR(sink)) { + ret = PTR_ERR(sink); + goto err; + } + break; + case ETM_TOKEN_SINK_CPU: + /* We have a sink and a CPU */ + + /* First get the cpu */ + if (match_int(&args[0], &cpu)) { + ret = -EINVAL; + goto err; + } + + /* Then the sink */ + sink = match_strdup(&args[1]); + if (IS_ERR(sink)) { + ret = PTR_ERR(sink); + goto err; + } + break; + default: + ret = -EINVAL; + goto err; + } + + /* + * If the CPUs don't match the sink is destined to another path. This + * isn't as an error hence not setting @ret. + */ + if (event->cpu != cpu) + goto err; + + /* We have a valid configuration */ + event->hw.drv_configs = sink; + +out: + return ret; + +err: + kfree(sink); + goto out; +} + int etm_perf_symlink(struct coresight_device *csdev, bool link) { char entry[sizeof("cpu9999999")]; @@ -383,6 +481,7 @@ static int __init etm_perf_init(void) etm_pmu.stop = etm_event_stop; etm_pmu.add = etm_event_add; etm_pmu.del = etm_event_del; + etm_pmu.set_drv_configs = etm_set_drv_configs; ret = perf_pmu_register(&etm_pmu, CORESIGHT_ETM_PMU_NAME, -1); if (ret == 0)