From patchwork Tue Jan 15 23:07:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 155677 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5454531jaa; Tue, 15 Jan 2019 15:07:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Xgw7pDeqAZMR7rRf5UOD3BHW/Fe5XdOWRhSxBclOdhZQnB8zab1f20axDsA0lSpU9UhxL X-Received: by 2002:a17:902:780a:: with SMTP id p10mr6762356pll.54.1547593673465; Tue, 15 Jan 2019 15:07:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547593673; cv=none; d=google.com; s=arc-20160816; b=UYTInFWZvQXluBgCZ6AmKBFz2FPmjIUJovsU1Ohs7zfNME6I8HqadH7b/pOT6/alpX QIKT4PUMSBymU3RNogzLhJOn2VWHKyvanl9l4F/qaTmYAkcHwolkeNpWFXx8GYazcOrP TTQmfWozmuCMysZ4Kwbyoi5XqnX6TQYfiNduPug2Gg34BArF+MMzoIAqTsEjRc+vY/UC jJuSfWMDOaz9zc1IgE+G3AnESO/H0VYBQSadnd44EdQsxApDdmweAHupmRYeJuWeoUZy TJUDsiKDGO/t8nWHnCOcnMZc4b7c8JOWT3UgKnDkLugBM5Gmh2xExxIK2sfxxfxiV5y2 pCFw== 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=voXZlLjcF9iMfJYraScWxo2aiNSp6J0i0hFMp6bhq5w=; b=SSXO18a6rVJT2KT3tahoBUJ5tdLXSTDuO/Ce5mNclZF54L/wJlhQxBiCGXpGiC+Kby Hp/bEou7mqnHLRNb3P5Q4Dt01N7LH4LbC37FYomeDQm/dMR8ZqGgOl4AKgGYl99SSEZl AsbstYpbPMo3FWHPoaBHi/ktf6kms5MAjQWuGRmrfpsvmK52m7HWQXBzvjeu0XHUoZhl zfOkKb7XM2KO78k+ieYYtamzT+ZjbCzopAbKwULcDrY6KYk7UsE5xVJyOhxrY04GZPcP RjLDIgfEpwhfXtgonC+paErR1DpbG7HL+9eq9CSAeEf3Lvuw5Eur3DxN26FAxzYYYLmS J0nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RGx3oU3n; 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 3si4476923plv.258.2019.01.15.15.07.53; Tue, 15 Jan 2019 15:07:53 -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=RGx3oU3n; 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 S2391301AbfAOXHw (ORCPT + 31 others); Tue, 15 Jan 2019 18:07:52 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46639 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728757AbfAOXHt (ORCPT ); Tue, 15 Jan 2019 18:07:49 -0500 Received: by mail-pg1-f194.google.com with SMTP id w7so1869864pgp.13 for ; Tue, 15 Jan 2019 15:07:48 -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=voXZlLjcF9iMfJYraScWxo2aiNSp6J0i0hFMp6bhq5w=; b=RGx3oU3n6x8+7l4o/Ne17g9eKln9qFOkWUXrvDRCLKTIeYzgAOQy/bAZOkXLMTgVF+ yteMBn8xkbIaYkod4nEePuIaSFeCqPjEG9M5u/rLh2JaXM4YeZMpNXcrbcjCuCxnFep3 +OVBcBZr/ANaevqHnj/b9Kr21ZHOtwY2DQZiE= 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=voXZlLjcF9iMfJYraScWxo2aiNSp6J0i0hFMp6bhq5w=; b=I2KX3LvWYGiLuw8aDdxbv/kkPusIYMBxQuHWGn9qSVprxqhHRhlB17vXVy5Kp4ap1d HJJ6KBKkNy2dTx8So1FmOlWhtS5n/CGP9GLxjNf3KSMV0BjbsH+/wt7Mwrv5+F5V56L6 T9zw3RYtaqzddx15wZfo8Czz50kMWreD6Dhi2hsgTipSjnt6tjc5IOpYRU6B7KJGaDXt hUzOqF8/duX5qoc/hadrrFMuD9X7JXgAKmDqghpmFxobIU+L8wHzwbkIOanW59GfnUjD dQDX4NbWsgeGUIhhxRM9bPwMLhNTBJSA1Tje5h/TWOkoBVpO/YMMVQzockbeA328fCrL 27Lw== X-Gm-Message-State: AJcUukd3raZIi6M9YZTSK05z78Qk53GSMb2vxFyqgkQvPTmI0kwud9BQ AZKa3EekxZAizP+f0FrFhOTzQQ== X-Received: by 2002:a63:61c8:: with SMTP id v191mr6052271pgb.242.1547593667822; Tue, 15 Jan 2019 15:07:47 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h19sm4985928pfn.114.2019.01.15.15.07.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 15:07:47 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org, gregkh@linuxfoundation.org Cc: 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, suzuki.poulose@arm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/7] perf/aux: Make perf_event accessible to setup_aux() Date: Tue, 15 Jan 2019 16:07:36 -0700 Message-Id: <20190115230742.13730-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190115230742.13730-1-mathieu.poirier@linaro.org> References: <20190115230742.13730-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 --- 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 Reviewed-by: Suzuki K Poulose 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 15 23:07:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 155683 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5455124jaa; Tue, 15 Jan 2019 15:08:32 -0800 (PST) X-Google-Smtp-Source: ALg8bN6u8wVI1b5ATqX1xIXvn4LKXjhxmjVA91+FmL2K5rKrnh14oHgJLIhiqEJDZj44/w924tRo X-Received: by 2002:aa7:810c:: with SMTP id b12mr6503592pfi.44.1547593711942; Tue, 15 Jan 2019 15:08:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547593711; cv=none; d=google.com; s=arc-20160816; b=oKQbNLHVYWb84Kg7evQiQGiJMOSb466Zz1/yEVA3zADwH+91Px/oOmzrrFJfe6LB0F 08ctsAgjt3AQ9CMiflVUVZe5jYZhQ/bO9rjJCshlQv8ptMwSyTPj0Zr9iE1Xk+7fv5sN oy8db9NqdXt8oW4FbwwAkNo1b6ecmC5NAP0sZgHC2rHM5S98CdlRjx6kb1khmo8RPUoQ vFfBunLMlS766Acx1RRD0ulSXqB95CKZmIf0hguq+brZxnAljZprUkhndcPaLfrAnqLB gJNi/JQd8rrvShjnGAPf79eP7hhycyXM4N7F9jr7ip3v99eJ+3VY0Cc14VzY6jiE8Ir8 TI2g== 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=XDWNDjej1vaQghEKuWRObLfufBBUVnZJNWEVf/9UfwU=; b=Tpd6N/+kt5+7Sk/PTY7/cn0o0dy8KY5x7079K7faRf63mhHTrXOT2fnFjD8EySAUe5 4Yo7wm4Xs0eEUIbghzyqtlCWzSmnD4ALvwYUUUNh+KlgcX76DhrzS7A/LlXnqit3sQT0 +mEoV6zoYpi4W0kF2sUW8jhNAJrbqlO43VG6kM6lj90N1pjMynPEDzsJv7tYmCibI0ET iCnIeAp4kYfX4peTIR7iKzzkd9WTZryxp0HhIqOJQGTjVj48za91hkMawZorMIXyl0eo CExyXR1GHuKXFRuIrz6CzM3eQHk5GUzPeEPXRj7ELLUqyscZVuEVOSnpx+ce5O4xwQQU tLjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b84Jmktb; 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 c10si4437322pll.271.2019.01.15.15.08.31; Tue, 15 Jan 2019 15:08:31 -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=b84Jmktb; 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 S2391386AbfAOXIa (ORCPT + 31 others); Tue, 15 Jan 2019 18:08:30 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44025 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387748AbfAOXHu (ORCPT ); Tue, 15 Jan 2019 18:07:50 -0500 Received: by mail-pl1-f196.google.com with SMTP id gn14so1989144plb.10 for ; Tue, 15 Jan 2019 15:07:50 -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=XDWNDjej1vaQghEKuWRObLfufBBUVnZJNWEVf/9UfwU=; b=b84JmktbH4LgEz2UKivbHhzC09x3UMXzJaMj8si6l+upZCirCs1QoNgBzprVBbDy9w FBzU4OKP2qSRSptbvbFV2QWDV8g/43fxihmkXRshEECSB0uW5kShD9zVMOAupagb+fO0 6GZki9k1wHHPDcr8WnLZ05pU620ghVn4IrqLY= 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=XDWNDjej1vaQghEKuWRObLfufBBUVnZJNWEVf/9UfwU=; b=cnjTvaq7D/0yj5zFe5HM+udZSIRrMr0yGeZerfQgL1eixlxOdNwEdwxq9ug7mLTd9y wUY7kWuDrg8JFTp2ArvxKmD2hE2XAN4aQIOwiwihXUop64cPhwqtjM3J2Vdtg8SxFiko nXKiKoz/HFq7DivSCTuHHiBxqAIzqLenmjjbhJPVac5rrls/WdHh4Md4VzEFQncmBrAb cUysK6NAc5+0PW7yfsQUqEX90LGLqldQ7z6zhInaJDgj3MbTwf22COngfVMBtgHgUnDK D3iSaCMQS9jWsJHP569C0H0cnMcuHiOqyyWf7zj5aFPPQof/zJHWCo8uxu7AAGINreTD 7Ogg== X-Gm-Message-State: AJcUukeGT3LWODMEwLjs8IHhL0Ng60tO07k8h8sjyV23jziTjhuKV4er k3cA7oXw5KNqX/d487yHt268FA== X-Received: by 2002:a17:902:6b87:: with SMTP id p7mr6690582plk.282.1547593669668; Tue, 15 Jan 2019 15:07:49 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h19sm4985928pfn.114.2019.01.15.15.07.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 15:07:48 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org, gregkh@linuxfoundation.org Cc: 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, suzuki.poulose@arm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/7] coresight: perf: Add "sinks" group to PMU directory Date: Tue, 15 Jan 2019 16:07:37 -0700 Message-Id: <20190115230742.13730-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190115230742.13730-1-mathieu.poirier@linaro.org> References: <20190115230742.13730-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 | 43 +++++++++++++++++++ .../hwtracing/coresight/coresight-etm-perf.h | 1 + drivers/hwtracing/coresight/coresight.c | 17 ++++++++ 3 files changed, 61 insertions(+) -- 2.17.1 diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index f21eb28b6782..292bd409a68c 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,38 @@ 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_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_symlink_sink(struct coresight_device *csdev) +{ + struct device *pmu_dev = etm_pmu.dev; + struct device *pdev = csdev->dev.parent; + struct device_attribute *dev_attr; + + if (csdev->type != CORESIGHT_DEV_TYPE_SINK && + csdev->type != CORESIGHT_DEV_TYPE_LINKSINK) + return -EINVAL; + + if (!etm_perf_up) + return -EPROBE_DEFER; + + dev_attr = kzalloc(sizeof(*dev_attr), GFP_KERNEL); + dev_attr->attr.name = kstrdup(dev_name(pdev), GFP_KERNEL); + dev_attr->attr.mode = 0444; + dev_attr->show = etm_perf_sink_name_show; + + return sysfs_add_file_to_group(&pmu_dev->kobj, + &dev_attr->attr, "sinks"); +} + 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..529a47285c0f 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.h +++ b/drivers/hwtracing/coresight/coresight-etm-perf.h @@ -59,6 +59,7 @@ struct etm_event_data { #ifdef CONFIG_CORESIGHT int etm_perf_symlink(struct coresight_device *csdev, bool link); +int etm_perf_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); diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 2b0df1a0a8df..526f122a38ee 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_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); From patchwork Tue Jan 15 23:07: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: 155678 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5454573jaa; Tue, 15 Jan 2019 15:07:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN7YMWk6P7CYLvXhtSE/7PeSV6z/sOODa7TyiMcOpn3YkRmJZDcKDIMCpRxCgzpmb3+OmH7N X-Received: by 2002:a62:4549:: with SMTP id s70mr6419908pfa.233.1547593676429; Tue, 15 Jan 2019 15:07:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547593676; cv=none; d=google.com; s=arc-20160816; b=YfM00WKlogUhbNA2G1BVoj/y7xgff6tNNFkqkP+E7O2XdS0vwn6TGFpm7UjcFmvT3K PhXUDxbhl4+y7dCgVCT/5fdUHvK+p507dYKIN346bhyX6SxXKS65rApK1SjEOIJ6HBDR WAb/wAy0Dqk6YOqvmyyw0PSpo8LKRO0QpX2bRzK8Qjo7twjpWA4iyM3IkPHRu/YA99nL bIyT6c3d+7Vx6cvxVhb3OkYlR7GZ9jXoV9Ypc7ojertO5eyCtWsEzfHjZG5pMJWRJXmP ncRwpKdl6K21y05Jwr5cwJ7G0y910DqO/ejBFhSy8FBzukHIdoxJk5q8sGgrqihrmx++ dmMg== 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=yP2FasSJHEKUvmhM1NueUcXAVpTqjNNg1l20bnmEqxo=; b=jJhZ3PE/XpBND3wpl9blel56LAu105N/1lma5kVZyQkqZjD6xdk+XmwimAaWTrUjfe YW5RHVcI7F5YkzB5DGwugCrcFBh9gkwP6b7eHiuFY+uLU7OpLc85gTaq502N9XQ2DiSH ghH4jio+wbFxDXxeeQ4fioFUVpHMwJ7oGGEl/ZYwl8ooSseCcT5drVZYp8/prXL8npb7 Y1O5jbYURqtat/xEMqGhXRxG7eC8XXDaA04fRGvdsnwTyhe7CixXohr7Avke2rCHJnCf StDPp5kuy3bYYuE4TqZl32Z7uzAK7m/uSH3Hf8oQB8+7DKZUOW2VXdPj1nROtx8fX1J+ zoHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f73yPWZG; 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 o28si4495705pgm.238.2019.01.15.15.07.56; Tue, 15 Jan 2019 15:07:56 -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=f73yPWZG; 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 S2391314AbfAOXHz (ORCPT + 31 others); Tue, 15 Jan 2019 18:07:55 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42999 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391292AbfAOXHw (ORCPT ); Tue, 15 Jan 2019 18:07:52 -0500 Received: by mail-pf1-f196.google.com with SMTP id 64so2023263pfr.9 for ; Tue, 15 Jan 2019 15:07: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=yP2FasSJHEKUvmhM1NueUcXAVpTqjNNg1l20bnmEqxo=; b=f73yPWZGnexRNZGn6npQodSzy1FwWsuGGI8atkevYafdxTj9Bgi4zFdrGmQ9dxEQk1 AjFqAi50+sW9npyd2KpsXn/7W1Z+IqbOoib12qDYV8QkulSU9i3YJ4kZ0sAK46GlJ59r FSe5TOBJyCwUmmxcqca3cyPUZxjllYob/RUpg= 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=yP2FasSJHEKUvmhM1NueUcXAVpTqjNNg1l20bnmEqxo=; b=J36Pv9lbgyvm5gV4PQ1CIkgVmsm6pK1e1RqUxLhoAEHrlpTg4NZI2X6HYcmkXkQZTV PoDNb84asGycDQcr4aiIoip70A+ejl9DxdbgtidDAqdn7T4Rchyd7PETF8Dj+BRU0iCK 8/ccXR/tZI0O4MccQrm5XeDTDoxXUiWrg12FhwV+TthzA1g64UwiOuc7GJ0JYjucY1Uv YBLONMHMyj+SIbJ7sX1aTxAbNJe+HoBPThQy+oNSyLMFCFricavyFhrNPL/YzKQC05Ip ZOAzmLE6boSRdNsamOuGzM7OgYcTjTptJZ5XlaoDco86dacYC+WLhZ1gRdMeW5uc3th8 Whmg== X-Gm-Message-State: AJcUukfEIfTyBjr2AA53tv3Qnc7QS0gH26u1fcME/7OW1D7OVWjAp+Ws 0ZxfpnGpfGXUFBevKZ7ozeGA+Q== X-Received: by 2002:a63:413:: with SMTP id 19mr5881392pge.7.1547593671526; Tue, 15 Jan 2019 15:07:51 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h19sm4985928pfn.114.2019.01.15.15.07.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 15:07:50 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org, gregkh@linuxfoundation.org Cc: 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, suzuki.poulose@arm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/7] coresight: Use event attributes for sink selection Date: Tue, 15 Jan 2019 16:07:38 -0700 Message-Id: <20190115230742.13730-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190115230742.13730-1-mathieu.poirier@linaro.org> References: <20190115230742.13730-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 | 16 ++------ drivers/hwtracing/coresight/coresight-priv.h | 1 + drivers/hwtracing/coresight/coresight.c | 39 +++++++++++++++++++ 3 files changed, 44 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 292bd409a68c..685d16001d0b 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -201,18 +201,10 @@ 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. */ + sink = coresight_get_sink_by_id(event->attr.config2); + if (!sink) + 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..071bb98d358f 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(u64 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 526f122a38ee..7e2ce0beb2a0 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); + unsigned long 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 == (*(unsigned long *)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(u64 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 15 23:07: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: 155682 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5454940jaa; Tue, 15 Jan 2019 15:08:23 -0800 (PST) X-Google-Smtp-Source: ALg8bN6WdKzzoUTW+uTbNPBCmufaq/yn9yRGsxYVITrNUtYEbMEcLf9/5vnLtERs8jZ+6YvYrTH5 X-Received: by 2002:a63:2586:: with SMTP id l128mr6105235pgl.104.1547593703075; Tue, 15 Jan 2019 15:08:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547593703; cv=none; d=google.com; s=arc-20160816; b=z450EDHe2EsdCHyrFOBjaGIH/Sc3uf9xQHAO1Aw+o9uWptFM7MQQVzVMDTTUj+XeWg vJS/p/kXdANFVkQcqvM4cnyEl2/q1EH9r9k5Db8c7TyNSvG2mSDb+Di+K/D6X9fTYUCh +A/nhNAouOCd6ZTQSeXMfGwtUKpYLVg5hhYxYZmzeWnJCtM0OxBGKvVzGT4ctvnhBN1U GCQmccAZvky26OSqmFJBI2tSNgCmj7SyHN8kCTKo3TMy120xEbJ5hcv1WIK4/F4mVOFf +0cYEktH6Nua7XgcPZx+iNNTlEiy2tc60Y4ZKrXCA3Ji3KDMep0yc5Mqq5XSJEDgSy4Q h9tQ== 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=bBbcO/FLwThPnzi9ctGancax6oPRinsiTg0II3oScgw=; b=tXsqAGiC3rTD/YvJ3MZ0ul9X/R+a6pncAzwEsT6/YRkPZ4oKnXQfcHrtzZFwuM7iMK iinPm1DzCBdh184dVK/t2sR27C5a2gTYZ3zw9nBdiycdMDLV5AwCTSwws4C0lA2gAF7I UVZmtCa9IQwvWJQSQeBo8ttcajDcj0PTa3vg0C3a9UfHsw/ygao0BpOw8HWqQ18lafxz DG9xvUxn1GrjjyXUMsMrrs8fwwyPrGmlReXl1wt7+MJmhoYAzsKVVU8He0YIVX9QeRoE AIzdezijxbbzbQfmVIjBKGbk/Nj2Yv3o8z6seklaY7tQzCOzC5L3jf6np7x3KSMb6wjk sXxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=On6RXlUU; 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 c10si4437322pll.271.2019.01.15.15.08.22; Tue, 15 Jan 2019 15:08:23 -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=On6RXlUU; 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 S2403753AbfAOXIW (ORCPT + 31 others); Tue, 15 Jan 2019 18:08:22 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45076 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387750AbfAOXHy (ORCPT ); Tue, 15 Jan 2019 18:07:54 -0500 Received: by mail-pl1-f194.google.com with SMTP id a14so1987014plm.12 for ; Tue, 15 Jan 2019 15:07:53 -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=bBbcO/FLwThPnzi9ctGancax6oPRinsiTg0II3oScgw=; b=On6RXlUUcE77eKNO+PGQZ6PETa/RedcAgn21UjeW5c60TBBoJQX7Io8Ezm7UFYxu39 hsyo67UlNJInScryS+W+t/3wr6aRdEK6LtYCajq7Ys2wG1l0Ee6w8LfltwUDtQAvSmUN DZAa46lZP3mjb0uw0IWOZU6BuFaab+JcpIGTY= 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=bBbcO/FLwThPnzi9ctGancax6oPRinsiTg0II3oScgw=; b=JlCCcPfYOoWhxS0V0gdAyPvTlmGEb0M0oiqtQzq9prjM7EtfWV2/1cpZ3BWL7iJy3v zOUSjpWXdQFtuey0+u2TmsoKZtJyz8mjl/VWa3uiHf9gScY4FrI+9bkakYbnxbUlggU5 TOkPmfeWTsjgsVFBranzrC6GVWIZvvdKZw4lh57fTDFXpkfn0gZfWvMjiQ+a54RM2LQO RnBeFPDI6tASOkE92b9RdCbH7a3ldM0GlAkyhWBqT8otSzhMrQXJwxlhnigVStK3Zg6s cfWv824cgBkCUn+wypIO68XAR2fVxFet2nMUqEbnJXL4EMfOnAHoFQDaCgck2EKyzao5 FJCw== X-Gm-Message-State: AJcUukc/2sQY+cKS++gKVGQDIRNe2jNCJU5BW4dGD2V6CLDeOsgsaTEB WWG8t81BTA2J5MKacDWUVvKelA== X-Received: by 2002:a17:902:5066:: with SMTP id f35mr6651355plh.78.1547593673313; Tue, 15 Jan 2019 15:07:53 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h19sm4985928pfn.114.2019.01.15.15.07.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 15:07:52 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org, gregkh@linuxfoundation.org Cc: 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, suzuki.poulose@arm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/7] perf pmu: Moving EVENT_SOURCE_DEVICE_PATH to PMU header file Date: Tue, 15 Jan 2019 16:07:39 -0700 Message-Id: <20190115230742.13730-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190115230742.13730-1-mathieu.poirier@linaro.org> References: <20190115230742.13730-1-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: linaro 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: linaro --- 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 Tue Jan 15 23:07: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: 155679 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5454653jaa; Tue, 15 Jan 2019 15:08:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN5Z7eHcsxguX1aCW6xq1jOBxyxH7OURj5WUlDPMNSWt7mZXdV66d2lp4SFAN4J0xyepA2ZH X-Received: by 2002:a17:902:7581:: with SMTP id j1mr6628344pll.308.1547593683119; Tue, 15 Jan 2019 15:08:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547593683; cv=none; d=google.com; s=arc-20160816; b=Eim+u7UQAOo5zhQp7eyVcXUiTFpE3udlrdnDd0tFJO3LmKL/wHPrb0mP8D+j3N+5e+ /gBqkEzbFJNVtkaGKBzbau4P9kOhTFM6H5XmPKDsDxtLcwlfhRetQSWl3pdGpIl8cXy3 yY1YbOtac2pQZukJug9pZyd3rSABvDL4P7v4Ox9AO7/JnB0LAv0Y23P+lZCzh+VZA3Ol 0SsjLNmAU4jNQNOIm7DwRJd5WclR06zR95SLAaxlZjFGA4W9SB6G3McOtQsxBJ2cGWWw hCfqgIB/tMwGj7OFuivNSKDwFwJh1Q/O9FLOFwHMbvhXUxlI26yEwq2Q+eQohxhC7OgG VjWg== 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=gPrWMMpDRosRuuCKq7RVqqPV5xVc5OS0HdA7yr9gVbk=; b=y8ejYSa4j0eWPLr2BmjDzIc58neXaEdDiclwE1ocIfS+Mece+qCi0+CqwttYgZXtsq czeJpYHiDqKE5JCWkSd/KrrLcnD8z66xnPnfAOULVXrsJd2xndEvpab24ybCgOfrkWx5 edQn6W0otFM8ux2g9ttaQe/PnNLtRbPTT3rpF5txOzQuV91vGy5I2F+hqifJvunav4XB 4DMCGJQzhk3tXbDTmwfRpdqI29MWa2LAJF3e6TPjr+hzADKM1floKN7gPcNr6VAvVgkM RY0bhdIrUL4dNVHVtQPURlqtpLwpp0bEF8EfpMJUK7/288jUCEPjJUTVMzQ24L017huB EU6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QqRrsVaB; 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 e8si2217435pfc.248.2019.01.15.15.08.02; Tue, 15 Jan 2019 15:08: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=QqRrsVaB; 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 S2391344AbfAOXIB (ORCPT + 31 others); Tue, 15 Jan 2019 18:08:01 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:47069 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391292AbfAOXH4 (ORCPT ); Tue, 15 Jan 2019 18:07:56 -0500 Received: by mail-pf1-f195.google.com with SMTP id c73so2013922pfe.13 for ; Tue, 15 Jan 2019 15:07: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=gPrWMMpDRosRuuCKq7RVqqPV5xVc5OS0HdA7yr9gVbk=; b=QqRrsVaBJ7rICeZftdrm7Ke54BLqO4IpJ+ykpcY8TsczjNwJap13T56otWVRsJ2+6d HQIW4hI5sXRNBTbBG/FIL660lxD3zLbuIlWAXp0VjrpyFfrw5YhfqDp4DSvpo7XBtL+/ qN5NlzimZrdkkaRSehkgJWGsM4F4jzcZMfrAU= 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=gPrWMMpDRosRuuCKq7RVqqPV5xVc5OS0HdA7yr9gVbk=; b=jT1e/aCUZjo530Syqbjo2E//q5Y/2OGLoJhu+s1Bco3QMviZvaIiyaG6mK9To7Q/qZ a+TDLTdI+hIZUvT8bq3cYW7Vd/r60xmWK32FkIFl8yBvTHwGu1yq7IyeTcEgxJ0bvA7j k4z2siB7LAGxwbMpCHuwwNf8lMyEs6DIj/Tn+wyDKCk45VZZaRdDD4Qv1mfXvBIb7rlq AfmZLlDMDQoe8k9cyLZ0qMglES6jPhhpzRbq/gDuFwaRb5fg/Qez8EvG/Dd4ZNqdD773 3YQYe+HWnR/EKM85B4kKUpdQGv15639ds6rPqn0WLoRthtp91N6T/d9eSUVgCJeFGQJ9 M0yg== X-Gm-Message-State: AJcUukfbH8fLY1cSuk74MdFSXCkIB2bVwd7aqZ6URPiCiDgB8EwkUhUZ ZEBzfBtXiIQ0GwZ3xeFQeTCfLA== X-Received: by 2002:a63:6cc:: with SMTP id 195mr5958903pgg.401.1547593675503; Tue, 15 Jan 2019 15:07:55 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h19sm4985928pfn.114.2019.01.15.15.07.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 15:07:54 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org, gregkh@linuxfoundation.org Cc: 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, suzuki.poulose@arm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/7] perf tools: Use event attributes to send sink information to kernel Date: Tue, 15 Jan 2019 16:07:40 -0700 Message-Id: <20190115230742.13730-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190115230742.13730-1-mathieu.poirier@linaro.org> References: <20190115230742.13730-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 | 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 15 23:07: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: 155680 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5454801jaa; Tue, 15 Jan 2019 15:08:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN6vkeVYKsPkivML26fIICrrq7zrmivrSShJmU3XGpEWGEuODQm4i0WuRVNEfMxqLemTR89N X-Received: by 2002:a63:5346:: with SMTP id t6mr6100202pgl.40.1547593692990; Tue, 15 Jan 2019 15:08:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547593692; cv=none; d=google.com; s=arc-20160816; b=FIpr5G8cjc7lpfWDNnPz8jB+gUbtG4iOvb/tRR18YiotpPaR/8cf6sN/H2iPFs8g8a BF9tFLLZ8vM0np3rkNeibUS4hLVU9v71wSf9s/ysgOqpSBnkfVDzs0RllBQM1MtXpsr3 lKd7qsMI3eVrYseJQzha6oZZIKtQP6A4uByQr/Ij1cry2SfsZ3ECCfGOicenTLVfh2qt TBrIUYO8IVlfw9IBITtP96+9A4rlD6D3uwmFlIgrmi6Jzsppl34qHxTKprjYYWhooDHU aAR9UynYU6HZTcKC2yTizGLTJZVxJ9dp9vzQC466sRJrAimMBO6lMUvL8ASDMb3KVU5H URKA== 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=HEG9LzH3wQxDtWIBsKS29pZZNhdND40FEPjRZJl/8NRAYTG6w8ssrJmggpENSV2crT Ri1wT6ueaO72XloNDMsKHrwD/819/FEYNTDpTMx6wFFPC0w/cZDSyiDzHyVx/nodgQkn Hdw4dR9h9n8GZsx3khZd+1Um0ce7oDdWn6W0jvOi9n1IfeGLoNCMffmiS45Iv6iN4djO Ur5LDtrUOp5llM6PB5LmKdeItXr+ZAbfiubnkq/1XuYSnodoLXVKrtHFp2Sa4vpc0CZt +Lzt8BHod3ekY7bO3vvFipMsY7FiCGb/FBBwZU2kP6rfccYjLjHwFqBFt7Lp7qptd69b J+9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FhWvV2jW; 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 u28si4219177pgn.436.2019.01.15.15.08.12; Tue, 15 Jan 2019 15:08:12 -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=FhWvV2jW; 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 S2391332AbfAOXIA (ORCPT + 31 others); Tue, 15 Jan 2019 18:08:00 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46220 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391285AbfAOXH6 (ORCPT ); Tue, 15 Jan 2019 18:07:58 -0500 Received: by mail-pl1-f194.google.com with SMTP id t13so1984163ply.13 for ; Tue, 15 Jan 2019 15:07: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=FhWvV2jW3/XhC5+T+avYrTigCzmBbikp0R7D0LvqiJVqYCUHY4ajRCElkIziyN6xu4 zH9BHEvTLavNGPfVnT7pU4BCTGCv5ycPbz93ubvn3TPu0l+DG+22XY8EWdiDGwl4W4Sd uvhg2oyyi16g03Q+sE47o7o37DenxghqDzliM= 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=IeI6SVLldti82Fxqog+bdMlbgFsI0P7yz7CIBhaSN3qBy5FJtdt67qCDC3xRR52WRG C8MjGUWG8ph6GOgJ+SnzoK7Wpqk+Lo9/S/g2vKU6u37uqu7nxfNnpInCoAAD/hRCkJqA d/c7SEVbUqqFdItHSM+CCzRjdaR2egeOd874K9dMiXE/Npy9+OnOWHShaH0Q+KsNwfWw D7XYsMYB25pj1+V3ae2QzKHE+PBiYm0tLT8drfh72Fv5y5drHwNQ/J3UbWtlN1uN8EHD jNe2A7sfI4HQz6PJuVgf2rqZtvXZjlzhNTxGX5p41WnZvVS8vkjxqfQIe4HRTw4HqAdi vBVQ== X-Gm-Message-State: AJcUukfzb/LjfQnbb4eecWX7HpcpH/duGvNje9r87SQnRiq+s8yttOb7 CTmzc//afAszZ6VxTmDFS1+uIQ== X-Received: by 2002:a17:902:b090:: with SMTP id p16mr6605089plr.190.1547593677531; Tue, 15 Jan 2019 15:07:57 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h19sm4985928pfn.114.2019.01.15.15.07.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 15:07:56 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org, gregkh@linuxfoundation.org Cc: 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, suzuki.poulose@arm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 6/7] perf tools: Removing CoreSight set_drv_config() API Date: Tue, 15 Jan 2019 16:07:41 -0700 Message-Id: <20190115230742.13730-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190115230742.13730-1-mathieu.poirier@linaro.org> References: <20190115230742.13730-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 15 23:07: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: 155681 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5454829jaa; Tue, 15 Jan 2019 15:08:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN5oan9hNTkOfCFvfK5nZz46yPlfujr7Rb5I6OxwKwnrGNbuNtzE9zMRHSd3YvKgxcW9BEEA X-Received: by 2002:a17:902:28e9:: with SMTP id f96mr6592777plb.169.1547593695426; Tue, 15 Jan 2019 15:08:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547593695; cv=none; d=google.com; s=arc-20160816; b=IUWcRABJVQydTjmUNIiwQRe31J9M+/kHmS7QxsSHMreMiH9sjZbKXgB47R3Aw98QDs pD+0jejuO7LtOlkGHmiOLtQKdZW0TQuRvaGP1nPqPjtvJVDwgQJQvnxdlzRIIxAXLHZ8 L9imLrw4FxvN+GJgDJjxL5+CECfTT2kcNR4+WMS7mJYKv2eEF5uWv9lUUghbB7etKoc2 Akn8yAj+KrY7A1zpDuIK3zjPTLZQ0zExfEOecViF+qQix0TI1MQDT/hkIPVcJOlXHcr8 xZwfVwmhrnqvgrP7WwaTQ5v5VJj2wE5jv0lLXCgqD4MEgtI95EwG0pH8b+7NeUrYppK1 TykQ== 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=GefTdFIkHpsBOPaMGc0udOBLHrKDnje+7oY7xUwosiEpmNLq5ncxiCZ+IVTG1r+pRh BIcJcMDDQzJyQuECGbybcb0maxnP6NGEvJjUkN4GmltfbB+qpxp+rR88GIzFlNMKdS6n JbnN/s2r0vxXIEbqF8pwChy+BhROLrtLsqBVIB/vtSTiwVQiOu7kexTTc2vGXWh+1hZ4 GrPAiG9FvUMeBWz3BIB3pBTve28jjzYcrHApUNWSy8NOjzvb5uGpd3tJYu0DFvSnTkHE VDP4qB4LDKQ6Hf4jeEEYYGF+6BCIilCAdoTV0jK8aRevTl0Ud9BP/AFaCtbpiqbalVuV zrgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RrU+4xJY; 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 u28si4219177pgn.436.2019.01.15.15.08.15; Tue, 15 Jan 2019 15:08:15 -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=RrU+4xJY; 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 S2391367AbfAOXIO (ORCPT + 31 others); Tue, 15 Jan 2019 18:08:14 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:42274 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391315AbfAOXIA (ORCPT ); Tue, 15 Jan 2019 18:08:00 -0500 Received: by mail-pl1-f196.google.com with SMTP id y1so1996435plp.9 for ; Tue, 15 Jan 2019 15:07: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=RrU+4xJYf4H5FDrj4GZKoITDCPTj4WYhd2IGo8DLql/zAa6ZOFiAo7XKTBOEkNHP6h CKuH4cJklJdukiMjaU/Szygr5aSATpa760ylb6fCCVB2JV1WmCdGnOhvhWgctC+OQSr1 5F6TXUVe0QFZ5sdKUuRPNnIiukrSxVRvu9LKQ= 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=BRsSGiim5cWD9lneqXjOs+qOhY5nSxu+UuvDfqrDBnfbzsBrsmeE2fzp1aHpVUcBFh Ld/ZJJdUTGgN9H/cQ1oXaMDyzSugXlEY/7EOLWIS/8C7sroIZehAUKJN9WbAdMANrMFz Ip0hLqHGEBZ+fBeTVuPZemVJQCnyAsSJ4iX/v5na0AabffP05o9v16JF82Yt8eJ4IYbu 0wDZCFcR3qwp9PivwbT7KDz/hT06ZAjRPzPuQxNIP4ZtqP82kELLw0xxI/lEGrYqAwA/ dnoI3aXWPsSWAN9h6MNwJqAq7T3RYlbBU6crWR2Kdl0+T54irYbeSM5bv1cm+YiepWPv Ly+g== X-Gm-Message-State: AJcUukc+ns9QCIx0NIXZqWEGEiLuXljpl0hgJW3bFo/vZRCphWFjtJ9z NFU4i6LrL7urP8PwNCjB9WPQnQ== X-Received: by 2002:a17:902:50e:: with SMTP id 14mr6510134plf.141.1547593679318; Tue, 15 Jan 2019 15:07:59 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id h19sm4985928pfn.114.2019.01.15.15.07.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 15:07:58 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org, peterz@infradead.org, gregkh@linuxfoundation.org Cc: 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, suzuki.poulose@arm.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 7/7] perf tools: Remove PMU::set_drv_config API Date: Tue, 15 Jan 2019 16:07:42 -0700 Message-Id: <20190115230742.13730-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190115230742.13730-1-mathieu.poirier@linaro.org> References: <20190115230742.13730-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 {