From patchwork Tue Jan 22 18:11:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 156311 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7883269jaa; Tue, 22 Jan 2019 10:12:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN7MJuqx6Q/VssockLqc/L4KRNcC0hmUdScTCM7ZfpsemNP/uu3r09nUxxP8k7cCY5rWqvr9 X-Received: by 2002:a62:140a:: with SMTP id 10mr34014871pfu.157.1548180736934; Tue, 22 Jan 2019 10:12:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548180736; cv=none; d=google.com; s=arc-20160816; b=iIUiRXi8RUasYfxo2f0eBWI9bDhGNmIK7DyKov+0yMZiVEgFGn6x/6/p9rbnWwIRQM MBMHCZf0+2pJnvepFrmm4aGBJfo0A5BG+7uNOVfYR7UaQ04897s6Z+4HPQYjywHHnPhW cMKzc6oF8YpQGJ0kwS3RZMxc7iMW/pddOuoniKmPhdGhtZqBJZjhpdX2D4a2mmqSLB8Y ncgvpltnVa/DN/6YMmtUjhwdiCkpc3tiJLXJf0Sb3EJpbX+7zfk82D1il47r4t7GLQGK 1jLzkCu4CfxPjcSDiQu/ESVp6xqZ8m3GcJLgjGu5jsUlSQJw9DFyF52CbyOK43V79lEs yltQ== 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=OJPXA6lSpBfqPbKWnv+BzpsRIc5VmSE4ADKHlW/2O0g=; b=vJcogJOvOm4uvIrRQRX63G/if4VFLZ53EJlRbZfXeYfrGsCBxFYAZIdFVTxWmzR+XB bWSdD4kIfY+16mlWcr7JPc1JfXkw+q7QyYufVUmUmfLllZHpfXfLB8lTo/pOQbutnD/0 XPB4bNg2csYOp20psuNtNLLCrxWtJAp4LXxuOkcZDHZYwtmpGXLcYn5WVWDVjZs/QHef iLa3Tpu8S0fQGXL3kqyLFurObKk5LGxkIMEj6A1KUsEgTSaGXqmSBuP/S1zuwFYtsf3t t5hfyRH+Hz0HQcC1KIpUA2tiKTaqw9ziSlLhGXT3pVmEHtYWMpUJ8fLl1+wFummF5Rw4 +xxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TBHC630Z; 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 y15si10844961pgf.321.2019.01.22.10.12.16; Tue, 22 Jan 2019 10:12:16 -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=TBHC630Z; 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 S1726792AbfAVSLy (ORCPT + 27 others); Tue, 22 Jan 2019 13:11:54 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44994 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726291AbfAVSLu (ORCPT ); Tue, 22 Jan 2019 13:11:50 -0500 Received: by mail-pg1-f195.google.com with SMTP id t13so11406842pgr.11 for ; Tue, 22 Jan 2019 10:11:49 -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=OJPXA6lSpBfqPbKWnv+BzpsRIc5VmSE4ADKHlW/2O0g=; b=TBHC630ZBree1vMKU8Mts6R8xPb14IDVvUgiNeXSoyXpp941wDPu6MhoGjkQOtKdAX 3fosK4jpcohAxzaEEj9TZ/1dR/S3VFjkNbZrMhNLSxkb1Cvj06RvlE0241ciSpKDKxEf fg69IG+j0jXxJCnLf/l5opvLqjaSGOyPgJwK4= 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=OJPXA6lSpBfqPbKWnv+BzpsRIc5VmSE4ADKHlW/2O0g=; b=EmyehmVL0r+DN5ogrjZtYdbzwP8FjCFhrxKmI4dpwoUjMNRy1Erc2AguImtwXjlzWS YLiKeyUrcAdGPDQGxXaOv6m+s+kMkUBAigHAqecQmv7lR3ZuW7RGljDSNYtq+dN2TSsq UN8MTpcubJbA7vGuXBVx70gWFR76Sq97LgyZHx1CVO1mq+jPRS2Un4E4WPQ+btNFkhlJ WiROiPGdNneiEGxPjAO1tOyz84fkNPahNHfHiT4xJV0xxI7of0oCPIG/cte2srXm4KVa Sce+xQ6yhqvXaoZh53WLfAlCFRuOb3kcVAUu+YfE5ZsnQSNLv5UqsGta60OH/cmJmWh+ 5dAw== X-Gm-Message-State: AJcUukdkEsXpJbwwciZlZrne4WNC3lx/8wwGGenHYen/DMdcdpEJZ9Hc YBds7l2jEE3ZOtCZKGWy34lIwA== X-Received: by 2002:a62:2e46:: with SMTP id u67mr33799408pfu.3.1548180708924; Tue, 22 Jan 2019 10:11:48 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id a18sm23489919pgj.30.2019.01.22.10.11.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 10:11:48 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org Cc: 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, suzuki.poulose@arm.com Subject: [PATCH v2 1/7] perf/aux: Make perf_event accessible to setup_aux() Date: Tue, 22 Jan 2019 11:11:38 -0700 Message-Id: <20190122181144.26645-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190122181144.26645-1-mathieu.poirier@linaro.org> References: <20190122181144.26645-1-mathieu.poirier@linaro.org> 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 --- 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 Tue Jan 22 18:11:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 156306 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7882914jaa; Tue, 22 Jan 2019 10:11:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN5QrBY/d0IudDPsnv0bfwdrkWB389ABTZ4avAyBiXKsIVFTMKxlIOr6ZOX7N6BdfIVc1Dn8 X-Received: by 2002:a17:902:541:: with SMTP id 59mr35901545plf.88.1548180714696; Tue, 22 Jan 2019 10:11:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548180714; cv=none; d=google.com; s=arc-20160816; b=VyJB6LDKVA7NHqiEAJ3Lxss74Q7n0wnSqFL21V6QweZDk0YdCP6ufqmBaTB2kJL/o+ nTmVzPUQ5FctBeJYFsztq5uuoN2cAq5fn63lUkz1WTgyGW4ts/JnsS4Dp117R9Fu3hl8 F6zWWkXCsyfeoB6zx2MVl4n5FYAlZGFh+W8F8eaTcHMTzw5tLV1GbLNa/nboH+LVDmuu 7QjddxM3OX17ZGgtuGlnpQdYIz9f7PAnRHJSr0EiGVIv+wwIf7FdrVWmmlHt33PKzd49 /diU2N9UP1wB0RuGB5M2Zz8fu1ukUvPtAI7F7m5lFw0+cKI9MqeJe9xBhA2/83uBdewI 36+A== 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=w2HxLo0zTdY2xYNYUVAZCND3mlCXe1W0iz7EyzmW3zA=; b=JzTW8XrFJd+p9syVFhviCy1VcE6wxJEzjnlokfEVXQASZl7lQbOOQh+cYPKl/42Hnq FVSfcnd3GxpquUwVmmK6tPHdXs2GOYY7q3gQgtA3HVEx8J9zfRy17Q9RoEWmMEg1mkxu huF/VIqGMEu/vNZ3Da4Lp2Q4Q87/EzWzDiiAFMTXyCIXG4Wg4K1hOkZ9rdG4N8yRaOQA Wxcs87eBJb3Q1kJmNMVADkrEOQ0NC2IlBeVVc7xyZPJG9rMr8ah6Wa2ZrG/JaZY55CXy xiITe122uyv3TnPgqEfK2bPxybXnnNDpUbSlKlm4V3AfI+E5J2D+sKBxfktyXG5lBMbv k6QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FI/KdH3R"; 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 r8si17112338pgr.252.2019.01.22.10.11.54; Tue, 22 Jan 2019 10:11:54 -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="FI/KdH3R"; 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 S1726684AbfAVSLx (ORCPT + 27 others); Tue, 22 Jan 2019 13:11:53 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35428 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726321AbfAVSLv (ORCPT ); Tue, 22 Jan 2019 13:11:51 -0500 Received: by mail-pl1-f194.google.com with SMTP id p8so11868133plo.2 for ; Tue, 22 Jan 2019 10:11:51 -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=w2HxLo0zTdY2xYNYUVAZCND3mlCXe1W0iz7EyzmW3zA=; b=FI/KdH3RKgeLXUHbaFZIgCH6VzqCe6b72MaEcYzUU+yXdZ/kD3ay8TojNyezCwIitG 1v4Z7aLBdjfy2wAdId7EIaxA++MPtdYuUIH3zB5hyIhQYkSrTIzLLQ0DhNyRhBolsfcl z0AC6bs6Rkbz6jiqnl248D4O2eSviJUf7PPI4= 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=w2HxLo0zTdY2xYNYUVAZCND3mlCXe1W0iz7EyzmW3zA=; b=WrQQIC/Qbzxgez03Xbv1HHjVEIW0E6yJp1J6IF1inajdvkosCrtJ9y8gd6Zy7nrC0+ 5Bs2TLpuBoYa76qqSe4TnnttK6viy02C2vAnSzBe/Fy5CAARsawHqfAA3TdbGTR/ZWCz USvXgIC4XZr7kiXJaA8pcVdhi3vOhamra4Pt9Yc7jqekqQIEdYpvZ0tiDpTSn1nJHdl3 rf7ORjPRhNmALcUdjSs+el9fuubTQZhoPvjfOVda028xLWP+UdloO+VyQm7yrpwLt+Cg u31AlD3RVASPnNFeov1FuWrGspsaDQ6U+FNIN+fj0GsrnfSNsFw8IdTf33P/lXhlELnR E8YQ== X-Gm-Message-State: AJcUukfZwqDCrxrSORQ3Pm4YEJ5ejjJn4ubid8C1iLBobyd/EKfXwl+h vhBnMA92YlGOyDIliguwUS8TSw== X-Received: by 2002:a17:902:e10a:: with SMTP id cc10mr35698716plb.165.1548180710633; Tue, 22 Jan 2019 10:11:50 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id a18sm23489919pgj.30.2019.01.22.10.11.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 10:11:50 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org Cc: 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, suzuki.poulose@arm.com Subject: [PATCH v2 2/7] coresight: perf: Add "sinks" group to PMU directory Date: Tue, 22 Jan 2019 11:11:39 -0700 Message-Id: <20190122181144.26645-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190122181144.26645-1-mathieu.poirier@linaro.org> References: <20190122181144.26645-1-mathieu.poirier@linaro.org> 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 --- .../hwtracing/coresight/coresight-etm-perf.c | 76 +++++++++++++++++++ .../hwtracing/coresight/coresight-etm-perf.h | 6 +- drivers/hwtracing/coresight/coresight.c | 18 +++++ include/linux/coresight.h | 7 +- 4 files changed, 104 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index f21eb28b6782..c68a0036532c 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,71 @@ 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) +{ + /* See function coresight_get_sink_by_id() to know where this is used */ + u32 hash = hashlen_hash(hashlen_string(NULL, dattr->attr.name)); + + return scnprintf(buf, PAGE_SIZE, "%x\n", hash); +} + +int etm_perf_add_symlink_sink(struct coresight_device *csdev) +{ + int ret; + struct device *pmu_dev = etm_pmu.dev; + struct device *pdev = csdev->dev.parent; + struct device_attribute *dattr; + + if (csdev->type != CORESIGHT_DEV_TYPE_SINK && + csdev->type != CORESIGHT_DEV_TYPE_LINKSINK) + return -EINVAL; + + if (csdev->dattr != NULL) + return -EINVAL; + + if (!etm_perf_up) + return -EPROBE_DEFER; + + dattr = kzalloc(sizeof(*dattr), GFP_KERNEL); + dattr->attr.name = kstrdup(dev_name(pdev), GFP_KERNEL); + dattr->attr.mode = 0444; + dattr->show = etm_perf_sink_name_show; + csdev->dattr = dattr; + + ret = sysfs_add_file_to_group(&pmu_dev->kobj, + &dattr->attr, "sinks"); + + if (!ret) + return 0; + + csdev->dattr = NULL; + kfree(dattr->attr.name); + kfree(dattr); + + return ret; +} + +void etm_perf_del_symlink_sink(struct coresight_device *csdev) +{ + struct device *pmu_dev = etm_pmu.dev; + struct device_attribute *dattr = csdev->dattr; + + if (csdev->type != CORESIGHT_DEV_TYPE_SINK && + csdev->type != CORESIGHT_DEV_TYPE_LINKSINK) + return; + + if (!dattr) + return; + + sysfs_remove_file_from_group(&pmu_dev->kobj, + &dattr->attr, "sinks"); + csdev->dattr = NULL; + kfree(dattr->attr.name); + kfree(dattr); +} + 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..a42fac83eac9 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. + * @dattr: 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 device_attribute *dattr; }; #define to_coresight_device(d) container_of(d, struct coresight_device, dev) From patchwork Tue Jan 22 18:11:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 156307 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7882992jaa; Tue, 22 Jan 2019 10:11:58 -0800 (PST) X-Google-Smtp-Source: ALg8bN4EM7K7mZbh7z/YTIaXBpIaBPapLJqi/JaJxyySi3P7Aq0WQ/4/oGovTjRcRtv5k3e8S1X7 X-Received: by 2002:a63:cd11:: with SMTP id i17mr21536090pgg.345.1548180718755; Tue, 22 Jan 2019 10:11:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548180718; cv=none; d=google.com; s=arc-20160816; b=BfYVjItnZJW+mmw035UJr0YrPTWPzfRlA8LUPtYTM9+iUnlll2Xmdcnki2XQWjmbw1 3ETslGNCcW5Gb56XCWHweooAkKIfxdeowegviU401ksB4Cmvn0yBOcALLbExil7zk9H4 k0QBKG0Xjoc9pT/LupDHQWZhi5ex6yh9DULOGSsfU4bnk6zeOCtVQ0REwjPCI6JGGyF0 v23ozDMDjxI5G1MQG1zhp1nOABTyyKouoY2OVwE4SV0o7TiByoiVv0SGOTVjOjlUg0CH 2eI5SpjpOZ9/gR6Kwhft20oIODcVkDfkDqeu1srqNsv1yqAS1hsULoi92BruDSr+eZov 0bOQ== 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=WD+b5Mm6yeuI88aSA3mrYBwAA3DBi7In9eqFESn15DU=; b=TtxIbDQ1uE7qUZaafhuQQkhJDByuy41sDa8SqHIzCuZd8XKFcgz7kAYhJgX3/Lg58L /GKrQXWLqWJLIs/IGiN1xRMFcuV/SKnR7D7hFI2lBZXR3xeQJP0BpguX0nz4c8MOL2E5 dRKNKXc+hxg/xLGDE8+QJH9oRGZArylBrbQqvlhY+Xy4WbuGL/53wbz7qs8c1kdVB8oP 76lQO5kBdna98Kvmky2b5Ex6wpwMilsLD3uu2Zi6AdH46FDtyFQHasoeLonKBmlC14zU pvRSbXQCF8TjGP4Sz0ROPECt+/yhgADDhdPWbUDNsmIvHJA6s9e/CJSZ7TFnzUBJkeOk 94nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=elnxxuCb; 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 86si18230233pfl.46.2019.01.22.10.11.58; Tue, 22 Jan 2019 10:11: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=elnxxuCb; 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 S1726823AbfAVSL4 (ORCPT + 27 others); Tue, 22 Jan 2019 13:11:56 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:33906 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbfAVSLx (ORCPT ); Tue, 22 Jan 2019 13:11:53 -0500 Received: by mail-pl1-f193.google.com with SMTP id w4so11870440plz.1 for ; Tue, 22 Jan 2019 10:11:52 -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=WD+b5Mm6yeuI88aSA3mrYBwAA3DBi7In9eqFESn15DU=; b=elnxxuCbq/YgY5Pr7eGe+AErOidyhvDqdlc5GkuWmcB1CVlDqEFQbKy3JKEtULu/as SH+9ZDtO9o9BFmiTBDcf7DH0ns1iv/tFr41XodKSsRPrlZDvA363X6H0nOQXHXuod64/ z19O662nB+dPd0mylCy+JlcXvcXf6rSHvLe9Y= 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=WD+b5Mm6yeuI88aSA3mrYBwAA3DBi7In9eqFESn15DU=; b=HOiqJs/djQfwpu+n4SgMBjcH2w+NJEyNhq+q6XM8YfWIo0+7RFH89hpA2wSMgB1ckr E2KSXznVLpJAt92UhAoqXGHqzAm2yDLLoWgzPWn0ignhqr+ZI73qROFl+9MieqmETAmf 1SCcn7n+cbEoUE9Jt+0LfhfjEJVptvjKbBiIgsq1cNCXJwZwMN9InqV66OHDKywabKzR fKaTEP81iuQgvLNpmInAZP5j7CunGHtwT/7aAbIWqkpuQbvaQp4q4z7Thf3vxfkH96CT DAgmaNI6BvaJqN9iPQTSzUtwtTh3gcQPrNCAAMSA/K9itHIqRRcJ1WwePS3SOIuk2VCT vRtg== X-Gm-Message-State: AJcUukf22hjOlWLBOBbjMFBFkKMKzUY1fehvis6ECfJLw0FENo5g00ZQ evKuAAVDyNsusMJDllqzQw9PwQ== X-Received: by 2002:a17:902:7296:: with SMTP id d22mr35979711pll.265.1548180712415; Tue, 22 Jan 2019 10:11:52 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id a18sm23489919pgj.30.2019.01.22.10.11.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 10:11:51 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org Cc: 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, suzuki.poulose@arm.com Subject: [PATCH v2 3/7] coresight: Use event attributes for sink selection Date: Tue, 22 Jan 2019 11:11:40 -0700 Message-Id: <20190122181144.26645-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190122181144.26645-1-mathieu.poirier@linaro.org> References: <20190122181144.26645-1-mathieu.poirier@linaro.org> 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 --- .../hwtracing/coresight/coresight-etm-perf.c | 24 ++++++------ drivers/hwtracing/coresight/coresight-priv.h | 1 + drivers/hwtracing/coresight/coresight.c | 39 +++++++++++++++++++ 3 files changed, 52 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 c68a0036532c..ea031eb673b3 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..c5f2df186a19 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,44 @@ 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); + u32 hash; + + if (csdev->type == CORESIGHT_DEV_TYPE_SINK || + csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) { + /* + * See function etm_perf_sink_name_show() to know where this + * comes from. + */ + hash = hashlen_hash(hashlen_string(NULL, dev_name(dev))); + + if (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 Tue Jan 22 18:11:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 156312 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7883304jaa; Tue, 22 Jan 2019 10:12:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN7j/LCJLmkzoN/ReW5Mi4Ksf6DtA1fgiisnI9bPGQpfP6BWJNrpCHKNkVo4rhxGQYoYJmTP X-Received: by 2002:a17:902:7b91:: with SMTP id w17mr35342167pll.111.1548180739572; Tue, 22 Jan 2019 10:12:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548180739; cv=none; d=google.com; s=arc-20160816; b=JNCNEZx5ia+2WJzvk5EWlF/bCRZ5EDY2iGBtFgVD1+nsSaRb1mElSS08Z+czPc/VcP kRGNLYg2eov+CAIP56I3eETrLc1ljshT+wzq3tGgzSR2u8DEjyrjcyhQiGJjUkrAh2Gq Eb8cIzKaC+aQjYl28p/kMOp3rhfcWz447B1U4evJhyqqWBORyV8yBR+2h5DctVxsdheD 1QhEIrwWL2b0olB81gl0Jzd+dAkorAgZFVmEDcuc427K2VaSSiM/5vRVRd6NrbXYKUpM XMO05aryj8+jLvM0YquTqHo6Nogr/xnbrKqsepxfZq9JBu3ciMXyhkTrKZL94ClaB3p8 /plA== 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=SuxrcXTgi5Kz7buMh5CGnWQq0L/rwu8Ex3hQZBJw2VY=; b=jg6DnFIlgdeWffw9VsUhz8hQ7fWOuFV2QWEujz7C1bs5/+y0HAQ7yG1yXxXnNITTvs lWL240Os7ub0ZIcUJhcMWNxJtrmi4JSLL66C32LiJGtwps+/jGGpDPelpXBJeXvjA5BR aR+YWC9vezxL7prAlcS+UUDNM1Eh8kC54XpCwp2HZv/vBdr6pFQlo7ubBYdj6dbLbR4x VVEG0kg0Vn2qaZTUE/igmoYylddgLObnIBFkgx+cSftmH97Mh36tMLEsU/DtQ23LW7aC rg2kDfPLtkFTHX4FqcMat0UCYXJB9sHOEE8Fr38oZUbecD5jqX1nbnp3GMD3H5dVW929 EC5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z60QHjIe; 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 y15si10844961pgf.321.2019.01.22.10.12.19; Tue, 22 Jan 2019 10:12:19 -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=Z60QHjIe; 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 S1726953AbfAVSMR (ORCPT + 27 others); Tue, 22 Jan 2019 13:12:17 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:38192 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726779AbfAVSLy (ORCPT ); Tue, 22 Jan 2019 13:11:54 -0500 Received: by mail-pl1-f195.google.com with SMTP id e5so11855932plb.5 for ; Tue, 22 Jan 2019 10:11:54 -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=SuxrcXTgi5Kz7buMh5CGnWQq0L/rwu8Ex3hQZBJw2VY=; b=Z60QHjIenHT4OyqBsheQMaxF6RYqBiV7QP2VycQw72Lnz8H7lTUiNzU5XFIvjxZMOd R2bV27OuAJFwleSNM7Dop+yv5TW+2A9PK6f1u1wfz8Ud6uRN3Xd2seGCMo1x9AveRPOQ lZiMeIWyeAYYBpcSzW4mn9GspNtVMVJWn3qKQ= 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=SuxrcXTgi5Kz7buMh5CGnWQq0L/rwu8Ex3hQZBJw2VY=; b=eIJx5BxA2nHzI6/qidIGmtk/VjV594AAmk+NjXKHU2y1/FGJ1rxxGha3LSGZQdLRy5 kscp/OhVN+Y2SYLziGKqRoJlU1zlJjcMfHovibTJ0HA+3ciWo2+X/ylAGsix2SUTAs9k mFI6rkefP24k9iL/fgPuA4GM5nGMRLKgUKsA8+6MfZNppskeNxywkHy9EUoVi+izT2Sx enbzZEHnx4MUUehUaGsAvZfsgWKD21Ph1Jqfz+XQUE1pjcFgeSMnTMCPcZKjJU39VE9u c6dDvd6tUORGXNuSkfmjxy0Dc/QBEa4DLW85XFnS40vYUZuYmHX+kPFQh/TzHB/GHXTi q+xQ== X-Gm-Message-State: AJcUukdTKrA1M8xl7QYFqXJUPm5J6xIBNxnT7/w2hp3zWn9m9WtWENr1 YYG8NErQXHUHivLbgyPey6pJ/Q== X-Received: by 2002:a17:902:bf03:: with SMTP id bi3mr35275336plb.83.1548180714066; Tue, 22 Jan 2019 10:11:54 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id a18sm23489919pgj.30.2019.01.22.10.11.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 10:11:53 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org Cc: 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, suzuki.poulose@arm.com Subject: [PATCH v2 4/7] perf pmu: Moving EVENT_SOURCE_DEVICE_PATH to PMU header file Date: Tue, 22 Jan 2019 11:11:41 -0700 Message-Id: <20190122181144.26645-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190122181144.26645-1-mathieu.poirier@linaro.org> References: <20190122181144.26645-1-mathieu.poirier@linaro.org> 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 --- tools/perf/util/pmu.c | 2 -- tools/perf/util/pmu.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) -- 2.17.1 Acked-by: Suzuki K Poulose 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 Tue Jan 22 18:11:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 156309 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7883076jaa; Tue, 22 Jan 2019 10:12:04 -0800 (PST) X-Google-Smtp-Source: ALg8bN6O22wr2BSqt0rYGU2iKfwYBMx3W8ts+Tx86NldCMRhelyLcOhQwCksQm/IxZ2jxbDEBC8B X-Received: by 2002:a63:bc02:: with SMTP id q2mr33239434pge.116.1548180724150; Tue, 22 Jan 2019 10:12:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548180724; cv=none; d=google.com; s=arc-20160816; b=AKHLl/W1wtfQTng1pVYk143o+WoTFJAxcivVftUACDDgq/tr4DRsY42HK5/SQLLPLj /C9dHaPSU+qJbZ2d1vRWC8cS2pNPyrrp3rCHxqxTPHKJCaneXLsKFScSWoiusMt6gmu0 xQAebzXOXS7kuXb4/xj/uRRYbIqIVVAjEoeGTZC1/TdFNJyhiPnUQbfnBttIJIk3aJwo 7ISF9zXpmtTC/uStFDT02PJhyrkHe15I7rMU0jdzJlGqFTxFT/Irffra6QbrYdLSJU9w Fzr1hAS12FfxXpWKUZZVSGUczvoj6RBXUhn1twd5qjnhOG1egCvYvvhLXe5yGzMVCZk7 9Daw== 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=L7eckfF2Zrk2L2hw3XycylNkNnZH54URJARS3kpuRe8=; b=WR4gTykVWwJnkyvqgTsN5I7USU0Wae+NTgZfrwHqswIvwuLWot4uTp2sZs+/OIrEZS jrBTsj9TXu+nk3rPFu8WU83EzUKZ2TPwQ2fgJiZt3YkblKQQ1hkFFyTAwk0POFQKeY4K DzzHB1wcAroQHJcegS31wkgJrvOU+6PWN2fnPkWRkgPZvjyVJaHdpAA5udY+hbN1N3CO fnfwg1mNyd1Hf4H85GBzz1HRW9elJjulrRv6LLk8A2BJTUZS0gVj66wDpi5kZVIMRVhz FeQwoEEl/RHWj3rqY45Ze28yQEhK+0k6mzSyELMpUzY8WPWXA9ST/b/LZa0VKzpwyFyi /0wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BXYfPlRL; 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 d12si3937022pgf.470.2019.01.22.10.12.03; Tue, 22 Jan 2019 10:12:04 -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=BXYfPlRL; 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 S1726881AbfAVSMB (ORCPT + 27 others); Tue, 22 Jan 2019 13:12:01 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39883 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbfAVSL4 (ORCPT ); Tue, 22 Jan 2019 13:11:56 -0500 Received: by mail-pl1-f196.google.com with SMTP id 101so11852040pld.6 for ; Tue, 22 Jan 2019 10:11:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L7eckfF2Zrk2L2hw3XycylNkNnZH54URJARS3kpuRe8=; b=BXYfPlRL/9ULQcWr54dC4Mv2z/oOD8AjTw4ZdXGJQ1iEcfPruZ0t2Ee5oxI2xeqkKQ zZuB9nQGg/x3AhZO/WvtTANu86lPvz3/+BEeNFID5LoCybqLtWt0rGH6WMxNgJ+x+iqp f/Q3rrcN9wAp5j9rzoUfwSKYkgFALFWt9zIgc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L7eckfF2Zrk2L2hw3XycylNkNnZH54URJARS3kpuRe8=; b=sR/l8+D16rvwjkWQlb8uxUijApHSx3IyVVkRog4LH1XWkYD2RxpimJ91jhVFeUt2IJ K/OXRnWtf1NVEk1Nh12QSrOHpfxLETi7oX9AicDmKe3Au1+eyxBLaLpFd5FPrMyZOKI5 UOk2LykWsizQmLqPdGmBhJwyAgCjSxLEeelTtbzIMYOrppGT5NNDsnJJWu77RU96PUlL 5m2A1r7m5tBvjsqeLaoSX6sX+jgf4CUMBN/0RrEbUtSDFc1r2mg6b9wsEri9crfR2QO/ QDCy+DHjAsvWQtq5Q/EydLImBZZ9WtJdL5hux69kUjuhB+dIpGsNpgKnKLBoCWyMRZig FfJA== X-Gm-Message-State: AJcUukd2HuqU39Lt+E5TMstVrkgLtz4ErSd1rU3/75xiTyWWQpqWzGL2 kxDog9WREaoflh4yxiZDGcx59w== X-Received: by 2002:a17:902:f091:: with SMTP id go17mr35959173plb.235.1548180715665; Tue, 22 Jan 2019 10:11:55 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id a18sm23489919pgj.30.2019.01.22.10.11.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 10:11:55 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org Cc: 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, suzuki.poulose@arm.com Subject: [PATCH v2 5/7] perf tools: Use event attributes to send sink information to kernel Date: Tue, 22 Jan 2019 11:11:42 -0700 Message-Id: <20190122181144.26645-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190122181144.26645-1-mathieu.poirier@linaro.org> References: <20190122181144.26645-1-mathieu.poirier@linaro.org> 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 one CPU is involved in the scenario due to the static nature of sysfs. As such communicate the sink information to each event by using the perf_event::attr:config2 attribute. The information sent to the kernel is an hash of the sink's name, which is unique in a system. Signed-off-by: Mathieu Poirier --- tools/perf/arch/arm/util/cs-etm.c | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) -- 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..4aa6193dcb50 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -22,6 +22,7 @@ #include "../../util/thread_map.h" #include "../../util/cs-etm.h" +#include #include #include @@ -60,10 +61,45 @@ static int cs_etm_parse_snapshot_options(struct auxtrace_record *itr, return 0; } +static int cs_etm_set_sink_attr(struct perf_pmu *pmu, + struct perf_evsel *evsel) +{ + char msg[BUFSIZ], path[PATH_MAX], *sink; + struct perf_evsel_config_term *term; + int ret = -EINVAL; + u32 hash; + + list_for_each_entry(term, &evsel->config_terms, list) { + if (term->type != PERF_EVSEL__CONFIG_TERM_DRV_CFG) + continue; + + sink = term->val.drv_cfg; + snprintf(path, PATH_MAX, "sinks/%s", sink); + + ret = perf_pmu__scan_file(pmu, path, "%x", &hash); + if (ret != 1) { + pr_err("failed to set sink \"%s\" on event %s with %d (%s)\n", + sink, perf_evsel__name(evsel), errno, + str_error_r(errno, msg, sizeof(msg))); + return ret; + } + + evsel->attr.config2 = (u64)hash; + return 0; + } + + /* + * No sink was provided on the command line - for _now_ treat + * this as an error. + */ + return ret; +} + static int cs_etm_recording_options(struct auxtrace_record *itr, struct perf_evlist *evlist, struct record_opts *opts) { + int ret; struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr); struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; @@ -92,6 +128,10 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, if (!cs_etm_evsel) return 0; + ret = cs_etm_set_sink_attr(cs_etm_pmu, cs_etm_evsel); + if (ret) + return ret; + if (opts->use_clockid) { pr_err("Cannot use clockid (-k option) with %s\n", CORESIGHT_ETM_PMU_NAME); From patchwork Tue Jan 22 18:11:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 156308 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7883062jaa; Tue, 22 Jan 2019 10:12:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN4i7NLkc4xrspcK/PN+LcN58j0aJEf+rswmDAhjFbYa4Yu5iRKh3yNjWXww1ldQPuoX0T07 X-Received: by 2002:a62:ea09:: with SMTP id t9mr36042098pfh.228.1548180722563; Tue, 22 Jan 2019 10:12:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548180722; cv=none; d=google.com; s=arc-20160816; b=sywrQII4r4bND4YWK+K/wP5SmMa0mm4rJ7Kqb87L+elyvfXLfRI32YJBU096DLm6hp Hi7q5Keg4Dc+71OqVkba8C9Dhao7D7TTImoijyfQu0Z4q4ir7Jam+i5KCRVIyqIstRmE i3x+LvI8zcG2CVYNnCH9ThaGFmLCApocMovfS5pixt8Mx9agelPX0bVaTzxigAaXaYC9 R3frSlIVNQkfxSqX5Smk7L3f277y9Q3lJUKfZFEhRMLf4RkGz52oZK13E5awdbhz5BEW hA4tGX3EfcEw7eCSuYpl0dTj6pHGUwLpZp3Tm66PZiJ36UBYiWD3YZrD6RWR26u0JRaQ BQ8A== 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=W+tcSbssL1cjoomd1/kZjJ7IjRwzQZIgCHeNiM3a0+8=; b=zauErTH7+emyJuuGVQciu7QyFNMpIUnOyuE9HhCfweNa0hSt1idBLz026EaP4eNA/e Y1PI/bdoOVKOOivgTiG6H1NmWMfBUgkrBh89QjX/FmhCHTX3M3/MamPNsu6RX2lDtuon PT1LmPMOki8IpUpXzMbVnE8bEc8e7sHw72t/86DI1+k+90YspgIIIAZy9FmkawOJlBG/ kN0219oe3gY5psFSGQaLkVZ2XNOBRKJofIUV3wnDbYSoqD+cfUSL8YoKXXSxONvVc1/W UOC0QD6yPrp/0I1Hc3qK81Ua6dYlzZbi76zVFda4kqsFTqcOII/KujWe+TJiiQHPBx86 KFHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iYX1E+Qk; 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 e11si15355618pfh.147.2019.01.22.10.12.02; Tue, 22 Jan 2019 10:12:02 -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=iYX1E+Qk; 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 S1726863AbfAVSMA (ORCPT + 27 others); Tue, 22 Jan 2019 13:12:00 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:32870 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726827AbfAVSL5 (ORCPT ); Tue, 22 Jan 2019 13:11:57 -0500 Received: by mail-pl1-f193.google.com with SMTP id z23so11875101plo.0 for ; Tue, 22 Jan 2019 10:11:57 -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=W+tcSbssL1cjoomd1/kZjJ7IjRwzQZIgCHeNiM3a0+8=; b=iYX1E+QkQtS+reozDRSNxJxAJ9t+crCH5YtMtbQ4hKqfNhGWIE6Oajd4RJIpXCTU2N JUI21kO42yJuv8h2ZyR1KtgfDrWQ88ir7AC0UbLF8NrzgjWKi715QVxMIgYfHMtgGM7x AdrigTyORi+AoTL5gf8Mvab/tfhrRU0HH3y6Y= 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=W+tcSbssL1cjoomd1/kZjJ7IjRwzQZIgCHeNiM3a0+8=; b=LT+S33qDBZX9vV8ASzvNRCKqFpuyXihmM2TvnN2W+zxd/MF7yy2cWZYQlxaow8Pzd9 HvcA8PPsBc2B/aBqk7ZGKGkuylqzwUueiMLZLNvQqZK3zHK9UhIHJAndJjW4sUhL73AW 4vz69Wxcpfx4SQ3veQE6fNP3varuF4AN5YSDVZTcm/VyJd6zDpUqGYCs74qsWKWLRk/p orpEVJSEdIwMHEbGHYF4UfZq5Y8HCcagLxlfnI6Cd3FsYZsQXv159VpYzIq2QVEuZTdD UB5+cJR9nB9l8DnLULYfGn4w9gsDMuUnyr8KCU6cGGgvappwkxol2/PQ6iQl/ioGcoWN PhyA== X-Gm-Message-State: AJcUukcKrNgkpUlRLBn0x9tcbrh9k0V5mGS60Z0JLipSll7GtcaDhMvW yp6yzKq8vPT3iE1Iwa6qUk2UNA== X-Received: by 2002:a17:902:2862:: with SMTP id e89mr35764673plb.158.1548180717330; Tue, 22 Jan 2019 10:11:57 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id a18sm23489919pgj.30.2019.01.22.10.11.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 10:11:56 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org Cc: 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, suzuki.poulose@arm.com Subject: [PATCH v2 6/7] perf tools: Removing CoreSight set_drv_config() API Date: Tue, 22 Jan 2019 11:11:43 -0700 Message-Id: <20190122181144.26645-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190122181144.26645-1-mathieu.poirier@linaro.org> References: <20190122181144.26645-1-mathieu.poirier@linaro.org> 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 4aa6193dcb50..9a4a8153e4c2 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -26,9 +26,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; @@ -638,54 +635,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 Tue Jan 22 18:11:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 156310 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7883171jaa; Tue, 22 Jan 2019 10:12:09 -0800 (PST) X-Google-Smtp-Source: ALg8bN77p6XQ7fAK0zbeLlVB59op44mMMvyYMDaespIeZg4yckRGxiMmZbxiJh+RwMGXgcee3czs X-Received: by 2002:a17:902:7005:: with SMTP id y5mr35450585plk.7.1548180729863; Tue, 22 Jan 2019 10:12:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548180729; cv=none; d=google.com; s=arc-20160816; b=Rvpm7H0LWQXAkDI77g28Jjk4/Yw7FrX2d/dXjutJHsSBJK9F1kBf+EsYt/EA7oCz5Y 27Kb1STaJ9/Ril1H6YIgkxBxq9dOXRiyyEjV3x4mZLolq2TzT6TH0g17k1Wy/7E3H7vh rUQ4AcGhB1U8MGr250VpOUarDG4imepY+GNCETjt+FyeksfYhWGB4pPeWafLA+W4/6lR E5CFgNL2ApIkZ0oHsL5I4IXTYp4v2ScD0H1pJV6Oy7mFgrHPv7spqOYsFpQg3/Hy3tG5 RqI5tuB4Qp2NwNr2aRX3pRVK6dBJijmMIF5fHHsB2Jr4smQf6e0Wp5W7xxIjSHo8/lOF /hkQ== 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=FYNEQv6/HlLtSpHrPvO+2R2XOSbdCGYPsATlW/3wPkz5HiLD84dyHps8URgD4dG9sY Wi1CwYWUaITmEZYq+hG6OHxeS5JVMaN5UiM3piquYtElAcNRZSkbELsnr+vyDN3+4ybx cYks8i2W4hpD4Igxqufkzf3ysUFjkNT7q73+V3HWoad9Mhxy2qpuoVixpe/nStP2pSck JG0n0WAdjyAAYVcEDb8jQ2fWnfzW3jVfdon1gEFSPsblyIwXyXbuZ6jIdAT7oY4qLdX1 CfcdhSioFrbBhvRj9IT6LPga4dM1hxahC7jyCXI1WDIDwrmLvIMfltMIjMcVIL/tDC/5 gdTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K7ZvJSuj; 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 y15si10844961pgf.321.2019.01.22.10.12.09; Tue, 22 Jan 2019 10:12:09 -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=K7ZvJSuj; 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 S1726913AbfAVSMH (ORCPT + 27 others); Tue, 22 Jan 2019 13:12:07 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38719 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726859AbfAVSL7 (ORCPT ); Tue, 22 Jan 2019 13:11:59 -0500 Received: by mail-pg1-f193.google.com with SMTP id g189so11406253pgc.5 for ; Tue, 22 Jan 2019 10:11:59 -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=K7ZvJSujgUfGxnCrede2OGo/ax6P3FNh6L3H192OJa8ot97BuR3wzx9K8SDLBeOkTe 4S3o9LR6UwV8HDoFSAR8Vq/3h8CRshuYiWFFmE6Wq2K1oNunLsPmHYFkR9NARbWi/9yK N6zEp3DoqJPXqPfYO90XrmuSlklLeIAfDcn9Q= 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=qTXpnkD8Alt/8T02zuBGKoaESM3UjnRWnY56amBvt5uNrEjZ67JKHcLl6I9auuJl7j JxfCoIRWzxP0jowaKco/1wbKsNW+ide5BfIRQEMqeWbeDw4ERUXMnYsQEHcY793bnoZV 7jF/fxviSH/WUzYCslctpC2ATbbGgv0yke8NY9epXQjTjWk4Mp6IUJ4/taCiQcZvE18O fP2XOeVmwwGFi2hCtEHdLyF8CIw2nI0gjGHW/nQ2iA0/WkReKYGFaO9/6ECXYOil9a+J a1DWtTvRQh04q8c1TnaA2RRi0ohoG1i5AvzSxOLDBaxQ58Z6wtBMe8Q2v04eslzR1jM0 L8Dw== X-Gm-Message-State: AJcUukdU+7EJelXo1XsJL1knxJ1GSZ46L+qkUy1G05RbGMBC5N8a1EYW u9uTScSVq2s8CXLItn/qemnX6A== X-Received: by 2002:a65:6684:: with SMTP id b4mr33005880pgw.55.1548180719155; Tue, 22 Jan 2019 10:11:59 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id a18sm23489919pgj.30.2019.01.22.10.11.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 10:11:58 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org Cc: 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, suzuki.poulose@arm.com Subject: [PATCH v2 7/7] perf tools: Remove PMU::set_drv_config API Date: Tue, 22 Jan 2019 11:11:44 -0700 Message-Id: <20190122181144.26645-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190122181144.26645-1-mathieu.poirier@linaro.org> References: <20190122181144.26645-1-mathieu.poirier@linaro.org> 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 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 {