From patchwork Thu Jan 31 18:47:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 157156 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7555504jaa; Thu, 31 Jan 2019 10:47:58 -0800 (PST) X-Google-Smtp-Source: ALg8bN7HKvzK4JTvCnpsFbJ6bvlA5Y+eHCPkUAmRXOFldpnrc/bmNFN5n1HHihIDu5E9/cLGzyAk X-Received: by 2002:a17:902:f24:: with SMTP id 33mr36306025ply.65.1548960478703; Thu, 31 Jan 2019 10:47:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548960478; cv=none; d=google.com; s=arc-20160816; b=QBKyl5G8Hj/PU/opjOuTqMUKP8fW2x2CyPM/qSdTkvbMdh37w85fpCqXv6cQ5MzYlJ 4wKjMIJxF5+OnIS/ITzLECApbZ42bo9dD2qFBzZKNa1MbQe8trhDxXTubtqZjjnqjZ39 T9mRGWXP2O0m36AMdrczTyAUsdzesUxCHSgj6jBPq341vKS+uTH7dXl73x58PGrfstXl xueDaC2bGLVVb+6l0lf4Dx7oD9458ax5xvkxlZpdSkArE5NPC9VO4wlBtBOYu5UbMXh6 tmrC6Ab2ZsAss802DInRZsSr+qZYYtqQeW70TiloKHEYtS7uV72GpoP6B7h40UsBe0of YUAQ== 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=MDOVaEZRoG9B5WvSdx3N1/m5BAdIo/VwcdxFaAGLjXA=; b=zJu/bfCyiNcsHHglSos0A3DjkafWPnd4K37P9A1xbzovH/1Ym2NIAhbFEIPnZAXsRl 5J2DUk+NonjUeMl8CyHJIIRMNrv93H88UMlnd5uXZsKsgHMFuzk3uOdFjiumYpH83T2c fdq131QIlKbZlX8eDtgad7GEjJgS3cJQaKqixPa4J5tqN2Mg1CCv3DCkmLKkMUMUR3sA n8VnWxBS4imL5vcB/FF25itYN8LDhECqY5YKJ9HhOXhK1t9CfCed5OflO3n4pwKb9tOm yITh3YbKMRMdT5kr2Rj1P083DTJ40OMjJA06vYaPYbN6yh553DqQ3qhN9TDJpNRvLJHP xAOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BJKZnQ+p; 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 ca6si5791885plb.141.2019.01.31.10.47.58; Thu, 31 Jan 2019 10:47:58 -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=BJKZnQ+p; 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 S1728059AbfAaSrX (ORCPT + 31 others); Thu, 31 Jan 2019 13:47:23 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37687 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726256AbfAaSrT (ORCPT ); Thu, 31 Jan 2019 13:47:19 -0500 Received: by mail-pl1-f196.google.com with SMTP id b5so1882055plr.4 for ; Thu, 31 Jan 2019 10:47:19 -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=MDOVaEZRoG9B5WvSdx3N1/m5BAdIo/VwcdxFaAGLjXA=; b=BJKZnQ+p0uBUVj3n7icarSryaTOKTRasioqWRPgu+TOzelrnbg1R0SAw9L0i0x8xTa /UehSgEvaBqDDKe6qMaqPktktwAZy+gZHHqJn/FQHxag2SnXa6+QrAmyrT8wRSW6NMwy hlQftDB6KkRCdIrT/gYfa1IwVnANf6ApHPY/g= 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=MDOVaEZRoG9B5WvSdx3N1/m5BAdIo/VwcdxFaAGLjXA=; b=XVEEb71/nJBNYw40J6Ehl6jc7bYk4+gLDBJaZRvWmlxeqINJcX3vzbum0KmLqntejr RCsL2SI+1gxWtK8HV+WeToViag3IQQK+qo6pULFBsPHsw9sjGFwzY+u6k5Es0wOgDN2Z Sylo91pS4jUxxFYK2nKmERJGi4bgnhSoPKJM9bRy3xBWsMQ4Q9zOGOujIngZRYhie/i+ jO1lVD7XwF6R4/tJ/fUOpJ5/HsvBB4QK8zqtarVZcDCNggvf2hDqMd2gPaSiVqY8RdbH YDtkk+vY0LroVpUOG9J2bOPzkNZ71afy0hDcO5kO1TaGnXJvXW3U9TOiDy0nGJQZlH5N 2lqw== X-Gm-Message-State: AJcUukcsfPMhvSu8/gOki9afAtwVm9UuF5hajiY3QQNrlbgnncwxArCt /vaoMuFBumZy7sdNsi1PWRxbeg== X-Received: by 2002:a17:902:7d90:: with SMTP id a16mr34489495plm.249.1548960438825; Thu, 31 Jan 2019 10:47:18 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 10:47:18 -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 1/7] perf/aux: Make perf_event accessible to setup_aux() Date: Thu, 31 Jan 2019 11:47:08 -0700 Message-Id: <20190131184714.20388-2-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 When pmu::setup_aux() is called the coresight PMU needs to know which sink to use for the session by looking up the information in the event's attr::config2 field. As such simply replace the cpu information by the complete perf_event structure and change all affected customers. Signed-off-by: Mathieu Poirier Reviewed-by: Suzuki K Poulose Acked-by: Peter Zijlstra (Intel) --- arch/s390/kernel/perf_cpum_sf.c | 6 +++--- arch/x86/events/intel/bts.c | 4 +++- arch/x86/events/intel/pt.c | 5 +++-- drivers/hwtracing/coresight/coresight-etm-perf.c | 6 +++--- drivers/perf/arm_spe_pmu.c | 6 +++--- include/linux/perf_event.h | 2 +- kernel/events/ring_buffer.c | 2 +- 7 files changed, 17 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c index bfabeb1889cc..1266194afb02 100644 --- a/arch/s390/kernel/perf_cpum_sf.c +++ b/arch/s390/kernel/perf_cpum_sf.c @@ -1600,7 +1600,7 @@ static void aux_sdb_init(unsigned long sdb) /* * aux_buffer_setup() - Setup AUX buffer for diagnostic mode sampling - * @cpu: On which to allocate, -1 means current + * @event: Event the buffer is setup for, event->cpu == -1 means current * @pages: Array of pointers to buffer pages passed from perf core * @nr_pages: Total pages * @snapshot: Flag for snapshot mode @@ -1612,8 +1612,8 @@ static void aux_sdb_init(unsigned long sdb) * * Return the private AUX buffer structure if success or NULL if fails. */ -static void *aux_buffer_setup(int cpu, void **pages, int nr_pages, - bool snapshot) +static void *aux_buffer_setup(struct perf_event *event, void **pages, + int nr_pages, bool snapshot) { struct sf_buffer *sfb; struct aux_buffer *aux; diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c index a01ef1b0f883..7cdd7b13bbda 100644 --- a/arch/x86/events/intel/bts.c +++ b/arch/x86/events/intel/bts.c @@ -77,10 +77,12 @@ static size_t buf_size(struct page *page) } static void * -bts_buffer_setup_aux(int cpu, void **pages, int nr_pages, bool overwrite) +bts_buffer_setup_aux(struct perf_event *event, void **pages, + int nr_pages, bool overwrite) { struct bts_buffer *buf; struct page *page; + int cpu = event->cpu; int node = (cpu == -1) ? cpu : cpu_to_node(cpu); unsigned long offset; size_t size = nr_pages << PAGE_SHIFT; diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c index 9494ca68fd9d..c0e86ff21f81 100644 --- a/arch/x86/events/intel/pt.c +++ b/arch/x86/events/intel/pt.c @@ -1114,10 +1114,11 @@ static int pt_buffer_init_topa(struct pt_buffer *buf, unsigned long nr_pages, * Return: Our private PT buffer structure. */ static void * -pt_buffer_setup_aux(int cpu, void **pages, int nr_pages, bool snapshot) +pt_buffer_setup_aux(struct perf_event *event, void **pages, + int nr_pages, bool snapshot) { struct pt_buffer *buf; - int node, ret; + int node, ret, cpu = event->cpu; if (!nr_pages) return NULL; diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index abe8249b893b..f21eb28b6782 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -177,15 +177,15 @@ static void etm_free_aux(void *data) schedule_work(&event_data->work); } -static void *etm_setup_aux(int event_cpu, void **pages, +static void *etm_setup_aux(struct perf_event *event, void **pages, int nr_pages, bool overwrite) { - int cpu; + int cpu = event->cpu; cpumask_t *mask; struct coresight_device *sink; struct etm_event_data *event_data = NULL; - event_data = alloc_event_data(event_cpu); + event_data = alloc_event_data(cpu); if (!event_data) return NULL; INIT_WORK(&event_data->work, free_event_data); diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 8e46a9dad2fa..7cb766dafe85 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -824,10 +824,10 @@ static void arm_spe_pmu_read(struct perf_event *event) { } -static void *arm_spe_pmu_setup_aux(int cpu, void **pages, int nr_pages, - bool snapshot) +static void *arm_spe_pmu_setup_aux(struct perf_event *event, void **pages, + int nr_pages, bool snapshot) { - int i; + int i, cpu = event->cpu; struct page **pglist; struct arm_spe_pmu_buf *buf; diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 1d5c551a5add..3e49b2144808 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -409,7 +409,7 @@ struct pmu { /* * Set up pmu-private data structures for an AUX area */ - void *(*setup_aux) (int cpu, void **pages, + void *(*setup_aux) (struct perf_event *event, void **pages, int nr_pages, bool overwrite); /* optional */ diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index 4a9937076331..857308295f63 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -658,7 +658,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event, goto out; } - rb->aux_priv = event->pmu->setup_aux(event->cpu, rb->aux_pages, nr_pages, + rb->aux_priv = event->pmu->setup_aux(event, rb->aux_pages, nr_pages, overwrite); if (!rb->aux_priv) goto out; From patchwork Thu Jan 31 18:47:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 157151 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7554998jaa; Thu, 31 Jan 2019 10:47:27 -0800 (PST) X-Google-Smtp-Source: ALg8bN4SgJ0e+XaR0rmCSlP0SmghXqqyetn8QhDzCBpmoKwqYFfVz8dMlZAGSknJEUoLmnHNjica X-Received: by 2002:a63:2849:: with SMTP id o70mr25612168pgo.155.1548960447214; Thu, 31 Jan 2019 10:47:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548960447; cv=none; d=google.com; s=arc-20160816; b=o3YIGQg0Y7jtfMiZFDN1TcqF9na6aRnYUKNLejiZLabhBkEt6l8WvQsrrZubH3gNmv VpTNuStVfDihcSPA9wSYIKuqAXK81HxYRNynlk7RI0gnhZTh/nlTaMR9ERvfhhwV/fMW UuNnkDM3N4wwWAVzi4xiV7tXBVuebTNYhKE1fGSRkYZw19VzdFkkyu3n2at0LNlXYbkI ImAQETtgX/f6ANlOaeBApir00GiFr+JIyAVwn169ZyxdyRczI7oV7MhtH14CeAtGl6qa lRLKhlToeYpsWi8gTpTqEoJJNbikWzjZPvnZ0HLDwl/ZJ9vm9bPR8cnpB3UVL7jQ1XGp ejnA== 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=Rjjbf1cJmQIDlEdQ4qHOJVKfCfY0jcPvMsMFKc7BZ/0=; b=XXI6bXGbvd6Rk5hNowVfkMTo9+jxC6xyyDCv74wBRx63pt6+STxJ19eC7dqfWyhKSn TiKF8Z8yRfxrPtKyk6NEQlg9X6Ks0gZdh9mbV3+gALb2vZXJZI98brW885+xLu/rjnNm 5fhiYjW0FID14l4HJdKTTYZUnU+7Mvad0csajjHefcjF7SFTu7N8OqQ0sk8ZeeEqtWDK nBDe5QmWOOymBIt3tmu5H56nUdBkBhShr+iv4desGaui8hL4131ZB/h4mXS1r7Ng/9kH l1SHp/jWiVUNh45sWR56nsrTR7M1rwihc7/2Kd0KizmI/FEVcE6IN0Qs7YXBqwQgPwK3 4njQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KyQeZo75; 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 j17si5227788pfd.113.2019.01.31.10.47.26; Thu, 31 Jan 2019 10:47:27 -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=KyQeZo75; 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 S1728139AbfAaSrY (ORCPT + 31 others); Thu, 31 Jan 2019 13:47:24 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:35696 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727971AbfAaSrV (ORCPT ); Thu, 31 Jan 2019 13:47:21 -0500 Received: by mail-pl1-f193.google.com with SMTP id p8so1885044plo.2 for ; Thu, 31 Jan 2019 10:47:20 -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=Rjjbf1cJmQIDlEdQ4qHOJVKfCfY0jcPvMsMFKc7BZ/0=; b=KyQeZo75idh6wUbOc+sIJDT1YPbQqSNmrhOGowHaaNrE+ksuGpHKu8E7RmlhnTJS7y VrVVfqaDpFD45hUS4JIC7rsgDfsQcseS3jd4gV/+lAdYA4ImbK1QKX+Bc7pJNiMMM4yX uantuxUhrXy1FrDJfUxi+fVBiv1b5u2DDYRO8= 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=Rjjbf1cJmQIDlEdQ4qHOJVKfCfY0jcPvMsMFKc7BZ/0=; b=nT8CZZp90rBV6B6mwDLpzvPsF0AUz8HhW313UCZrPuMzRWGI4DJpO7Q9dFyUAP2rBj ZAi4PC/DSC6zpT7fNsD19EOAR12IxJ+CQxx5xhiAAbBTKobyjU72TD+gcmL4dtWEGov4 EviDU0k1JGMkPfB7cnwuRJSBYg+6K3Jx/E8CfX6R9MMJt/s/uTgfEUxt4JYAR7s6JR9V DZB7AvnyYTI7DgtfmxFdLCZqUgZ6/krZyxCA0ahuNMQpl/db3vfpUi0s6YdCZRGUDbJA P8DTdH7JreFJos1wGHQ4I7wixFdIZnnr8MZJKw7dLBV3EmRmVy0dKxPn0mbXaEFTZFMc K1ww== X-Gm-Message-State: AJcUukc22VTxYUOMgghEIh+80LxyO+NG8afabeZvAhp74fsxc9J2vUhr qwGh12uSnT49DfWN15gW3UfbHg== X-Received: by 2002:a17:902:ac8f:: with SMTP id h15mr34795790plr.245.1548960440532; Thu, 31 Jan 2019 10:47:20 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 10:47:19 -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 2/7] coresight: perf: Add "sinks" group to PMU directory Date: Thu, 31 Jan 2019 11:47:09 -0700 Message-Id: <20190131184714.20388-3-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 Add a "sinks" directory entry so that users can see all the sinks available in the system in a single place. Individual sink are added as they are registered with the coresight bus. Signed-off-by: Mathieu Poirier Acked-by: Peter Zijlstra (Intel) --- .../hwtracing/coresight/coresight-etm-perf.c | 82 +++++++++++++++++++ .../hwtracing/coresight/coresight-etm-perf.h | 6 +- drivers/hwtracing/coresight/coresight.c | 18 ++++ include/linux/coresight.h | 7 +- 4 files changed, 110 insertions(+), 3 deletions(-) -- 2.17.1 Reviewed-by: Suzuki K Poulose diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index f21eb28b6782..cdbdb28dc175 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -43,8 +44,18 @@ static const struct attribute_group etm_pmu_format_group = { .attrs = etm_config_formats_attr, }; +static struct attribute *etm_config_sinks_attr[] = { + NULL, +}; + +static const struct attribute_group etm_pmu_sinks_group = { + .name = "sinks", + .attrs = etm_config_sinks_attr, +}; + static const struct attribute_group *etm_pmu_attr_groups[] = { &etm_pmu_format_group, + &etm_pmu_sinks_group, NULL, }; @@ -479,6 +490,77 @@ int etm_perf_symlink(struct coresight_device *csdev, bool link) return 0; } +static ssize_t etm_perf_sink_name_show(struct device *dev, + struct device_attribute *dattr, + char *buf) +{ + struct dev_ext_attribute *ea; + + ea = container_of(dattr, struct dev_ext_attribute, attr); + return scnprintf(buf, PAGE_SIZE, "0x%lx\n", (unsigned long)(ea->var)); +} + +int etm_perf_add_symlink_sink(struct coresight_device *csdev) +{ + int ret; + unsigned long hash; + const char *name; + struct device *pmu_dev = etm_pmu.dev; + struct device *pdev = csdev->dev.parent; + struct dev_ext_attribute *ea; + + if (csdev->type != CORESIGHT_DEV_TYPE_SINK && + csdev->type != CORESIGHT_DEV_TYPE_LINKSINK) + return -EINVAL; + + if (csdev->ea != NULL) + return -EINVAL; + + if (!etm_perf_up) + return -EPROBE_DEFER; + + ea = devm_kzalloc(pdev, sizeof(*ea), GFP_KERNEL); + if (!ea) + return -ENOMEM; + + name = dev_name(pdev); + /* See function coresight_get_sink_by_id() to know where this is used */ + hash = hashlen_hash(hashlen_string(NULL, name)); + + ea->attr.attr.name = devm_kstrdup(pdev, name, GFP_KERNEL); + if (!ea->attr.attr.name) + return -ENOMEM; + + ea->attr.attr.mode = 0444; + ea->attr.show = etm_perf_sink_name_show; + ea->var = (unsigned long *)hash; + + ret = sysfs_add_file_to_group(&pmu_dev->kobj, + &ea->attr.attr, "sinks"); + + if (!ret) + csdev->ea = ea; + + return ret; +} + +void etm_perf_del_symlink_sink(struct coresight_device *csdev) +{ + struct device *pmu_dev = etm_pmu.dev; + struct dev_ext_attribute *ea = csdev->ea; + + if (csdev->type != CORESIGHT_DEV_TYPE_SINK && + csdev->type != CORESIGHT_DEV_TYPE_LINKSINK) + return; + + if (!ea) + return; + + sysfs_remove_file_from_group(&pmu_dev->kobj, + &ea->attr.attr, "sinks"); + csdev->ea = NULL; +} + static int __init etm_perf_init(void) { int ret; diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwtracing/coresight/coresight-etm-perf.h index da7d9336a15c..015213abe00a 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.h +++ b/drivers/hwtracing/coresight/coresight-etm-perf.h @@ -59,6 +59,8 @@ struct etm_event_data { #ifdef CONFIG_CORESIGHT int etm_perf_symlink(struct coresight_device *csdev, bool link); +int etm_perf_add_symlink_sink(struct coresight_device *csdev); +void etm_perf_del_symlink_sink(struct coresight_device *csdev); static inline void *etm_perf_sink_config(struct perf_output_handle *handle) { struct etm_event_data *data = perf_get_aux(handle); @@ -70,7 +72,9 @@ static inline void *etm_perf_sink_config(struct perf_output_handle *handle) #else static inline int etm_perf_symlink(struct coresight_device *csdev, bool link) { return -EINVAL; } - +int etm_perf_add_symlink_sink(struct coresight_device *csdev) +{ return -EINVAL; } +void etm_perf_del_symlink_sink(struct coresight_device *csdev) {} static inline void *etm_perf_sink_config(struct perf_output_handle *handle) { return NULL; diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 2b0df1a0a8df..d7fa90be6f42 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -18,6 +18,7 @@ #include #include +#include "coresight-etm-perf.h" #include "coresight-priv.h" static DEFINE_MUTEX(coresight_mutex); @@ -1167,6 +1168,22 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) goto err_out; } + if (csdev->type == CORESIGHT_DEV_TYPE_SINK || + csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) { + ret = etm_perf_add_symlink_sink(csdev); + + if (ret) { + device_unregister(&csdev->dev); + /* + * As with the above, all resources are free'd + * explicitly via coresight_device_release() triggered + * from put_device(), which is in turn called from + * function device_unregister(). + */ + goto err_out; + } + } + mutex_lock(&coresight_mutex); coresight_fixup_device_conns(csdev); @@ -1185,6 +1202,7 @@ EXPORT_SYMBOL_GPL(coresight_register); void coresight_unregister(struct coresight_device *csdev) { + etm_perf_del_symlink_sink(csdev); /* Remove references of that device in the topology */ coresight_remove_conns(csdev); device_unregister(&csdev->dev); diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 46c67a764877..7b87965f7a65 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -154,8 +154,9 @@ struct coresight_connection { * @orphan: true if the component has connections that haven't been linked. * @enable: 'true' if component is currently part of an active path. * @activated: 'true' only if a _sink_ has been activated. A sink can be - activated but not yet enabled. Enabling for a _sink_ - happens when a source has been selected for that it. + * activated but not yet enabled. Enabling for a _sink_ + * appens when a source has been selected for that it. + * @ea: Device attribute for sink representation under PMU directory. */ struct coresight_device { struct coresight_connection *conns; @@ -168,7 +169,9 @@ struct coresight_device { atomic_t *refcnt; bool orphan; bool enable; /* true only if configured as part of a path */ + /* sink specific fields */ bool activated; /* true only if a sink is part of a path */ + struct dev_ext_attribute *ea; }; #define to_coresight_device(d) container_of(d, struct coresight_device, dev) From patchwork Thu Jan 31 18:47:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 157157 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7555578jaa; Thu, 31 Jan 2019 10:48:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN7HpEIEMngm9hBzzr7bx0fweXlQ7rLGKMT7yPSvaEpc/xcecetLo4oGmP04xKzsdp+vG5nM X-Received: by 2002:a63:c503:: with SMTP id f3mr31673736pgd.431.1548960483722; Thu, 31 Jan 2019 10:48:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548960483; cv=none; d=google.com; s=arc-20160816; b=V1/hO+VpuzXKzUHfCbL16t4tvvdiiNkoML/Cmp/d+AjekIHp2S3T2uTgIIJQDTO0xk gtEWp7J54onUImqdlCTakQ0/83lym2bIsXrbiJW04jNgP1te0gaggrs6NNCKQxGT9VM+ UcMYUpHGHz4x9JK6XGDGLgMohGU05t1y11bNGjFbAE4TEUMiMmiYXZYTjgkypCfnj1y6 sEmRf2DNsfdG1MJa/x45Q5GRJX0iswIbYU+kK8c2R97qfLTxD7JU5IGQlKw/zYNWviko YhojYXINH+iilieGRz/GfdWa/uf08uOiTb04z7wzCi+oj1aXwmu3YHl0ZcAX+G2wQ7BB 9EPA== 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=tD8VufzCQvXfpsNw9V8Ef8mQcXE6LoxMXAqIMu2r4YI=; b=Q0FKSAuSAjgWPlmR4G5xyuzXXUFSSTQdKPkdUeyRezboltYcCRFNTiwOqjv5H/7g8r KboaaG/UyrEM5MeUFkrTNZ5A4P1QK/tcX+ZaTfRu4OnVJIVdqoiHyGU8otWTPtPrdIDa BlFLKWN3hS1savNI77qnV2qa/q8ZUIKeyB0I7woBL1aitrHHv1CnfyF9KkyKGlKm9jC6 Z3HPNfklY0+9hK8kU4qjLoEBsUJggUXmvev0gEbWMjS7TSAPH+9JdAGIcuiBaRkZ26gO Se/rCihCX/ikmBWBxnWrKew2AByDgWevX8I/ZU5MzawEWO2edvEeE7mrRcWoh7MTOwse f5CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="O/cMZ4kF"; 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 a12si4875844pgk.291.2019.01.31.10.48.03; Thu, 31 Jan 2019 10:48:03 -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="O/cMZ4kF"; 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 S1728382AbfAaSsB (ORCPT + 31 others); Thu, 31 Jan 2019 13:48:01 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:32924 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728023AbfAaSrW (ORCPT ); Thu, 31 Jan 2019 13:47:22 -0500 Received: by mail-pl1-f195.google.com with SMTP id z23so1887533plo.0 for ; Thu, 31 Jan 2019 10:47:22 -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=tD8VufzCQvXfpsNw9V8Ef8mQcXE6LoxMXAqIMu2r4YI=; b=O/cMZ4kFAEzugVfW5UYIgT1/I/zv4JLH104R0wQ1gsXAXU5RhwbdA9LKMIAoIKnYAz /KLU3bYxUv+vCI6WUo6wQbwU98HvfCdtZQzIOLwQyDR/RN13vCAPAV5hltWpR8guGeEt U3IoWo3cpUj1u0kvgVo9FhoeWBQXf/MCZ6vTM= 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=tD8VufzCQvXfpsNw9V8Ef8mQcXE6LoxMXAqIMu2r4YI=; b=UfyZw9UkMZ9+jhFsAIMppSGP+8jyvMCiyblITl8rcXKcbpbTgwGflA+TwFzEmhg6US agFX586W4wqd84AQF5b08Gdz66IRxxlKopaj8LfI85IM5xmfPm7hkjZ9o3/H33Nt806R 0ABrHb/a/FBsjyO58lMOLO+KUky5OCuX3rL2/aPVoFITshmj8SRvz4P8HGMHBWBlAI++ fcMiQhk+7n1AxVWIXUAU3D/gpPszgSNZI4F+b1kzlw4mQLh5fW0I/502lT3FG9n/Xcfz Hr8phYyyL+B4DRQQifwZpyLtxvYOP3R2LWzF1mwRTbfmwpme6aY8sMBS/3KCbhACQN5f CBhw== X-Gm-Message-State: AJcUukdtKgR95I91H6ZHRdMJLezB6GuGoXQ48Kh73pvdWz747A8NfCSU pXYd9SuY9oJo/NzyoyhIfTUTIQ== X-Received: by 2002:a17:902:ab84:: with SMTP id f4mr35168544plr.207.1548960442170; Thu, 31 Jan 2019 10:47:22 -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.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 10:47:21 -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 3/7] coresight: Use event attributes for sink selection Date: Thu, 31 Jan 2019 11:47:10 -0700 Message-Id: <20190131184714.20388-4-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 This patch uses the information conveyed by perf_event::attr::config2 to select a sink to use for the session. That way a sink can easily be selected to be used by more than one source, something that isn't currently possible with the sysfs implementation. Signed-off-by: Mathieu Poirier Acked-by: Peter Zijlstra (Intel) --- .../hwtracing/coresight/coresight-etm-perf.c | 24 +++++------ drivers/hwtracing/coresight/coresight-priv.h | 1 + drivers/hwtracing/coresight/coresight.c | 42 +++++++++++++++++++ 3 files changed, 55 insertions(+), 12 deletions(-) -- 2.17.1 Reviewed-by: Suzuki K Poulose diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index cdbdb28dc175..8c88bf0a1e5f 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -31,11 +31,14 @@ static DEFINE_PER_CPU(struct coresight_device *, csdev_src); PMU_FORMAT_ATTR(cycacc, "config:" __stringify(ETM_OPT_CYCACC)); PMU_FORMAT_ATTR(timestamp, "config:" __stringify(ETM_OPT_TS)); PMU_FORMAT_ATTR(retstack, "config:" __stringify(ETM_OPT_RETSTK)); +/* Sink ID - same for all ETMs */ +PMU_FORMAT_ATTR(sinkid, "config2:0-31"); static struct attribute *etm_config_formats_attr[] = { &format_attr_cycacc.attr, &format_attr_timestamp.attr, &format_attr_retstack.attr, + &format_attr_sinkid.attr, NULL, }; @@ -191,6 +194,7 @@ static void etm_free_aux(void *data) static void *etm_setup_aux(struct perf_event *event, void **pages, int nr_pages, bool overwrite) { + u32 id; int cpu = event->cpu; cpumask_t *mask; struct coresight_device *sink; @@ -201,18 +205,14 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, return NULL; INIT_WORK(&event_data->work, free_event_data); - /* - * In theory nothing prevent tracers in a trace session from being - * associated with different sinks, nor having a sink per tracer. But - * until we have HW with this kind of topology we need to assume tracers - * in a trace session are using the same sink. Therefore go through - * the coresight bus and pick the first enabled sink. - * - * When operated from sysFS users are responsible to enable the sink - * while from perf, the perf tools will do it based on the choice made - * on the cmd line. As such the "enable_sink" flag in sysFS is reset. - */ - sink = coresight_get_enabled_sink(true); + /* First get the selected sink from user space. */ + if (event->attr.config2) { + id = (u32)event->attr.config2; + sink = coresight_get_sink_by_id(id); + } else { + sink = coresight_get_enabled_sink(true); + } + if (!sink || !sink_ops(sink)->alloc_buffer) goto err; diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index 579f34943bf1..b936c6d7e13f 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -147,6 +147,7 @@ void coresight_disable_path(struct list_head *path); int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data); struct coresight_device *coresight_get_sink(struct list_head *path); struct coresight_device *coresight_get_enabled_sink(bool reset); +struct coresight_device *coresight_get_sink_by_id(u32 id); struct list_head *coresight_build_path(struct coresight_device *csdev, struct coresight_device *sink); void coresight_release_path(struct list_head *path); diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index d7fa90be6f42..29cef898afba 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -541,6 +542,47 @@ struct coresight_device *coresight_get_enabled_sink(bool deactivate) return dev ? to_coresight_device(dev) : NULL; } +static int coresight_sink_by_id(struct device *dev, void *data) +{ + struct coresight_device *csdev = to_coresight_device(dev); + unsigned long hash; + + if (csdev->type == CORESIGHT_DEV_TYPE_SINK || + csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) { + + if (!csdev->ea) + return 0; + /* + * See function etm_perf_add_symlink_sink() to know where + * this comes from. + */ + hash = (unsigned long)csdev->ea->var; + + if ((u32)hash == *(u32 *)data) + return 1; + } + + return 0; +} + +/** + * coresight_get_sink_by_id - returns the sink that matches the id + * @id: Id of the sink to match + * + * The name of a sink is unique, whether it is found on the AMBA bus or + * otherwise. As such the hash of that name can easily be used to identify + * a sink. + */ +struct coresight_device *coresight_get_sink_by_id(u32 id) +{ + struct device *dev = NULL; + + dev = bus_find_device(&coresight_bustype, NULL, &id, + coresight_sink_by_id); + + return dev ? to_coresight_device(dev) : NULL; +} + /* * coresight_grab_device - Power up this device and any of the helper * devices connected to it for trace operation. Since the helper devices From patchwork Thu Jan 31 18:47:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 157155 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7555296jaa; Thu, 31 Jan 2019 10:47:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN7oH42QQ1ldmyhqaJ7T48ORw9MKZkJ2SWh1LKXc1zqIcGUSZH1M0VoOzp38RLv3RQA3T0yg X-Received: by 2002:a17:902:d68c:: with SMTP id v12mr35537196ply.4.1548960466102; Thu, 31 Jan 2019 10:47:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548960466; cv=none; d=google.com; s=arc-20160816; b=sTrXxcK2SjO+8v90q8UTRDkgJjtuvHJ9qQYMKd6ShF62hbrCXibmprEh8Bccc2QOET b1S0vEGlEQlGiI/p/x85QHeAN/b2bnf446AO0NAtGlK/WlcpLokx8eAedlDQNDHlv4Fm gcqBVNAdK/G4hDCN5CqX5gYyi1JDus/Tx2V0P4zp6J2MO/CCRvgumLcY+JxG/6PWwrU1 DwQP0ejoofS8xS0JiTUclE49uCSNZt5FkTGiWcAqVb4DkYMuPM2hhCfbKA5hQceDszWr nP7jcGt2g434bBS7nFebPyv43HRPCUmtBQtwLbJV6+WrrUOs6HrHWRD+ZEc5bNL8Mdvk rRvw== 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=7joT+FiIVI2um+Bj5G0r88fPyUv6XsFU9OyCfcSTWlE=; b=owV2Y1zdu80Cvoy+ApRxdUk1yPOfbd1BSzwXHiUpU5yqDsR8CWl2O8LxiO1xHZ1WLi 0be3FH9D/86SFCIzOnqBgx9j7cWLXq7Oi13RA7v4jM+JUbJbzu3ttbTqlDIoU0DJSvBz iej/yKyrEPT1jbcJOfFLjvmo1u/q69GO/hRegJYlLC7QXT/L1ad13gy8JdH6UVKzUPSa Icy65HZc+Vb524320/e6HwjasO2m29olCTk9ziq/l310xJdCMtaZcAJRXD6hT7lKyh+f uD0d46+ctrjVsvnljaZ9HEaCwwjjg9of1Vy5p9OSY3W5uKRurPLU4zW50BhL0G5dZ2r9 kBoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=glf4ziPB; 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 c4si4923421pfi.110.2019.01.31.10.47.45; Thu, 31 Jan 2019 10:47:46 -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=glf4ziPB; 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 S1728193AbfAaSr2 (ORCPT + 31 others); Thu, 31 Jan 2019 13:47:28 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41212 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728123AbfAaSrY (ORCPT ); Thu, 31 Jan 2019 13:47:24 -0500 Received: by mail-pl1-f194.google.com with SMTP id u6so1864160plm.8 for ; Thu, 31 Jan 2019 10:47:24 -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=7joT+FiIVI2um+Bj5G0r88fPyUv6XsFU9OyCfcSTWlE=; b=glf4ziPBQoTzLutgeF+Kepcv2UOvFNic2vzeLLP4nCNWMQCM3Rv0B0ZJe75bW3cncy +IhWEsfjSWk/9bisvLFqOIqzZPTjpQRv3nK1CktyUcZKc4wGG8r0BoZ9PtaFc04J0Lqo gIb04R7fqjNSJVnxqReFJF5V73z+BFLi0okJc= 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=7joT+FiIVI2um+Bj5G0r88fPyUv6XsFU9OyCfcSTWlE=; b=RLxRSodi+5oBkeQSfPZEwvj4QTbWOunahACsq9dz9IO4GTX6ZHpnD25lQZyGvZBbdK FcI540jGf9udJ8ScLs11w5dxwe9mbzQsbzrHHIzT6H0hTysCxPyVfNdEt0ZvPL7mBPVh NL8z7k0b+4il3CxGlHSEzM1aVS19XCPfwEXST9u30dTMRgExX687iGfZKrw6o070L/b/ iDfzfm9hOOHttsT06B8QYxz1pkc8t40nSxeXbE4IFeOU7n0cB+99DQjeOyBp2gl/clvm aMaZ9tHMzyFQd70xIxT1NsT0gVPo8qCXdzAU9dOaw4WHfXoN0Dh8BYw02b0f3V8BDEpD JiJg== X-Gm-Message-State: AJcUuke/0R0trH5maiAbvq1EKpPkPDmsoMHUVvCQr03X83CssoWjB0zc VD689XSXJVNk/KVKihgIPTQ1DQ== X-Received: by 2002:a17:902:2b8a:: with SMTP id l10mr33947349plb.70.1548960443889; Thu, 31 Jan 2019 10:47:23 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 10:47:23 -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 4/7] perf pmu: Moving EVENT_SOURCE_DEVICE_PATH to PMU header file Date: Thu, 31 Jan 2019 11:47:11 -0700 Message-Id: <20190131184714.20388-5-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 Moving definition of EVENT_SOURCE_DEVICE_PATH to pmu.h so that it can be used by other files than pmu.c Signed-off-by: Mathieu Poirier Acked-by: Suzuki K Poulose --- tools/perf/util/pmu.c | 2 -- tools/perf/util/pmu.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) -- 2.17.1 diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 11a234740632..51d437f55d18 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -29,8 +29,6 @@ struct perf_pmu_format { struct list_head list; }; -#define EVENT_SOURCE_DEVICE_PATH "/bus/event_source/devices/" - int perf_pmu_parse(struct list_head *list, char *name); extern FILE *perf_pmu_in; diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 76fecec7b3f9..350c54e0bd3d 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -16,6 +16,7 @@ enum { }; #define PERF_PMU_FORMAT_BITS 64 +#define EVENT_SOURCE_DEVICE_PATH "/bus/event_source/devices/" struct perf_event_attr; 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); From patchwork Thu Jan 31 18:47:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 157152 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7555112jaa; Thu, 31 Jan 2019 10:47:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN6PA/xr7iSi28UYwDsRFsb+ALU+EojYTiUaS41xAz+JAWZUcJr7Vd41UGW1R8ESCL8rBdmJ X-Received: by 2002:a63:4745:: with SMTP id w5mr33209668pgk.377.1548960454483; Thu, 31 Jan 2019 10:47:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548960454; cv=none; d=google.com; s=arc-20160816; b=fIOivZhLobKLjGd1CqrN0X+0pWpzpcxPkTO65xjEy2Zxbz4V2BuZ6iBVE9D4WB2qgC N5r6uO7Ge70+m20jrVkqnDv7Qk1P8Mwco4Crqq+sNH8IBQXjZDw55+eUZuEU0/JiaBJt kvFjLl5+pz9aqzaYPUtMLk1bb0n6Ik56xm+90HFl+cF+bYy6TrLOSjOzet1dlYraRS/S Ah+DB9N/IsXhQeTj8Or5s0DU9jWpsK0CcO4Z09F9FkNwQfJxE7Lv8rHveJ56DxnHzmqT 27Gz82wHpG8jyodWBllZqa/ZIIGGIY4fEUzm9AlXLSOIqIQ521zQvHKouvd3nPeWE6H4 t4iA== 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=tgDBy5pU4TSH5DxOCpIvkhjQNbxctYyd7XLZVLAf0nI=; b=dJfNkg5zYLJDfld58+cV1bke4eQJl0vNJuILsqwoQyVnlsdJQvluHtEX+euMqJbO8C xR5nvcJGljxXLhpJ9kOHi6oRFTVmS8hR3x9SBz9TnEZ9/7wj1sTNey8cRkurbsKY133p qG5G2XV1Vj+hR7q0SSeNnQVad2gNf3GOi0sAxHSAhlqrHAm3j0iGjZiVVl6RqEeJTzLO HskV2iFF32GRXTxRiGPVQxFN2Xt/S1oFL2sUo/OChbxj+mG/RZXjMHPEGZfPzKm3wWq4 iubq9galXTLTSrnmyVDzTP47f19+iI6e93Z2f/YwpqFUrfw+Lm8dDPlXVbAGMFW+3MBo 8hkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OEitRYvb; 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.34; Thu, 31 Jan 2019 10:47:34 -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=OEitRYvb; 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 S1728273AbfAaSrc (ORCPT + 31 others); Thu, 31 Jan 2019 13:47:32 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37618 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728191AbfAaSr1 (ORCPT ); Thu, 31 Jan 2019 13:47:27 -0500 Received: by mail-pf1-f194.google.com with SMTP id y126so1887467pfb.4 for ; Thu, 31 Jan 2019 10:47:27 -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=tgDBy5pU4TSH5DxOCpIvkhjQNbxctYyd7XLZVLAf0nI=; b=OEitRYvbdt7M0rQEZwQ0hu+ke2w8T89lMjjsZruG8ofpjewHOgcDS5hxPEAP+vX1sO d/YF2ewC8ZGswcUekRvxuUhYkaj7difJ/dM9j1X0+lxgL2AC0QAFahUvWVLvkxJt0JXV ZGDf0aPWW6bIapvpzabnJQq4r7GTT8D8bPMNE= 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=tgDBy5pU4TSH5DxOCpIvkhjQNbxctYyd7XLZVLAf0nI=; b=lObWh219t3ixqfD/3HFkfqd4n/N+hDx8KdIWtKJ9wWnjTYyHzOjbwiKDwZsS9BYMzL RbV7HOSf6ggTkuaqwhe0zp26mfNFPqIX5gWUOy7GGceR0jJKjlnsxoYu6J1Z9/CuESVY t010gXENtAkTROoyOZq8zAqNw9LrdkXKEU9/4dE+pCkr4sgNlb7piBM0kRCmWByxTJ5R Xx59EZSGTRdtVnEbiMlmSAOVMNXlG26vUnRpFpd6kZP1iY1nkGuDQ2u2OUuojP6Kd3Zv HTrQBTk8uAXJTF9pXQLEdwW7O+njO/oEMiZxiUsswlRnGFdL2jRXZKAfmo9ajjYeYvLp bAEQ== X-Gm-Message-State: AJcUukckbJ5rOa6gfG4k7TglH3sOULbjrsyCJIBn6ufgXtDrjNqx7dDf 1nSH5y/ixSXL+mdJYlzUForPSh/w9XTc5A== X-Received: by 2002:a63:2f86:: with SMTP id v128mr31458623pgv.407.1548960447382; Thu, 31 Jan 2019 10:47:27 -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.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 10:47:26 -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 6/7] perf tools: Removing CoreSight set_drv_config() API Date: Thu, 31 Jan 2019 11:47:13 -0700 Message-Id: <20190131184714.20388-7-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 Now that event's config2 attribute is used to communicate sink selection to the kernel, remove the old set_drv_config() implementation since it is no longer needed. Signed-off-by: Mathieu Poirier --- tools/perf/arch/arm/util/cs-etm.c | 54 ------------------------------- tools/perf/arch/arm/util/cs-etm.h | 3 -- tools/perf/arch/arm/util/pmu.c | 2 -- 3 files changed, 59 deletions(-) -- 2.17.1 diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 4f31cf0d1e6d..911426721170 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -27,9 +27,6 @@ #include #include -#define ENABLE_SINK_MAX 128 -#define CS_BUS_DEVICE_PATH "/bus/coresight/devices/" - struct cs_etm_recording { struct auxtrace_record itr; struct perf_pmu *cs_etm_pmu; @@ -642,54 +639,3 @@ struct auxtrace_record *cs_etm_record_init(int *err) out: return NULL; } - -static FILE *cs_device__open_file(const char *name) -{ - struct stat st; - char path[PATH_MAX]; - const char *sysfs; - - sysfs = sysfs__mountpoint(); - if (!sysfs) - return NULL; - - snprintf(path, PATH_MAX, - "%s" CS_BUS_DEVICE_PATH "%s", sysfs, name); - - if (stat(path, &st) < 0) - return NULL; - - return fopen(path, "w"); - -} - -static int __printf(2, 3) cs_device__print_file(const char *name, const char *fmt, ...) -{ - va_list args; - FILE *file; - int ret = -EINVAL; - - va_start(args, fmt); - file = cs_device__open_file(name); - if (file) { - ret = vfprintf(file, fmt, args); - fclose(file); - } - va_end(args); - return ret; -} - -int cs_etm_set_drv_config(struct perf_evsel_config_term *term) -{ - int ret; - char enable_sink[ENABLE_SINK_MAX]; - - snprintf(enable_sink, ENABLE_SINK_MAX, "%s/%s", - term->val.drv_cfg, "enable_sink"); - - ret = cs_device__print_file(enable_sink, "%d", 1); - if (ret < 0) - return ret; - - return 0; -} diff --git a/tools/perf/arch/arm/util/cs-etm.h b/tools/perf/arch/arm/util/cs-etm.h index 1a12e64f5127..a3354bda4fe8 100644 --- a/tools/perf/arch/arm/util/cs-etm.h +++ b/tools/perf/arch/arm/util/cs-etm.h @@ -7,9 +7,6 @@ #ifndef INCLUDE__PERF_CS_ETM_H__ #define INCLUDE__PERF_CS_ETM_H__ -#include "../../util/evsel.h" - struct auxtrace_record *cs_etm_record_init(int *err); -int cs_etm_set_drv_config(struct perf_evsel_config_term *term); #endif diff --git a/tools/perf/arch/arm/util/pmu.c b/tools/perf/arch/arm/util/pmu.c index e047571e6080..e4619f2fe7ce 100644 --- a/tools/perf/arch/arm/util/pmu.c +++ b/tools/perf/arch/arm/util/pmu.c @@ -8,7 +8,6 @@ #include #include -#include "cs-etm.h" #include "arm-spe.h" #include "../../util/pmu.h" @@ -19,7 +18,6 @@ struct perf_event_attr if (!strcmp(pmu->name, CORESIGHT_ETM_PMU_NAME)) { /* add ETM default config here */ pmu->selectable = true; - pmu->set_drv_config = cs_etm_set_drv_config; #if defined(__aarch64__) } else if (strstarts(pmu->name, ARM_SPE_PMU_NAME)) { return arm_spe_pmu_default_config(pmu); From patchwork Thu Jan 31 18:47:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 157154 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7555225jaa; Thu, 31 Jan 2019 10:47:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN5E4TL1rVnNH7jBOofmhRMK1uln9dZUMIz6fuG+9j1iiCh4juH3RO8sLSyoDBoYv6lKkMRF X-Received: by 2002:a17:902:28e9:: with SMTP id f96mr36098971plb.169.1548960461851; Thu, 31 Jan 2019 10:47:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548960461; cv=none; d=google.com; s=arc-20160816; b=n7YIrzPdA4+CTMrgRIFfN8LE/G+hojl/YxraAyfX4LQ3H29JlV7lFg3kAWQ1uxtMwR A76V9yvgmUDtPbESKmmuxSUZQKCnoBMC5ZLKUdwzCIqT1e9v2IDqyFFBf5zbI/V860dL ipNwFIuV+GcPun4aXmnI+wKqaDGhRFzeF8rVfAA+5bfckRY8b9pW6P9Ri9ruj/OkJIC7 4xPoyBM8MNjVaX/mAo49k6CwKaY64ClbJWFbhawPcgkVVvSDlIhX+oC7vtomPH9Bka2x 6fdI61NK4S7oFXbkjNISeWvPpqkl3T63+Zrb4raxg5VxNQntiqYTqnITmyYvwCPHXh/F hYKA== 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=W6/A2tfSYGw9pTsmVq4n41iTRg138j1rlpbipIKTLNs=; b=qvns6kSXTc0NrR5hOvlSs9+3vTc/s2IMrC3DICzB0W9xIU0hOnLmHMH/Oe6QgX1mzS Z3K6Oy4kvk6mGgA3wQXue6ItqMe484DAho+KCZkAJkCZKd0C+PYquD5/ehaFuiv/Bjfj 6UVKussZY+NksDKmGIaOqMQyDuPaLmVJIIidCkNOjqDGtaVtOViW2fcN/0EjhfnJm4mv pQCV7kK3nHs+YvqXx1Mj2N9Zkhu3Pjaei1alwnGKs+h79wD744Ghs0OFKQMeWWWzyYQS YxO1Hot2efsZAVKNTZupii9XmhH8mggf4IVqC3gBi1e0tLwdjbsFHHg3vgpSavtZpYmI 0CBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=br7drhpN; 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 c4si4923421pfi.110.2019.01.31.10.47.41; Thu, 31 Jan 2019 10:47:41 -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=br7drhpN; 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 S1728307AbfAaSrk (ORCPT + 31 others); Thu, 31 Jan 2019 13:47:40 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39450 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728203AbfAaSr3 (ORCPT ); Thu, 31 Jan 2019 13:47:29 -0500 Received: by mail-pl1-f193.google.com with SMTP id 101so1873371pld.6 for ; Thu, 31 Jan 2019 10:47:29 -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=W6/A2tfSYGw9pTsmVq4n41iTRg138j1rlpbipIKTLNs=; b=br7drhpNCpVQ4u9siGGJ9PQyuHW8ViAHdpZMBgVLopQF8F9yVx+NlHf1ZbeXSDphsU 6Fw77WIu3yyJeas7sWxM2XdTDtQJZyMQArAl4Tc+Zpm6Lh2qTfC9X97ABppjQXtTfRJs +py6j+QiFcHj0GBiK7tKw146S51rKexkq+amk= 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=W6/A2tfSYGw9pTsmVq4n41iTRg138j1rlpbipIKTLNs=; b=l9IVtNNI+J1i2I2dfeO/WnhlCpHc4/qg+jMulaIVKNocti5AOD5q4DxUqTlq0RnTdV Zgd4tZJaCgp/SiDLMEvstqVOxMwR+11rd3KSY6qUBK/4Qc8bpw0zPAreFbMd+5y3n3Ap UsEcihm7MCYExfjoTm5oe43WUc4FY3/ut7hq59WKslCR+vwV2N0DDrWjratPOBRj1yJx 9ilKm4JNgBU7Zr41Qo26grtDXzmi31WX6xWYe2J7+qgbNUBDSSGe2/oLKQfMmXIS+Kzd rjmtmwQ+7wvy0FKK0VIrNC5qLNipr/Y3c4sLw5VS9+CjtuED6wgwDBGTEeAfgoDHNGvO HcNg== X-Gm-Message-State: AJcUukfw79LmUMF52Kw8fQDNX26F63p2LohqZ18Elhazg9WCeXx++15W CbvAF1cJSJrBcuzCVjdwXbb5lg== X-Received: by 2002:a17:902:5588:: with SMTP id g8mr36095732pli.22.1548960449085; Thu, 31 Jan 2019 10:47:29 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 10:47:28 -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 7/7] perf tools: Remove PMU::set_drv_config API Date: Thu, 31 Jan 2019 11:47:14 -0700 Message-Id: <20190131184714.20388-8-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 CoreSight was the only client of the PMU's set_drv_config() API. Now that it is no longer needed by CoreSight remove it from the code base. Signed-off-by: Mathieu Poirier --- tools/perf/builtin-record.c | 10 ----- tools/perf/builtin-stat.c | 9 ---- tools/perf/builtin-top.c | 13 ------ tools/perf/util/Build | 1 - tools/perf/util/drv_configs.c | 78 ----------------------------------- tools/perf/util/drv_configs.h | 26 ------------ tools/perf/util/pmu.h | 1 - 7 files changed, 138 deletions(-) delete mode 100644 tools/perf/util/drv_configs.c delete mode 100644 tools/perf/util/drv_configs.h -- 2.17.1 Acked-by: Suzuki K Poulose diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 882285fb9f64..b637c37b8479 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -23,7 +23,6 @@ #include "util/evlist.h" #include "util/evsel.h" #include "util/debug.h" -#include "util/drv_configs.h" #include "util/session.h" #include "util/tool.h" #include "util/symbol.h" @@ -566,7 +565,6 @@ static int record__open(struct record *rec) struct perf_evlist *evlist = rec->evlist; struct perf_session *session = rec->session; struct record_opts *opts = &rec->opts; - struct perf_evsel_config_term *err_term; int rc = 0; /* @@ -619,14 +617,6 @@ static int record__open(struct record *rec) goto out; } - if (perf_evlist__apply_drv_configs(evlist, &pos, &err_term)) { - pr_err("failed to set config \"%s\" on event %s with %d (%s)\n", - err_term->val.drv_cfg, perf_evsel__name(pos), errno, - str_error_r(errno, msg, sizeof(msg))); - rc = -1; - goto out; - } - rc = record__mmap(rec); if (rc) goto out; diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 63a3afc7f32b..9c5b3b94bb38 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -52,7 +52,6 @@ #include "util/evlist.h" #include "util/evsel.h" #include "util/debug.h" -#include "util/drv_configs.h" #include "util/color.h" #include "util/stat.h" #include "util/header.h" @@ -418,7 +417,6 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) int status = 0; const bool forks = (argc > 0); bool is_pipe = STAT_RECORD ? perf_stat.data.is_pipe : false; - struct perf_evsel_config_term *err_term; if (interval) { ts.tv_sec = interval / USEC_PER_MSEC; @@ -515,13 +513,6 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) return -1; } - if (perf_evlist__apply_drv_configs(evsel_list, &counter, &err_term)) { - pr_err("failed to set config \"%s\" on event %s with %d (%s)\n", - err_term->val.drv_cfg, perf_evsel__name(counter), errno, - str_error_r(errno, msg, sizeof(msg))); - return -1; - } - if (STAT_RECORD) { int err, fd = perf_data__fd(&perf_stat.data); diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index f64e312db787..33e448f702b6 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -24,7 +24,6 @@ #include "util/annotate.h" #include "util/config.h" #include "util/color.h" -#include "util/drv_configs.h" #include "util/evlist.h" #include "util/evsel.h" #include "util/event.h" @@ -1184,10 +1183,6 @@ static void init_process_thread(struct perf_top *top) static int __cmd_top(struct perf_top *top) { - char msg[512]; - struct perf_evsel *pos; - struct perf_evsel_config_term *err_term; - struct perf_evlist *evlist = top->evlist; struct record_opts *opts = &top->record_opts; pthread_t thread, thread_process; int ret; @@ -1232,14 +1227,6 @@ static int __cmd_top(struct perf_top *top) if (ret) goto out_delete; - ret = perf_evlist__apply_drv_configs(evlist, &pos, &err_term); - if (ret) { - pr_err("failed to set config \"%s\" on event %s with %d (%s)\n", - err_term->val.drv_cfg, perf_evsel__name(pos), errno, - str_error_r(errno, msg, sizeof(msg))); - goto out_delete; - } - top->session->evlist = top->evlist; perf_session__set_id_hdr_size(top->session); diff --git a/tools/perf/util/Build b/tools/perf/util/Build index af72be7f5b3b..71e697e7df2d 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -104,7 +104,6 @@ libperf-y += term.o libperf-y += help-unknown-cmd.o libperf-y += mem-events.o libperf-y += vsprintf.o -libperf-y += drv_configs.o libperf-y += units.o libperf-y += time-utils.o libperf-y += expr-bison.o diff --git a/tools/perf/util/drv_configs.c b/tools/perf/util/drv_configs.c deleted file mode 100644 index eec754243f4d..000000000000 --- a/tools/perf/util/drv_configs.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * drv_configs.h: Interface to apply PMU specific configuration - * Copyright (c) 2016-2018, Linaro Ltd. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - */ - -#include "drv_configs.h" -#include "evlist.h" -#include "evsel.h" -#include "pmu.h" -#include - -static int -perf_evsel__apply_drv_configs(struct perf_evsel *evsel, - struct perf_evsel_config_term **err_term) -{ - bool found = false; - int err = 0; - struct perf_evsel_config_term *term; - struct perf_pmu *pmu = NULL; - - while ((pmu = perf_pmu__scan(pmu)) != NULL) - if (pmu->type == evsel->attr.type) { - found = true; - break; - } - - list_for_each_entry(term, &evsel->config_terms, list) { - if (term->type != PERF_EVSEL__CONFIG_TERM_DRV_CFG) - continue; - - /* - * We have a configuration term, report an error if we - * can't find the PMU or if the PMU driver doesn't support - * cmd line driver configuration. - */ - if (!found || !pmu->set_drv_config) { - err = -EINVAL; - *err_term = term; - break; - } - - err = pmu->set_drv_config(term); - if (err) { - *err_term = term; - break; - } - } - - return err; -} - -int perf_evlist__apply_drv_configs(struct perf_evlist *evlist, - struct perf_evsel **err_evsel, - struct perf_evsel_config_term **err_term) -{ - struct perf_evsel *evsel; - int err = 0; - - evlist__for_each_entry(evlist, evsel) { - err = perf_evsel__apply_drv_configs(evsel, err_term); - if (err) { - *err_evsel = evsel; - break; - } - } - - return err; -} diff --git a/tools/perf/util/drv_configs.h b/tools/perf/util/drv_configs.h deleted file mode 100644 index 32bc9babc2e0..000000000000 --- a/tools/perf/util/drv_configs.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * drv_configs.h: Interface to apply PMU specific configuration - * Copyright (c) 2016-2018, Linaro Ltd. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - */ - -#ifndef __PERF_DRV_CONFIGS_H -#define __PERF_DRV_CONFIGS_H - -#include "drv_configs.h" -#include "evlist.h" -#include "evsel.h" - -int perf_evlist__apply_drv_configs(struct perf_evlist *evlist, - struct perf_evsel **err_evsel, - struct perf_evsel_config_term **term); -#endif diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 350c54e0bd3d..569a6cbffd5a 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -30,7 +30,6 @@ struct perf_pmu { struct list_head format; /* HEAD struct perf_pmu_format -> list */ struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */ struct list_head list; /* ELEM */ - int (*set_drv_config) (struct perf_evsel_config_term *term); }; struct perf_pmu_info {