linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: gregkh@linuxfoundation.org
Cc: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 22/28] coresight: tmc-etf: Do not call smp_processor_id from preemptible
Date: Wed, 19 Jun 2019 13:53:12 -0600	[thread overview]
Message-ID: <20190619195318.19254-23-mathieu.poirier@linaro.org> (raw)
In-Reply-To: <20190619195318.19254-1-mathieu.poirier@linaro.org>

From: Suzuki K Poulose <suzuki.poulose@arm.com>

During a perf session we try to allocate buffers on the "node" associated
with the CPU the event is bound to. If it is not bound to a CPU, we
use the current CPU node, using smp_processor_id(). However this is unsafe
in a pre-emptible context and could generate the splats as below :

 BUG: using smp_processor_id() in preemptible [00000000] code: perf/2544
 caller is tmc_alloc_etf_buffer+0x5c/0x60
 CPU: 2 PID: 2544 Comm: perf Not tainted 5.1.0-rc6-147786-g116841e #344
 Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Feb  1 2019
 Call trace:
  dump_backtrace+0x0/0x150
  show_stack+0x14/0x20
  dump_stack+0x9c/0xc4
  debug_smp_processor_id+0x10c/0x110
  tmc_alloc_etf_buffer+0x5c/0x60
  etm_setup_aux+0x1c4/0x230
  rb_alloc_aux+0x1b8/0x2b8
  perf_mmap+0x35c/0x478
  mmap_region+0x34c/0x4f0
  do_mmap+0x2d8/0x418
  vm_mmap_pgoff+0xd0/0xf8
  ksys_mmap_pgoff+0x88/0xf8
  __arm64_sys_mmap+0x28/0x38
  el0_svc_handler+0xd8/0x138
  el0_svc+0x8/0xc

Use NUMA_NO_NODE hint instead of using the current node for events
not bound to CPUs.

Fixes: 2e499bbc1a929ac ("coresight: tmc: implementing TMC-ETF AUX space API")
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/hwtracing/coresight/coresight-tmc-etf.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
index b89e29c5b39d..23b7ff00af5c 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
@@ -377,12 +377,10 @@ static void *tmc_alloc_etf_buffer(struct coresight_device *csdev,
 				  struct perf_event *event, void **pages,
 				  int nr_pages, bool overwrite)
 {
-	int node, cpu = event->cpu;
+	int node;
 	struct cs_buffers *buf;
 
-	if (cpu == -1)
-		cpu = smp_processor_id();
-	node = cpu_to_node(cpu);
+	node = (event->cpu == -1) ? NUMA_NO_NODE : cpu_to_node(event->cpu);
 
 	/* Allocate memory structure for interaction with Perf */
 	buf = kzalloc_node(sizeof(struct cs_buffers), GFP_KERNEL, node);
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2019-06-19 20:02 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-19 19:52 [PATCH 00/28] coresight: next v5.2-rc5 (V2) Mathieu Poirier
2019-06-19 19:52 ` [PATCH 01/28] coresight: Rename of_coresight to coresight-platform Mathieu Poirier
2019-06-19 19:52 ` [PATCH 02/28] coresight: platform: Make memory allocation helper generic Mathieu Poirier
2019-06-19 19:52 ` [PATCH 03/28] coresight: Make sure device uses DT for obsolete compatible check Mathieu Poirier
2019-06-19 19:52 ` [PATCH 04/28] coresight: Introduce generic platform data helper Mathieu Poirier
2019-06-19 19:52 ` [PATCH 05/28] coresight: Make device to CPU mapping generic Mathieu Poirier
2019-06-19 19:52 ` [PATCH 06/28] coresight: Remove cpu field from platform data Mathieu Poirier
2019-06-19 19:52 ` [PATCH 07/28] coresight: Remove name from platform description Mathieu Poirier
2019-06-19 19:52 ` [PATCH 08/28] coresight: Cleanup coresight_remove_conns Mathieu Poirier
2019-06-19 19:52 ` [PATCH 09/28] coresight: Reuse platform data structure for connection tracking Mathieu Poirier
2019-06-19 19:53 ` [PATCH 10/28] coresight: Rearrange platform data probing Mathieu Poirier
2019-06-19 19:53 ` [PATCH 11/28] coresight: Add support for releasing platform specific data Mathieu Poirier
2019-06-19 19:53 ` [PATCH 12/28] coresight: platform: Use fwnode handle for device search Mathieu Poirier
2019-06-19 19:53 ` [PATCH 13/28] coresight: Use fwnode handle instead of device names Mathieu Poirier
2019-06-19 19:53 ` [PATCH 14/28] coresight: Use platform agnostic names Mathieu Poirier
2019-06-19 19:53 ` [PATCH 15/28] coresight: stm: ACPI support for parsing stimulus base Mathieu Poirier
2019-06-19 19:53 ` [PATCH 16/28] coresight: Support for ACPI bindings Mathieu Poirier
2019-06-19 19:53 ` [PATCH 17/28] coresight: acpi: Support for AMBA components Mathieu Poirier
2019-06-19 19:53 ` [PATCH 18/28] coresight: acpi: Support for platform devices Mathieu Poirier
2019-06-19 19:53 ` [PATCH 19/28] coresight: Add dummy definition for of_coresight_get_cpu() Mathieu Poirier
2019-06-19 19:53 ` [PATCH 20/28] coresight: tmc-etr: Do not call smp_processor_id() from preemptible Mathieu Poirier
2019-06-20  6:02   ` Greg KH
2019-06-19 19:53 ` [PATCH 21/28] coresight: tmc-etr: alloc_perf_buf: Do not call smp_processor_id " Mathieu Poirier
2019-06-20  6:03   ` Greg KH
2019-06-19 19:53 ` Mathieu Poirier [this message]
2019-06-20  6:03   ` [PATCH 22/28] coresight: tmc-etf: " Greg KH
2019-06-19 19:53 ` [PATCH 23/28] coresight: etb10: " Mathieu Poirier
2019-06-20  6:04   ` Greg KH
2019-06-19 19:53 ` [PATCH 24/28] coresight: Potential uninitialized variable in probe() Mathieu Poirier
2019-06-20  6:04   ` Greg KH
2019-06-19 19:53 ` [PATCH 25/28] coresight: etm3x: Smatch: Fix potential NULL pointer dereference Mathieu Poirier
2019-06-20  6:04   ` Greg KH
2019-06-20 21:38     ` Mathieu Poirier
2019-06-21  6:59       ` Greg KH
2019-06-19 19:53 ` [PATCH 26/28] coresight: tmc: " Mathieu Poirier
2019-06-20  6:05   ` Greg KH
2019-06-20 21:42     ` Mathieu Poirier
2019-06-21  6:59       ` Greg KH
2019-06-19 19:53 ` [PATCH 27/28] coresight: platform: add OF/APCI dependency Mathieu Poirier
2019-06-19 19:53 ` [PATCH 28/28] coresight: replicator: Add terminate entry for acpi_device_id tables Mathieu Poirier
2019-06-20  6:08 ` [PATCH 00/28] coresight: next v5.2-rc5 (V2) Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190619195318.19254-23-mathieu.poirier@linaro.org \
    --to=mathieu.poirier@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).