Received: by 10.223.176.5 with SMTP id f5csp2198758wra; Thu, 8 Feb 2018 09:59:30 -0800 (PST) X-Google-Smtp-Source: AH8x2262uHk6xtgG3MIHK3AxEUXzJrFl+fqZSHXkibURuvHWRktrI/iyPW0u3xB7IEiRVQ8Qb3tY X-Received: by 2002:a17:902:8546:: with SMTP id d6-v6mr7360plo.147.1518112769985; Thu, 08 Feb 2018 09:59:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518112769; cv=none; d=google.com; s=arc-20160816; b=LcRCbeO3D3NqT+EKquLQW+H0U0GSIYnz4n5lIa0zGk8m+2NhUPqspamldt7cc6skPR EO8DrvITDDZJJ4ewlt4kcrG0Fkmunbrg1XGijPW/YxQXjHl+DH4bztPTc6/aLlPB0B0L Nic2oVQPRJtLXb+QGOUwp752KOrfBk3yeQ3nusJ3XP+Reqoz88sXWOFac+KKNMKbPesF ucxq8uHmxAQF3f2Htp+8skRSYWTG/oXwF/tpnp0KQK5LuIttt6+XSs5+pzl3st52t2uH T/Ry97Yrfu09sPOrdK321LKDeP53e2jaVvupAWtWUvItvUBiu+7HPpp0ZP9r9pQEudSX 8C+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=uTbyQMzlRYH90AexegrF14ArObNcEYmhRWWHAcCx/PU=; b=RNZ6DN04Tc1Yzg6YrG4UXzBE2Lm2TtRfK1o0hMI/CZDovLp+ZYafiaDSYBr6dgOvUz ChVEXKo14KrKKBUSXdphZ/ShIGUShN/nQNdgHX+BME9b5HRxfwn7SEtuI/n4zTOzr0vH 0uzqudQcz5aNOwtGaWQml1Tg8fB6Cwsb1ptn5v9QuhtzUZyF6B4kH2dya2CpiDX6DEFp eK7x3rSOVJkYQpshzoEzQIqT5q0fV+XIZPSfuKB7OCawQ0zksKXoMy9Bb1w6wEDput5G O+I8llhiTr7l2/6XnGyqVtjMfXxKjr3dOCzxhg+L333N3aiN70UD6TbNsNWT5j2QSpCS ZHew== 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 l36-v6si228942plg.7.2018.02.08.09.59.15; Thu, 08 Feb 2018 09:59:29 -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 S1752171AbeBHR6W (ORCPT + 99 others); Thu, 8 Feb 2018 12:58:22 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60788 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751700AbeBHR6V (ORCPT ); Thu, 8 Feb 2018 12:58:21 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 028E68182D1B; Thu, 8 Feb 2018 17:58:21 +0000 (UTC) Received: from ovpn-123-26.rdu2.redhat.com (ovpn-123-26.rdu2.redhat.com [10.10.123.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE8BB1007D65; Thu, 8 Feb 2018 17:58:20 +0000 (UTC) Message-ID: <1518112700.2911.0.camel@redhat.com> Subject: Re: [PATCH] perf: arm_pmu_acpi: Fix armpmu_alloc call from invalid context From: Mark Salter To: Mark Rutland Cc: Thomas Gleixner , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Date: Thu, 08 Feb 2018 12:58:20 -0500 In-Reply-To: <20180208175433.p2a3g2q7tctfpk7c@lakrids.cambridge.arm.com> References: <20180208174504.30665-1-msalter@redhat.com> <20180208175433.p2a3g2q7tctfpk7c@lakrids.cambridge.arm.com> Organization: Red Hat, Inc Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Feb 2018 17:58:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 08 Feb 2018 17:58:21 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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 On Thu, 2018-02-08 at 17:54 +0000, Mark Rutland wrote: > Hi Mark, > > On Thu, Feb 08, 2018 at 12:45:04PM -0500, Mark Salter wrote: > > 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 > > I have patches to address this: > > http://lists.infradead.org/pipermail/linux-arm-kernel/2018-February/557838.html > https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/log/?h=arm64/acpi-pmu-lockdep Awesome, I completely missed that. Thanks. > > > 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, > > We need CPUHP_AP_PERF_ARM_ACPI_STARTING to happen before > CPUHP_AP_PERF_ARM_STARTING, and I think this re-ordering prevents us > from correctly resetting the PMU and enabling percpu interrupts, at > least in heterogeneous configurations (e.g. big.LITTLE systems like > Juno). > > I'm not sure whether we could safely move both callbacks this late. > > Thanks, > Mark.