From patchwork Thu Feb 8 17:45:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 127696 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1714725ljc; Thu, 8 Feb 2018 09:45:31 -0800 (PST) X-Google-Smtp-Source: AH8x227aTGz3n8MvmhRBnN5f5LRZB0FUOgXgwA7MpfKJnTpa3h33tzqzy3cCSPYXwtapO4M+gXUw X-Received: by 10.101.72.75 with SMTP id i11mr4594pgs.78.1518111931019; Thu, 08 Feb 2018 09:45:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518111931; cv=none; d=google.com; s=arc-20160816; b=LV+Sai5OyQPdWyyS3O0tXba5FMPawkL8/tetWTRXQntM98F6oirs7WefGeVfWjeZrB taELDXGOnCwUo9+YvttAGuR5zIMVPdaE0b0xkmhSKxvroG6ORSN3Aej94O3cnrkO9YeF Rqk1lWE0h0BzI+7/TdFbQ8x9NE4dNv2vfZxc54ErzwbQQIY2bcUpfOh4Wy5xGzgW4H4x n8Tp/HxeZDgrmLukTxPmnVzZS8EURErx9I8AqJ1kcbXp59DysyUcdhTt64Osk4wo33Z9 vUy1+82OWLRiqzmAxwMhljL7X1YxqlxMX8fRG4IWah5y+5Y7sisqI9f6UMErTKSrIlAC vWjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=WG/hDxJodZ9vQc0d9d5W4dnsjxpI5T8cPUTjo0WFyzE=; b=XT++9lO8GSX5AA1SuBWZd9VqYQNRI+mW/o1/dVoM/MCmaxIUjLjOGK7yvdO/DzZpwz +BxMpe+yZQK0N0gWfjeqDXgR27zkHf/w6jxt7Oi23QQJqlqTuxwO91i2otPXWO+ucyTm z+UsHjd4P5IfDg5YlVka3mcjf0rRkUYMPeFnOuuzzh3l42YQ7oXpTkeSaaPqDh5nO6i1 xWM4ME4sXXSH+BEzpQage1YN+HVmbZj1q/9rKTkRATo4qpcGZb9+PcIbqk38I6ekjO/+ ESNwjgIqizWnV5L+G42J8ZY1LJR/4f7xE35707UwBPEkcN3h4qFydHf7vr6ARkW8eUF0 G4VQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f131si220172pgc.410.2018.02.08.09.45.30; Thu, 08 Feb 2018 09:45: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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752430AbeBHRp1 (ORCPT + 13 others); Thu, 8 Feb 2018 12:45:27 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42470 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752103AbeBHRp0 (ORCPT ); Thu, 8 Feb 2018 12:45:26 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 858E0EAEA0; Thu, 8 Feb 2018 17:45:25 +0000 (UTC) Received: from rhp50.localdomain (ovpn-123-26.rdu2.redhat.com [10.10.123.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E5B1202699C; Thu, 8 Feb 2018 17:45:25 +0000 (UTC) From: Mark Salter To: Mark Rutland Cc: Thomas Gleixner , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] perf: arm_pmu_acpi: Fix armpmu_alloc call from invalid context Date: Thu, 8 Feb 2018 12:45:04 -0500 Message-Id: <20180208174504.30665-1-msalter@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 08 Feb 2018 17:45:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 08 Feb 2018 17:45:25 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'msalter@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When booting an arm64 debug kernel with ACPI, I see: BUG: sleeping function called from invalid context at mm/slab.h:420 in_atomic(): 0, irqs_disabled(): 128, pid: 12, name: cpuhp/0 1 lock held by cpuhp/0/12: #0: (cpuhp_state-up){+.+.}, at: [<0000000057aa0dae>] cpuhp_thread_fun+0x13c/0x258 irq event stamp: 28 hardirqs last enabled at (27): [<000000000b861658>] _raw_spin_unlock_irq+0x38/0x58 hardirqs last disabled at (28): [<000000006231cfb1>] cpuhp_thread_fun+0xd0/0x258 softirqs last enabled at (0): [<0000000054d9737a>] copy_process.isra.32.part.33+0x450/0x1480 softirqs last disabled at (0): [< (null)>] (null) CPU: 0 PID: 12 Comm: cpuhp/0 Not tainted 4.15.0+ #18 Hardware name: AppliedMicro X-Gene Mustang Board/X-Gene Mustang Board, BIOS 3.06.25 Oct 17 2016 Call trace: dump_backtrace+0x0/0x188 show_stack+0x24/0x2c dump_stack+0xa4/0xe0 ___might_sleep+0x208/0x234 __might_sleep+0x58/0x8c kmem_cache_alloc_trace+0x248/0x3e0 armpmu_alloc+0x38/0x1a8 arm_pmu_acpi_cpu_starting+0x11c/0x15c cpuhp_invoke_callback+0x120/0x100c cpuhp_thread_fun+0xe8/0x258 smpboot_thread_fn+0x170/0x268 kthread+0x110/0x13c ret_from_fork+0x10/0x18 With commit 7d88eb695a1f ("arm/perf: Convert to hotplug state machine"), arm_pmu uses the cpuhotplug framework to initialize the PMU driver when using ACPI. However, the arm_pmu_acpi_cpu_starting() callback comes before CPUHP_AP_ONLINE is reached which means it runs with interrupts diabled and tries to allocate memory with GFP_KERNEL alloc which may sleep. Move CPUHP_AP_PERF_ARM_ACPI_STARTING to come after CPUHP_AP_ONLINE so that the arm_pmu initialization runs with interrupts enabled as it does when booting with device tree. Fixes: 7d88eb695a1f ("arm/perf: Convert to hotplug state machine") Signed-off-by: Mark Salter --- include/linux/cpuhotplug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.8.3.1 diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 5172ad0..e07b2da 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -114,7 +114,6 @@ enum cpuhp_state { CPUHP_AP_ARM_VFP_STARTING, CPUHP_AP_ARM64_DEBUG_MONITORS_STARTING, CPUHP_AP_PERF_ARM_HW_BREAKPOINT_STARTING, - CPUHP_AP_PERF_ARM_ACPI_STARTING, CPUHP_AP_PERF_ARM_STARTING, CPUHP_AP_ARM_L2X0_STARTING, CPUHP_AP_ARM_ARCH_TIMER_STARTING, @@ -146,6 +145,7 @@ enum cpuhp_state { CPUHP_AP_SMPBOOT_THREADS, CPUHP_AP_X86_VDSO_VMA_ONLINE, CPUHP_AP_IRQ_AFFINITY_ONLINE, + CPUHP_AP_PERF_ARM_ACPI_STARTING, CPUHP_AP_PERF_ONLINE, CPUHP_AP_PERF_X86_ONLINE, CPUHP_AP_PERF_X86_UNCORE_ONLINE,