From patchwork Fri May 10 09:31:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 163845 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2121130ilr; Fri, 10 May 2019 02:31:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzR3vb0XWHPcDvbFPlMjhebE63DXbg7/yh4NRqRojP+2EwFVvVTg4FCgKk+bS6rHK9o5LOL X-Received: by 2002:a63:754b:: with SMTP id f11mr12347789pgn.32.1557480677669; Fri, 10 May 2019 02:31:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557480677; cv=none; d=google.com; s=arc-20160816; b=mDzzfRIvZnL77CA2wnSMCguaH6PMfV5EXffVLpFqSRWCORVmEbaP1RYEq8qDw1P/1j MoS32oaCPJF9DJxrCh+QdaCuhLmbVYvWCcFrKoyyt89l/JOLL3cZvWQNOQP89vbfBYGZ cI47QMRhGgcDF0WssB5jQglpUOBVXIRXnWyBQ7xu051JHaf6jeNS+Ao8EcfkGELPK5Gc 2G37puM0Ht9FLtijJnido7QNl7wxVuToGcERLn0GEgP/BPohFvVFzACMrpgmaN9ZIJ4C JKMh6jLnEUD3GjclyEr6vn7qZzP6a71Aznj0aZI/ebi8tb3rG0AWKAUwa6yDh4AMSywH 4lAg== 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; bh=JrFm8xzc76nY4o8KabaaEDVkkgtH99nd7MwsfLV1FrE=; b=wP7REEjam+CZD4yCfccvUCSik6nxzKEM2guDaR99mLPwoT6koVKTWgDxbifk1ea06S 46TOQ3zfkCeOpJl7tnNss3dg1YcM+QoPHpPOf8XXxqm56PKGriphIaMOCbMReQi00vKr i7ogfxL0HLaKQ/JTuz9/zPn5ZwafRVjJZAIUXcoOPKn/6itQ7rxaoKavXV98hQRuhNmm DUFZG1ZHqHxMc5wpQnGNPYT/jrAVL+H2wWcC9b7rcK4/JQKBtB0/wIcb7XCkHddAy/bO LMARJiGkRGPkDXuQE1Vi5qUUYIm3SNAHN3ttjPRo6roPe7d/cuhzBU5Ch70cSiRG6G31 1u0Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cp7si5092873plb.14.2019.05.10.02.31.17; Fri, 10 May 2019 02:31:17 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727328AbfEJJbQ (ORCPT + 30 others); Fri, 10 May 2019 05:31:16 -0400 Received: from foss.arm.com ([217.140.101.70]:41120 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726992AbfEJJbP (ORCPT ); Fri, 10 May 2019 05:31:15 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D396A15AD; Fri, 10 May 2019 02:31:14 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C3E7B3F738; Fri, 10 May 2019 02:31:13 -0700 (PDT) From: Suzuki K Poulose To: mathieu.poirier@linaro.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, Suzuki K Poulose Subject: [PATCH 1/4] coresight: tmc-etr: Do not call smp_processor_id() from preemptible Date: Fri, 10 May 2019 10:31:00 +0100 Message-Id: <1557480663-16759-2-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1557480663-16759-1-git-send-email-suzuki.poulose@arm.com> References: <1557480663-16759-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of using smp_processor_id() to figure out the node, use the numa_node_id() for the current CPU node to avoid splats like : BUG: using smp_processor_id() in preemptible [00000000] code: perf/1743 caller is alloc_etr_buf.isra.6+0x80/0xa0 CPU: 1 PID: 1743 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 alloc_etr_buf.isra.6+0x80/0xa0 tmc_alloc_etr_buffer+0x12c/0x1f0 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 Fixes: 855ab61c16bf70b646 ("coresight: tmc-etr: Refactor function tmc_etr_setup_perf_buf()") Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 793639f..cae9d8a 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1323,13 +1323,11 @@ static struct etr_perf_buffer * tmc_etr_setup_perf_buf(struct tmc_drvdata *drvdata, struct perf_event *event, int nr_pages, void **pages, bool snapshot) { - int node, cpu = event->cpu; + int node; struct etr_buf *etr_buf; struct etr_perf_buffer *etr_perf; - if (cpu == -1) - cpu = smp_processor_id(); - node = cpu_to_node(cpu); + node = (event->cpu == -1) ? numa_node_id() : cpu_to_node(event->cpu); etr_perf = kzalloc_node(sizeof(*etr_perf), GFP_KERNEL, node); if (!etr_perf) From patchwork Fri May 10 09:31:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 163846 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2121147ilr; Fri, 10 May 2019 02:31:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzoFD8aWuxpK+Vmy10HG2kEL7W4Wom9zICbZKa8a5kP2lbCDElN2qUhmQRSFxcoQmvVokiL X-Received: by 2002:a63:b706:: with SMTP id t6mr6135497pgf.305.1557480679096; Fri, 10 May 2019 02:31:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557480679; cv=none; d=google.com; s=arc-20160816; b=IKH4sw9mdr71bJQ8u/ZU7ps1vozwdhF2Gy5ZHzcK8J20pjWgO5EJT1NVO8bg26To80 zBxco6SjF1nIbhn92QOdIpbZ/n5Zr561g7KcVH5aDxo4ZvJuMtgn+U1qymm174Kf0dyB cu2YBNAGOHtRPDhHK+rcjVxDlVUsQGRqiKLATTC67OtTCrivC9CvAUcRZzaHyTD5NVGm 6MU5+hv2Nf+saQ0ZnZE2HoFY8YbS4jP/t4Mj/meaeeS4hDSE4fdfp/VA8qboNw5SNjam hUxJj3DrTHYXG+sh/XjCgvM72cXf2udHpLeL32rS2BXVRHSquVsgo2fzPIQSZ8yEdjSH 1W9Q== 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; bh=i8bhmbEetvuknLCg0LksGJSUcs2I5Gnn2f78Ia6IV7U=; b=dbHfFMSaWKlxxLbd7svdaefZ3OwIuKeJqepdHKdhsxqGQu+zzc2DloZ5Cve53spiRI KSWG8iMeHdrzIRq0gSd1PqPrr4mKMLfPPjDsYQz83j5JhK15yTUOKYAxEpyPEKgx25lk TCxPB2iK0YfBhZMIzTBamxf6d//dAWquzzps060fxpuTeQ0u5nbl+oCFPYX4jBl4SKTn aD4UTYyvZkj/RhJGHPExJOyRBy/lk85kW4WS9BuEDpjI3i2lP1IVDUEXAcms2l/m870w BfUYshk/93zGz67aIm53NEu86bGgmzGIv8viHIHDZ1UJJtbgilBaGvseMpJ2wEobVg1O 38gQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 36si7167148pgw.281.2019.05.10.02.31.18; Fri, 10 May 2019 02:31:19 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727346AbfEJJbR (ORCPT + 30 others); Fri, 10 May 2019 05:31:17 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:41130 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727310AbfEJJbQ (ORCPT ); Fri, 10 May 2019 05:31:16 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2B5B815BF; Fri, 10 May 2019 02:31:16 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1BF713F738; Fri, 10 May 2019 02:31:14 -0700 (PDT) From: Suzuki K Poulose To: mathieu.poirier@linaro.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, Suzuki K Poulose Subject: [PATCH 2/4] coresight: tmc-etr: alloc_perf_buf: Do not call smp_processor_id from preemptible Date: Fri, 10 May 2019 10:31:01 +0100 Message-Id: <1557480663-16759-3-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1557480663-16759-1-git-send-email-suzuki.poulose@arm.com> References: <1557480663-16759-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We find the current CPU using smp_processor_id() if the event is not bound to a CPU, to find the node for memory allocation. Use the safe numa_node_id() instead, to avoid BUG(). BUG: using smp_processor_id() in preemptible [00000000] code: perf/1743 caller is tmc_alloc_etr_buffer+0x1bc/0x1f0 CPU: 1 PID: 1743 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_etr_buffer+0x1bc/0x1f0 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 Fixes: 22f429f19c4135d51e9 ("coresight: etm-perf: Add support for ETR backend") Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index cae9d8a..e2932f5 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1184,14 +1184,11 @@ static struct etr_buf * alloc_etr_buf(struct tmc_drvdata *drvdata, struct perf_event *event, int nr_pages, void **pages, bool snapshot) { - int node, cpu = event->cpu; + int node; struct etr_buf *etr_buf; unsigned long size; - if (cpu == -1) - cpu = smp_processor_id(); - node = cpu_to_node(cpu); - + node = (event->cpu == -1) ? numa_node_id() : cpu_to_node(event->cpu); /* * Try to match the perf ring buffer size if it is larger * than the size requested via sysfs. From patchwork Fri May 10 09:31:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 163848 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2121260ilr; Fri, 10 May 2019 02:31:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyStdIzEtjP+KwEObMtjx813FIZlBUw2fBDI38TbpVW51ZNr2jM2yH+C1GRFZsEUX7Bzxa2 X-Received: by 2002:a17:902:720a:: with SMTP id ba10mr11645160plb.192.1557480685789; Fri, 10 May 2019 02:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557480685; cv=none; d=google.com; s=arc-20160816; b=zUtxbS5G9AeduEEexh5ZCq3e4B9hJHZz7qboBiMNOuYq6lb6qj5BY/4LKA3a9IUr05 QiinLjVij5ZIMp8ELn8RpSBCStmy7qQbFeGTULxIiL8/PC2q6g6GwhQzMcEM2DhFxcki O+02h3vvQhJD9wWosgZfCc7GjotV02JGfDU9cfCZFVVRbHbSeYJd68JFEcHK0UIl8mjB MDgUlqwqmnV9uBBHat/1s7WqR6Sa02fxGWfnOz7eHlfaiyJEE/gJNz7uOS9bsCF5Sk4e 9gVe85HbzH657KyUfKEHfWoG8mqGSCaGCsbwNjCfMUenj8Bdt9z2q6/fYnM/CJdx0Ml4 Ot8w== 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; bh=eJPrKWtRiFxnnQzGIhq7/Yc8KZ1BmubqWOm6dfohKg4=; b=Scw9wo2J1DxPQxHNJee3l3ys9GvRElIEgJrecKef7/cFVToRxa43HagZuSWUxhcBGe 18ZqMHFP0rSL+Q6v33lW8xIL9YZbwD2ytxRpCf8OQEd+gLTqBg+KvmZLfbXQ3h2LqX+n y14G6AhOPv4AK99HpljT7aqw8gIIp4LupkNtdfFCmOqJysvt29CzkSFMz/OmV01ifVKe 4hy4kW/jYYyHqmcWXZm+xvDQTFnhivPuX0ZE6+0rKPRkzFdz7lu0QPwqxlkWm9EJzltu gAFCfWSIUDtSa0N7en9LRhxHhdJP/ekLH1BqtS16ddWoFSVFBAYtJJpAIeXkVWeNlF2D kohg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13si6363053pgp.569.2019.05.10.02.31.25; Fri, 10 May 2019 02:31:25 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727375AbfEJJbU (ORCPT + 30 others); Fri, 10 May 2019 05:31:20 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:41140 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727342AbfEJJbS (ORCPT ); Fri, 10 May 2019 05:31:18 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 77487169E; Fri, 10 May 2019 02:31:17 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 67D713F738; Fri, 10 May 2019 02:31:16 -0700 (PDT) From: Suzuki K Poulose To: mathieu.poirier@linaro.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, Suzuki K Poulose Subject: [PATCH 3/4] coresight: tmc-etf: Do not call smp_processor_id from preemptible Date: Fri, 10 May 2019 10:31:02 +0100 Message-Id: <1557480663-16759-4-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1557480663-16759-1-git-send-email-suzuki.poulose@arm.com> References: <1557480663-16759-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We find the current CPU using smp_processor_id() if the event is not bound to a CPU, to find the node for memory allocation. Use the safe numa_node_id() instead, to avoid BUG(). e.g: 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 Fixes: 2e499bbc1a929ac ("coresight: tmc: implementing TMC-ETF AUX space API") Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 31093de..5d0e594 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_node_id() : cpu_to_node(event->cpu); /* Allocate memory structure for interaction with Perf */ buf = kzalloc_node(sizeof(struct cs_buffers), GFP_KERNEL, node); From patchwork Fri May 10 09:31:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 163847 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2121193ilr; Fri, 10 May 2019 02:31:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKuoNA3zCZVUZDNUQRSYlbAljwOAOyK8kePyu2fKRvW69lr1+PCJLzVZlB1FoNrDTe1lK7 X-Received: by 2002:a17:902:bd91:: with SMTP id q17mr11637010pls.13.1557480682056; Fri, 10 May 2019 02:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557480682; cv=none; d=google.com; s=arc-20160816; b=x/rm14PfeNqWHvSSJ1gxKBfVa/NXCCFoe2JtIURP3EOiLrYuNPisks9eXl3LkKcRPI w1gvYMH9e8++YHrFie6/XjY32p36nzxTXwQwy3sf4PMf6DkflZWn2Cv0TrdoSeLKNnNo +AoJkOfDTbz+gbutzjhI/Jyjl8gHyDMclDkhwcvddloyImBJbVOsH9ziqnmL7Mnu68P9 XLHoHzTiz477Bn2zLXqbmapT0r58qvB0zi9eUxMPj14WnhUtqHfoxxSBVD+XtgZmJSyL Mfap9WB88jkqJyXvk7IEmFkscaw1x1u/Wv0P+ix9ckTT7c7UPjLrauvzO4wVeEIGMjQL K5lw== 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; bh=lS3tz02fEv6NfJMLvvJsHmf4VbpfiR6ExoV5WaG9BSk=; b=e+spYYy02RDPybgT7uWEGsWdNZ7Z0fASZ1JBWp0aJpjQgKvDwtnRTpFj9Jx79m5uEq 3QQV3HifOSDyZ7zDboMJ/otfzk8aLQD3awUFHVCiH3uZcF/IWClUYz6lTcWl3ZW8NI/V XjLE9L+dELJHBMc6kG5w0ao6qTUxbeUGnEScETgP5It5/PyGuaJU5BWGDJ+rXO0PJ7jr iOkHVKJi8omAlzXzGSOUmc2rylRbhyaLmS1J2/mKowG2g8KPXTMEGxkmh1z0/sptekWH 6XIoYEmIssN4+BBsDa/YPlvUQaCj4uDILsxZpIMEQmFJAleEEV6fHoZqdYE0h3dnH3KM 0PBw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 36si7167148pgw.281.2019.05.10.02.31.21; Fri, 10 May 2019 02:31:22 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727390AbfEJJbU (ORCPT + 30 others); Fri, 10 May 2019 05:31:20 -0400 Received: from foss.arm.com ([217.140.101.70]:41152 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727365AbfEJJbT (ORCPT ); Fri, 10 May 2019 05:31:19 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D099CA78; Fri, 10 May 2019 02:31:18 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B3CF73F738; Fri, 10 May 2019 02:31:17 -0700 (PDT) From: Suzuki K Poulose To: mathieu.poirier@linaro.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, Suzuki K Poulose Subject: [PATCH 4/4] coresight: etb10: Do not call smp_processor_id from preemptible Date: Fri, 10 May 2019 10:31:03 +0100 Message-Id: <1557480663-16759-5-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1557480663-16759-1-git-send-email-suzuki.poulose@arm.com> References: <1557480663-16759-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We find the current CPU using smp_processor_id() if the event is not bound to a CPU, to find the node for memory allocation. Use the safe numa_node_id() instead, to avoid BUG(). e.g: BUG: using smp_processor_id() in preemptible [00000000] code: perf/2544 Fixes: 2997aa4063d97fdb39 ("coresight: etb10: implementing AUX API") Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-etb10.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index bdd4fd5..a38b38a 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -374,12 +374,10 @@ static void *etb_alloc_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_node_id() : cpu_to_node(event->cpu); buf = kzalloc_node(sizeof(struct cs_buffers), GFP_KERNEL, node); if (!buf)