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: 10207579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C92D4602D8 for ; Thu, 8 Feb 2018 17:45:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7A7F295A2 for ; Thu, 8 Feb 2018 17:45:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC529295AC; Thu, 8 Feb 2018 17:45:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 587EE295A2 for ; Thu, 8 Feb 2018 17:45:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=nbsC969wABl1Gp4V5rRlVuEkkQ6av0M6Ser4gLIzBFk=; b=QEg rrPaqYWJCmWoZeCHZsQxTs9NptigaC/W10PqPbd3m518LbHzy+PTKH/hvqtvcGnRx55EBFdc0mVwh DemJppEKdCz8uW9FsFIZY7QpTH90AvZn6tWzkuEkjzrKmOCYFam0acbFfg/sEBZMzIy2ikOO628Ve sPR7C97ACzShoBe+PVqGzPuynL6gWPoMqHnQEjfeMSm1V/TEEoXy7IqPCvKeRo5FM8WIMRasYn/S2 qetfCHyNiHcs7hr5Ya6IvgguQVG3IGd7St3cSNJj+fwLUk0pfxkiurcxVvMvWTCdDdmjSQKqq0w0s KrW9ugVUc9eGaAh6mhzq/zJL6BzkYdA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ejqGV-0004Lo-7d; Thu, 08 Feb 2018 17:45:43 +0000 Received: from mx3-rdu2.redhat.com ([66.187.233.73] helo=mx1.redhat.com) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ejqGS-0004IA-JE for linux-arm-kernel@lists.infradead.org; Thu, 08 Feb 2018 17:45:42 +0000 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 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:'' X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Gleixner , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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,