Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp4412914pxb; Tue, 31 Aug 2021 04:43:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZK+7Hncz/di4v0VRQiblI9s62Q/e5+Uj4qDksaHIbtcbQ75HpQj0dDWnqD8J57qSOdsqT X-Received: by 2002:a6b:7a03:: with SMTP id h3mr22494900iom.39.1630410202506; Tue, 31 Aug 2021 04:43:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630410202; cv=none; d=google.com; s=arc-20160816; b=psho5uqAUpNc6mOWgbj3bzxY/UJRJJhg7Hjq6n01ADbgS2hYNe0AYp9VLPkzXcm3mX QlorMCOB7W9hT4CN+6NFa97/r76K71fxSBM6RSh4DxFFxOCBvCWykLqJzqQqXjAdKt9l oGlkicXI8cSWy2xe5ryPxCkubpN4wP7fkVm6RJHYfuQFY6YvHDR4FJAG0bexSTJnRI/D ltlDoHUnAIa37nK3me42+NuVvplaeBlPklN8x6pG9g9ivZVt0YIG7my7VxVYwS+kqJIs BSGcxrhgSJOOXIrFMms5QeLnpospKAjHwv9jXLAAE/AM4MCKjnN9/5KVNniCIP5cf9hJ j9Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=l//iG72UQUgu2Sgam8e4jXFgahV9t6yqfjss357Zl/I=; b=unILeyQxG1MRnP2srwEGyGurkQxyh5X/gkcVMwoz3j0VlU+W+LNgfDAZz3Nbbi7Gqt tdgBHz0iDFTtMGvI6z9m0tOnPj/HRw09sSQa0OnNp1pu5eeEI8LERJS9NecvSII/CW6X od5VF1746Lsa7CCtapSS0hqDBHw6ixNsa5Rly+4ALY/yKqeF9okwr46roiu1cfAOSHWx JkVm0MZclNnecFWPnSJgAfSkvJgBo8dl6qpsNaEdAITw9EbDa20OQ1ZZkusfp8aoMlsM GfNx9Y4P5MSE1OGSxkiuIncNK2vZuIxIMOy+obvCF24EzcY/uqrwxb8qUBhZNYPf9gEW FqvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=UGQNARUj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l30si7270998jaf.107.2021.08.31.04.43.11; Tue, 31 Aug 2021 04:43:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=UGQNARUj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241493AbhHaLmB (ORCPT + 99 others); Tue, 31 Aug 2021 07:42:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230266AbhHaLmB (ORCPT ); Tue, 31 Aug 2021 07:42:01 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 544D0C061575; Tue, 31 Aug 2021 04:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=l//iG72UQUgu2Sgam8e4jXFgahV9t6yqfjss357Zl/I=; b=UGQNARUjmU0UNrllsXfAZ/+m1u ke4UgWNCQFKzrWa8HwEqXRnENub5IcaTf3Rj7I6DfFq0wgy3RrhOYTffJ+S4mmSZ0fc6F8+iF1+13 PM9mY5u0NoBzyo/7S1cNU9MNrLY+8DNeinkLVQ1bzpfLsvfv9IE45Fz7lWLJs9+mvCzBiDRcySvMv wv+Yia6qSQqaq8RLI8whUARE/jOEh7s+puisO99TWfuFfke1LaCDfbkA2x4D4i2NhlfaLU+crDxTd Rc61oJN7dnd+6EvV5PKvzomk1Z4Qlb1Il9w6vi1tiHdNcdf4+VqOun8wRhWydc0tbmwB9l99eWLwV d5gmoqLg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mL28C-00EgZk-Kl; Tue, 31 Aug 2021 11:40:44 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 870F4300109; Tue, 31 Aug 2021 13:40:43 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3F60F2C83EADB; Tue, 31 Aug 2021 13:40:43 +0200 (CEST) Date: Tue, 31 Aug 2021 13:40:43 +0200 From: Peter Zijlstra To: Guenter Roeck Cc: Xiaoming Ni , linux-kernel@vger.kernel.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, wangle6@huawei.com, xiaoqian9@huawei.com, shaolexi@huawei.com, linux-acpi@vger.kernel.org, Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla Subject: Re: [PATCH] semaphore: Add might_sleep() to down_*() family Message-ID: References: <20210809021215.19991-1-nixiaoming@huawei.com> <20210831111322.GA1687117@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210831111322.GA1687117@roeck-us.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 31, 2021 at 04:13:22AM -0700, Guenter Roeck wrote: > Hi, > > On Mon, Aug 09, 2021 at 10:12:15AM +0800, Xiaoming Ni wrote: > > Semaphore is sleeping lock. Add might_sleep() to down*() family > > (with exception of down_trylock()) to detect atomic context sleep. > > > > Previously discussed with Peter Zijlstra, see link: > > https://lore.kernel.org/lkml/20210806082320.GD22037@worktop.programming.kicks-ass.net > > > > Signed-off-by: Xiaoming Ni > > Acked-by: Will Deacon > > This patch results in the following traceback on all arm64 boots with > EFI BIOS. > > The problem is only seen with CONFIG_ACPI_PPTT=y, and thus only on arm64. > > Guenter > > --- > [ 14.048540] BUG: sleeping function called from invalid context at kernel/locking/semaphore.c:163 > [ 14.048700] in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 14, name: cpuhp/0 > [ 14.048865] 2 locks held by cpuhp/0/14: > [ 14.048943] #0: ffff8000125799b0 (cpu_hotplug_lock){++++}-{0:0}, at: cpuhp_thread_fun+0x38/0x254 > [ 14.049320] #1: ffff8000125799d8 (cpuhp_state-up){+.+.}-{0:0}, at: cpuhp_thread_fun+0x38/0x254 > [ 14.049523] irq event stamp: 62 > [ 14.049580] hardirqs last enabled at (61): [] finish_task_switch.isra.0+0xd0/0x2f0 > [ 14.049689] hardirqs last disabled at (62): [] generic_exec_single+0x138/0x190 > [ 14.049785] softirqs last enabled at (0): [] copy_process+0x634/0x1af4 > [ 14.049876] softirqs last disabled at (0): [<0000000000000000>] 0x0 > [ 14.050299] CPU: 0 PID: 14 Comm: cpuhp/0 Not tainted 5.14.0-01100-gb91db6a0b52e #1 > [ 14.050452] Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015 > [ 14.050694] Call trace: > [ 14.050753] dump_backtrace+0x0/0x19c > [ 14.050839] show_stack+0x1c/0x30 > [ 14.050892] dump_stack_lvl+0x9c/0xd8 > [ 14.050949] dump_stack+0x1c/0x38 > [ 14.050999] ___might_sleep+0x154/0x200 > [ 14.051053] __might_sleep+0x54/0x90 > [ 14.051106] down_timeout+0x34/0x90 > [ 14.051159] acpi_os_wait_semaphore+0x68/0x9c > [ 14.051218] acpi_ut_acquire_mutex+0x50/0xbc > [ 14.051277] acpi_get_table+0x3c/0xc0 > [ 14.051330] acpi_find_last_cache_level+0x44/0x12c > [ 14.051391] _init_cache_level+0xd8/0xe4 > [ 14.051446] generic_exec_single+0xf8/0x190 > [ 14.051502] smp_call_function_single+0x174/0x1e0 This is the patch working as intended.. You simply cannot schedule with interrupts disabled as per the callchain.