Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2062346pxb; Sat, 23 Jan 2021 15:39:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzc4bcof1kZFld68k5nBdeYnOntXYOZv/VJAhjMDMMobwE/8q6F03kLL+Tcl1QMC5kPru/K X-Received: by 2002:aa7:c4c9:: with SMTP id p9mr644917edr.234.1611445183118; Sat, 23 Jan 2021 15:39:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611445183; cv=none; d=google.com; s=arc-20160816; b=wfTdhwX4+PJ2XuVNWgGm3OgNlcGV/MyTA4K02rauBCIvlYf3su1LyX3SPMzbs80IAP uqRljwYLL15r9ZqObNxPfA8EL8ILWOpzvDk6V7X4T1ZT3w9QJa6D3Afxlg9jgR62LtLo 7TIIA4u+PFRNtiNsqWDEdLek7nkxsXDIqw5zIIu9qMmj2f++ih8fqrykr1XzLIsJ8R/X GSZ4c84QK3s2tjKt4gTTDWbZBuM6PLACM4eQxskRB3rfb3q3nmJ/osGJMFwhGQzdkRSi WWcGVoLcSkVnORdp+Y+oIkI0Dj2q9ehA97AWPCXGtaskMdDqqCPDRwseKgUvUR3M2ZD1 w97Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Pl0v5x8S446n8IOwuQY/hgBO0SFvlHKKdwxuS/rddAM=; b=aNajxLM3+K3OTXWQU7THbLxQV3eRSDC2VOicAuP7tOZU5acCQtqgbTyOBSiO3bsDKx zCmoJQbO4NAUInnq0xkuATRV3FnJfkeL/GBMjfCyu2nC10alvuQWPD7FfcwTcnBQ/zp9 pKVHYNbpPx6H1vSfVfKdPObZab35xuM94wBiAnbiJNJWsA1REIgEgu+43/QKCrew/Xhl P7KZO6PEcgGATEheCStZ2FFxSiR5/zsQ6/EcA86YeF1fghWBMXnSA0jZHb/UfLnIx34y /r6KGpt7amte11NHTfCyeimTyfisEDVuxhhw2UoG5zCLhNZYDf1AW6T8CdpmmMXAzlD0 myDg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 1si5523864edv.426.2021.01.23.15.39.20; Sat, 23 Jan 2021 15:39:43 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726417AbhAWXin (ORCPT + 99 others); Sat, 23 Jan 2021 18:38:43 -0500 Received: from foss.arm.com ([217.140.110.172]:34244 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726386AbhAWXim (ORCPT ); Sat, 23 Jan 2021 18:38:42 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BD3841474; Sat, 23 Jan 2021 15:37:56 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.194.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A16A53F719; Sat, 23 Jan 2021 15:37:55 -0800 (PST) From: Qais Yousef To: Petr Mladek , Sergey Senozhatsky , Thomas Gleixner Cc: Steven Rostedt , John Ogness , "Peter Zijlstra (Intel)" , linux-kernel@vger.kernel.org, Qais Yousef Subject: [PATCH 0/2] Fix BUG: Invalid wait context in hrtimer_interrupt() Date: Sat, 23 Jan 2021 23:37:39 +0000 Message-Id: <20210123233741.3614408-1-qais.yousef@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I hit a pr_warn() inside hrtimer_interrupt() which lead to a BUG: Invalid wait context splat. The problem wasn't reproducible but I think the cause is obvious, printk can't be called from interrupt context. AFAICU printk_deferred() is safe from NMI, so I assumed it is safe to be called from hrtimer_interrupt() too. Adding a pr_warn_once() inside hrtimer_interrupt() in a location where it is always hit produces the BUG splat. Replacing it with pr_warn_deferred_once() generates the printk warning without any splat. I added a new pr_*_deferred_once() variants to avoid open coding; but the name ended not much shorter and I'm not sure if the wrappers are a win overall. Since I've already done it, I'm sticking to it in this post. But will be happy to drop it and just open code the printk_deferred_once(KERN_WARN, ...) in hrtimer_interrupt() instead. Thanks Qais Yousef (2): printk: Add new pr_*_deferred_once() variants hrtimer: Use pr_warn_deferred_once() in hrtimer_interrupt() include/linux/printk.h | 24 ++++++++++++++++++++++++ kernel/time/hrtimer.c | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) -- 2.25.1