From patchwork Thu Aug 25 16:41:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12955070 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39A13ECAA25 for ; Thu, 25 Aug 2022 16:41:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA5D2940008; Thu, 25 Aug 2022 12:41:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A56116B0075; Thu, 25 Aug 2022 12:41:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 943FD940008; Thu, 25 Aug 2022 12:41:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7C8CD6B0074 for ; Thu, 25 Aug 2022 12:41:43 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4FEECAC530 for ; Thu, 25 Aug 2022 16:41:43 +0000 (UTC) X-FDA: 79838681286.07.D894582 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf20.hostedemail.com (Postfix) with ESMTP id E62DE1C0019 for ; Thu, 25 Aug 2022 16:41:42 +0000 (UTC) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1661445701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/sTDmikhifvT+jyCYSjHJibnGmKic2QnilMTiV7/DbU=; b=obMubdUd6EYGlMUE+9dZPkyrahV0KRgisk2845KsBngVKkRtiS/Msafs4/lAf5+xakKTZ/ GF/JrVvH839LGCfDXeW7jRQH1sCUYlyLY9jRMxBcmm8Dejy2OsJQrmodMkwVQcftSEiRkW EEOvcB3OI/zRussbsWUnJgWhcmoAGZPbEi8kDl9CbpK3DIX4/nnk5IRaY1IEp0MA/+aRS7 WUnCopuwdPLuK8XTQH+j2Sgxsx+MnhGCAXz4I3H8y+aEF054nxFtl/wIFeoeK8RmFMXGLI v0eiMX71mbgaS6WpTMLEcDqeu0mTrd2ekCrmJTPJVcX4OVj17fWIGAMkQah5kQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1661445701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/sTDmikhifvT+jyCYSjHJibnGmKic2QnilMTiV7/DbU=; b=HuR+XllO9XxgzG30p0gBGiEYr0BVeZQinpJziXEn5D8nhFALUt02pQEhbjGpt6BqBFKpLY 2uMIOQAaGXq31vDA== To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Peter Zijlstra , Steven Rostedt , Linus Torvalds , Matthew Wilcox , Andrew Morton , linux-mm@kvack.org, Sebastian Andrzej Siewior Subject: [PATCH v2 4/8] mm/debug: Provide VM_WARN_ON_IRQS_ENABLED() Date: Thu, 25 Aug 2022 18:41:27 +0200 Message-Id: <20220825164131.402717-5-bigeasy@linutronix.de> In-Reply-To: <20220825164131.402717-1-bigeasy@linutronix.de> References: <20220825164131.402717-1-bigeasy@linutronix.de> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661445703; a=rsa-sha256; cv=none; b=dmVpGeiEhFGE0tgaQeh6m+VUOCuC07afOiDwPBUnTfEuKuW/gTbXy402909OKRaE+LsZPj sDp5+szfR8V6qzuoH6QH6miVjFeLiu7naI5QUMZMbuWjDW0+q6WooqZtmlNQshlwnoEBbE TxoJhueeuFcu9ZH3A6BbCFFp5hnJyic= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=obMubdUd; dkim=pass header.d=linutronix.de header.s=2020e header.b=HuR+XllO; spf=pass (imf20.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661445703; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/sTDmikhifvT+jyCYSjHJibnGmKic2QnilMTiV7/DbU=; b=0Fmj3AkRkJMsKwcHNhztyXoau8nPdpkra7aDs1IhHUh6WwbB6OnazUqTmkiSw4AHyFtods 5Z93jhdCep2eAGFKZtxRIF5lYfe6TbwX+U5ac8u4PY0rxJc9JzlCFvp+vKrnvPPevgMHQ0 aV+btnCC5CqaVaOR2Bs0A4KlhoYyUOM= Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=obMubdUd; dkim=pass header.d=linutronix.de header.s=2020e header.b=HuR+XllO; spf=pass (imf20.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: wrafxri97i68nee46kjpcaad6h6yeebq X-Rspamd-Queue-Id: E62DE1C0019 X-HE-Tag: 1661445702-754972 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Thomas Gleixner Some places in the VM code expect interrupts disabled, which is a valid expectation on non-PREEMPT_RT kernels, but does not hold on RT kernels in some places because the RT spinlock substitution does not disable interrupts. To avoid sprinkling CONFIG_PREEMPT_RT conditionals into those places, provide VM_WARN_ON_IRQS_ENABLED() which is only enabled when VM_DEBUG=y and PREEMPT_RT=n. Signed-off-by: Thomas Gleixner Cc: Andrew Morton Cc: linux-mm@kvack.org Signed-off-by: Sebastian Andrzej Siewior Acked-by: Peter Zijlstra (Intel) Acked-by: Michal Hocko --- include/linux/mmdebug.h | 6 ++++++ lib/Kconfig.debug | 3 +++ 2 files changed, 9 insertions(+) diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h index 15ae78cd28536..b8728d11c9490 100644 --- a/include/linux/mmdebug.h +++ b/include/linux/mmdebug.h @@ -94,6 +94,12 @@ void dump_mm(const struct mm_struct *mm); #define VM_WARN(cond, format...) BUILD_BUG_ON_INVALID(cond) #endif +#ifdef CONFIG_DEBUG_VM_IRQSOFF +#define VM_WARN_ON_IRQS_ENABLED() WARN_ON_ONCE(!irqs_disabled()) +#else +#define VM_WARN_ON_IRQS_ENABLED() do { } while (0) +#endif + #ifdef CONFIG_DEBUG_VIRTUAL #define VIRTUAL_BUG_ON(cond) BUG_ON(cond) #else diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 072e4b289c13e..c96fc6820544c 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -803,6 +803,9 @@ config ARCH_HAS_DEBUG_VM_PGTABLE An architecture should select this when it can successfully build and run DEBUG_VM_PGTABLE. +config DEBUG_VM_IRQSOFF + def_bool DEBUG_VM && !PREEMPT_RT + config DEBUG_VM bool "Debug VM" depends on DEBUG_KERNEL