From patchwork Thu Aug 25 16:41:26 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: 12955071 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 52B47ECAA24 for ; Thu, 25 Aug 2022 16:41:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D6516940009; Thu, 25 Aug 2022 12:41:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D3BCB940007; 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 9B92B940009; 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 8900E940007 for ; Thu, 25 Aug 2022 12:41:43 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 53A9E41D00 for ; Thu, 25 Aug 2022 16:41:43 +0000 (UTC) X-FDA: 79838681286.07.D77C1F6 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf12.hostedemail.com (Postfix) with ESMTP id C7B564000B 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=3a2uwD3ePfGP6QOLusJldJ8Cx5w8uOIWpoMcUghBNEI=; b=fAoAi6GN6WY3LeygB/lU0oNfEevDLSlEyWydv2qLC8qJtAwmaJKfLqO4P16YjHMIUo0Je9 llrAhoYh2vZSnpVGam3C5lt5iT7SkmCn51yjLk++hlqRWDKbRPigRr+Dc56Fpb8OYFzSe7 DnlzDN20dDV1rYDLSq3rpXJOlaXcaUMMB5MMNQFUokVaixRlqPj3UFwL9lQjHuBaaXpY67 HVdPQDhN7wH4uc9PcPmbOBplXAZUd9DEUEz4jPfqyQgdpRk0lgPTcxpzkq+V5x55YEH9gj +/KOfkwwtXkRGDvRjHAlLiKvucUPP/2n3UEDqCQOO+U6s4fLgWmQYRcw60KBTw== 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=3a2uwD3ePfGP6QOLusJldJ8Cx5w8uOIWpoMcUghBNEI=; b=YGZc1zl3hETI58auazyzwWtrsPvOEkOwmmHlHQaf1c4aLojGysK6XG0Bv0ZbXFdkioOVw0 bEi0iQIIzmj2gYBA== 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 3/8] mm/vmstat: Use preempt_[dis|en]able_nested() Date: Thu, 25 Aug 2022 18:41:26 +0200 Message-Id: <20220825164131.402717-4-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=Iw3313Bn7qt0aZ2BeKVYNv96r/AjFYJ8c6RVnAYEn9oeXPzQ1TsLvdq5RU2PB/15HWDTzT S3UCVyeS2lU+4P7fuEIr+At6qwftazFW3YHeCJU3wDoFZ3KJTcb8766u82vLmtv3qQ3f92 DNvNGfuKpSM3nkwTuT9UEem0pMD0hhk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=fAoAi6GN; dkim=pass header.d=linutronix.de header.s=2020e header.b=YGZc1zl3; spf=pass (imf12.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=3a2uwD3ePfGP6QOLusJldJ8Cx5w8uOIWpoMcUghBNEI=; b=R2mdj4EcCgxTC5KLvifPmP85gOLqM94aBWhh1UqTpvZYAwj/JGZVfS48MAIZAwV4i6eQp5 6z1X6xVFIVcaNsNt1zh18UrInfeYl7vFMQfpoTS6OvHCFNQOFZYoEnpIcvEcgaOrwJrFm5 iVP9CSUtfBflc7XPXRVieIMQAqPuQK8= X-Rspam-User: Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=fAoAi6GN; dkim=pass header.d=linutronix.de header.s=2020e header.b=YGZc1zl3; spf=pass (imf12.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: rspam12 X-Stat-Signature: u7zfhrz15s6zs9fc6ks8hg98fnyba6xz X-Rspamd-Queue-Id: C7B564000B X-HE-Tag: 1661445702-719399 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 Replace the open coded CONFIG_PREEMPT_RT conditional preempt_enable/disable() pairs with the new helper functions which hide the underlying implementation details. 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 --- mm/vmstat.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 373d2730fcf21..d514fe7f90af0 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -355,8 +355,7 @@ void __mod_zone_page_state(struct zone *zone, enum zone_stat_item item, * CPU migrations and preemption potentially corrupts a counter so * disable preemption. */ - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - preempt_disable(); + preempt_disable_nested(); x = delta + __this_cpu_read(*p); @@ -368,8 +367,7 @@ void __mod_zone_page_state(struct zone *zone, enum zone_stat_item item, } __this_cpu_write(*p, x); - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - preempt_enable(); + preempt_enable_nested(); } EXPORT_SYMBOL(__mod_zone_page_state); @@ -393,8 +391,7 @@ void __mod_node_page_state(struct pglist_data *pgdat, enum node_stat_item item, } /* See __mod_node_page_state */ - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - preempt_disable(); + preempt_disable_nested(); x = delta + __this_cpu_read(*p); @@ -406,8 +403,7 @@ void __mod_node_page_state(struct pglist_data *pgdat, enum node_stat_item item, } __this_cpu_write(*p, x); - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - preempt_enable(); + preempt_enable_nested(); } EXPORT_SYMBOL(__mod_node_page_state); @@ -441,8 +437,7 @@ void __inc_zone_state(struct zone *zone, enum zone_stat_item item) s8 v, t; /* See __mod_node_page_state */ - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - preempt_disable(); + preempt_disable_nested(); v = __this_cpu_inc_return(*p); t = __this_cpu_read(pcp->stat_threshold); @@ -453,8 +448,7 @@ void __inc_zone_state(struct zone *zone, enum zone_stat_item item) __this_cpu_write(*p, -overstep); } - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - preempt_enable(); + preempt_enable_nested(); } void __inc_node_state(struct pglist_data *pgdat, enum node_stat_item item) @@ -466,8 +460,7 @@ void __inc_node_state(struct pglist_data *pgdat, enum node_stat_item item) VM_WARN_ON_ONCE(vmstat_item_in_bytes(item)); /* See __mod_node_page_state */ - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - preempt_disable(); + preempt_disable_nested(); v = __this_cpu_inc_return(*p); t = __this_cpu_read(pcp->stat_threshold); @@ -478,8 +471,7 @@ void __inc_node_state(struct pglist_data *pgdat, enum node_stat_item item) __this_cpu_write(*p, -overstep); } - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - preempt_enable(); + preempt_enable_nested(); } void __inc_zone_page_state(struct page *page, enum zone_stat_item item) @@ -501,8 +493,7 @@ void __dec_zone_state(struct zone *zone, enum zone_stat_item item) s8 v, t; /* See __mod_node_page_state */ - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - preempt_disable(); + preempt_disable_nested(); v = __this_cpu_dec_return(*p); t = __this_cpu_read(pcp->stat_threshold); @@ -513,8 +504,7 @@ void __dec_zone_state(struct zone *zone, enum zone_stat_item item) __this_cpu_write(*p, overstep); } - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - preempt_enable(); + preempt_enable_nested(); } void __dec_node_state(struct pglist_data *pgdat, enum node_stat_item item) @@ -526,8 +516,7 @@ void __dec_node_state(struct pglist_data *pgdat, enum node_stat_item item) VM_WARN_ON_ONCE(vmstat_item_in_bytes(item)); /* See __mod_node_page_state */ - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - preempt_disable(); + preempt_disable_nested(); v = __this_cpu_dec_return(*p); t = __this_cpu_read(pcp->stat_threshold); @@ -538,8 +527,7 @@ void __dec_node_state(struct pglist_data *pgdat, enum node_stat_item item) __this_cpu_write(*p, overstep); } - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - preempt_enable(); + preempt_enable_nested(); } void __dec_zone_page_state(struct page *page, enum zone_stat_item item) 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 From patchwork Thu Aug 25 16:41:28 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: 12955072 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 B4889ECAA27 for ; Thu, 25 Aug 2022 16:41:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1099E6B0074; Thu, 25 Aug 2022 12:41:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B92C940007; Thu, 25 Aug 2022 12:41:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CEE336B0075; Thu, 25 Aug 2022 12:41:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A6B94940007 for ; Thu, 25 Aug 2022 12:41:43 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 80B40C0C34 for ; Thu, 25 Aug 2022 16:41:43 +0000 (UTC) X-FDA: 79838681286.27.A7014DE Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf08.hostedemail.com (Postfix) with ESMTP id 16F0E160005 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=rBDIufscYHVsHmPufaPAl/Vqv2LLB/GPVe+GUwmXUq8=; b=dwt4gAjuVE7mnQU8NsSY1OdNQ0rEZBIOo7TJBp+JnuKFR/KIJGimsOnnoMrAmxV7Ig+JT7 O249Q23IW3M+loKcYaWWeCCbHsG9iBRknQ60mgpEXPa4N+Eode7esLr9CsWoLpckIV1KzI ayi8JaUVrbuLHKvfTbkZw3UEWBw409RJLoheWD5IzDo/LyyVLw6mJMQH2W1WsMcD3Dh2VU y0AoX+D8MvMAnXdwKQNdlX2Uq1K1KYhECqVDrC126boDaX4wUq6U9kgnOZqzw/EZZ46Kw8 ahdSsDX24EgjlJ4uN9GjqVIcF/W2re4OGiNrAhu80st4X6zaYkG+ENS6mRRj9g== 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=rBDIufscYHVsHmPufaPAl/Vqv2LLB/GPVe+GUwmXUq8=; b=/xWS01iGeCi7ocDyLNA4wcA1jGESk+49fcLFDvz6piEFCTHy/Cap5+B9ZdmwZa5+akYuxh YMeWgbw07cXCjbBw== To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Peter Zijlstra , Steven Rostedt , Linus Torvalds , Matthew Wilcox , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , cgroups@vger.kernel.org, linux-mm@kvack.org, Sebastian Andrzej Siewior Subject: [PATCH v2 5/8] mm/memcontrol: Replace the PREEMPT_RT conditionals Date: Thu, 25 Aug 2022 18:41:28 +0200 Message-Id: <20220825164131.402717-6-bigeasy@linutronix.de> In-Reply-To: <20220825164131.402717-1-bigeasy@linutronix.de> References: <20220825164131.402717-1-bigeasy@linutronix.de> MIME-Version: 1.0 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=rBDIufscYHVsHmPufaPAl/Vqv2LLB/GPVe+GUwmXUq8=; b=pAlgZuQCUNpiAYwKR5wIOoyelN6UGrTtgZQRFsSduvnBQu43RjCI7Yl+VyY/FwOKGPCJx8 PizgYAIxBc93wsmK8DC0N7Q67IZI2Mr/0WuBS71VKXud1LPypGK2IVJ7tUMfKr6dv/hIPy TCRVWRS6kOc0xJsxfdbS2Oae55yXR/o= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=dwt4gAju; dkim=pass header.d=linutronix.de header.s=2020e header.b="/xWS01iG"; spf=pass (imf08.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661445703; a=rsa-sha256; cv=none; b=hLT/XHNnuUkua1Io7RvUonq1WlJMXKinFQ9cbC3ukMLwYBlXkA0FVCauccL+T0z6xCb9Uj gVV/mK71vv+66N404I5sivmPrdWQcX29Whnt2C9waAi9rvHygdfot26YJpeV1wFzZssSeI 9bvOY508OnplpwdUS/UewRWx+39mNGw= Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=dwt4gAju; dkim=pass header.d=linutronix.de header.s=2020e header.b="/xWS01iG"; spf=pass (imf08.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-Rspam-User: X-Stat-Signature: c55tixqih17k8n4bxgtuswzqfrbgchqw X-Rspamd-Queue-Id: 16F0E160005 X-Rspamd-Server: rspam03 X-HE-Tag: 1661445702-454297 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 Use VM_WARN_ON_IRQS_ENABLED() and preempt_disable/enable_nested() to replace the CONFIG_PREEMPT_RT #ifdeffery. Signed-off-by: Thomas Gleixner Cc: Johannes Weiner Cc: Michal Hocko Cc: Roman Gushchin Cc: Shakeel Butt Cc: Muchun Song Cc: cgroups@vger.kernel.org Cc: linux-mm@kvack.org Signed-off-by: Sebastian Andrzej Siewior Acked-by: Johannes Weiner Reviewed-by: Muchun Song Acked-by: Peter Zijlstra (Intel) Acked-by: Michal Hocko --- mm/memcontrol.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b69979c9ced5c..d35b6fa560f0a 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -597,25 +597,18 @@ static u64 flush_next_time; */ static void memcg_stats_lock(void) { -#ifdef CONFIG_PREEMPT_RT - preempt_disable(); -#else - VM_BUG_ON(!irqs_disabled()); -#endif + preempt_disable_nested(); + VM_WARN_ON_IRQS_ENABLED(); } static void __memcg_stats_lock(void) { -#ifdef CONFIG_PREEMPT_RT - preempt_disable(); -#endif + preempt_disable_nested(); } static void memcg_stats_unlock(void) { -#ifdef CONFIG_PREEMPT_RT - preempt_enable(); -#endif + preempt_enable_nested(); } static inline void memcg_rstat_updated(struct mem_cgroup *memcg, int val) @@ -715,7 +708,7 @@ void __mod_memcg_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, * interrupt context while other caller need to have disabled interrupt. */ __memcg_stats_lock(); - if (IS_ENABLED(CONFIG_DEBUG_VM) && !IS_ENABLED(CONFIG_PREEMPT_RT)) { + if (IS_ENABLED(CONFIG_DEBUG_VM)) { switch (idx) { case NR_ANON_MAPPED: case NR_FILE_MAPPED: @@ -725,7 +718,7 @@ void __mod_memcg_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, WARN_ON_ONCE(!in_task()); break; default: - WARN_ON_ONCE(!irqs_disabled()); + VM_WARN_ON_IRQS_ENABLED(); } } From patchwork Thu Aug 25 16:41:29 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: 12955073 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 16427ECAA24 for ; Thu, 25 Aug 2022 16:41:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63A7794000C; Thu, 25 Aug 2022 12:41:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E89A940007; Thu, 25 Aug 2022 12:41:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4898F94000C; Thu, 25 Aug 2022 12:41:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 368E5940007 for ; Thu, 25 Aug 2022 12:41:44 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 055B9A1D15 for ; Thu, 25 Aug 2022 16:41:44 +0000 (UTC) X-FDA: 79838681328.06.DFBF128 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf13.hostedemail.com (Postfix) with ESMTP id 8F3372000C for ; Thu, 25 Aug 2022 16:41:43 +0000 (UTC) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1661445702; 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=vNtMvikVP3A7JqyI64O+1a12M8t0vOpcITdU5U0TGnE=; b=1tbpx1sbmfdpwCzS9EIDtkWSVCGguf5I2hLDQGB3gqxy3NXTtgqxr/OyUHEVyLoWq3g+P+ uLfKJpOAWO7ON0OCmzt/gOS53iP8p88HEzAMeM0nfm02bLRVp3g1wSqC6DGK639HTZVca/ JgYApAw08cAzR11s+MES0bwsTZ0DDw6Tms9QX2ubEloCEvIkqQzXebuMe6ZSiYIsWJTwrK BoWu325TadyR5PkTVpwGarSfJURzf76C+VqcMoVVxUWCcgTKt3xE1cz/0uwZTvgUPYY7nT syGRgrGaTPLKYVFR1zfTNxCgXFsCiV0tf1g+P2nyTtUlEOHbZajGvExAn9TcFg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1661445702; 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=vNtMvikVP3A7JqyI64O+1a12M8t0vOpcITdU5U0TGnE=; b=05zUufWP4OOvhby/9h51rilXjm5mAeXZOKAZ+CURv0RQdj2qbxL8qBxvKw0Kr/LwMwpHpa 6RN8dg8XyVjM5qCg== To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Peter Zijlstra , Steven Rostedt , Linus Torvalds , Matthew Wilcox , Andrew Morton , Nick Terrell , linux-mm@kvack.org, Sebastian Andrzej Siewior Subject: [PATCH v2 6/8] mm/compaction: Get rid of RT ifdeffery Date: Thu, 25 Aug 2022 18:41:29 +0200 Message-Id: <20220825164131.402717-7-bigeasy@linutronix.de> In-Reply-To: <20220825164131.402717-1-bigeasy@linutronix.de> References: <20220825164131.402717-1-bigeasy@linutronix.de> MIME-Version: 1.0 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=vNtMvikVP3A7JqyI64O+1a12M8t0vOpcITdU5U0TGnE=; b=XYy2JcS7QfN5LQgtBHsjnb9nI5ziMvsnLCybJgPvT2eLB5sXWSFdom/fs0ioeSKrVKrMoI nTQaUzjfDmhEepts71xR9LJPJ0WLMoAG0NU6k0G52O2KZK5Exm5jcjivSmKAtn1z8ZcRAF Ef7AIp++t+RV2hoU5BGbvbk0sDrhRxc= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=1tbpx1sb; dkim=pass header.d=linutronix.de header.s=2020e header.b=05zUufWP; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf13.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661445703; a=rsa-sha256; cv=none; b=ociqdhLIOm7D5vP0Q2WBjliYyA8GfwtxrkehFxZ9RCa2d3DqZEFAA6NnMftSrtfGQq0e41 KkNd56X4ze+FjtIB3WpCJdXKjU965dp9lFXbFOC+X2BdQ+dtxTNj2vfdmK0yMhHa2YMHOQ Eutz/2TvrgLS8Umyz5N7/DsyWbsd3E0= Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=1tbpx1sb; dkim=pass header.d=linutronix.de header.s=2020e header.b=05zUufWP; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf13.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de X-Rspam-User: X-Rspamd-Queue-Id: 8F3372000C X-Rspamd-Server: rspam10 X-Stat-Signature: zob78dgs6nypieaxpx36n19htzshzz81 X-HE-Tag: 1661445703-468126 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 Move the RT dependency for the initial value of sysctl_compact_unevictable_allowed into Kconfig. Signed-off-by: Thomas Gleixner Cc: Andrew Morton Cc: Nick Terrell Cc: linux-mm@kvack.org Signed-off-by: Sebastian Andrzej Siewior Acked-by: Peter Zijlstra (Intel) --- mm/Kconfig | 6 ++++++ mm/compaction.c | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index 0331f1461f81c..3897e924e40f2 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -579,6 +579,12 @@ config COMPACTION it and then we would be really interested to hear about that at linux-mm@kvack.org. +config COMPACT_UNEVICTABLE_DEFAULT + int + depends on COMPACTION + default 0 if PREEMPT_RT + default 1 + # # support for free page reporting config PAGE_REPORTING diff --git a/mm/compaction.c b/mm/compaction.c index 640fa76228dd9..10561cb1aaad9 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1727,11 +1727,7 @@ typedef enum { * Allow userspace to control policy on scanning the unevictable LRU for * compactable pages. */ -#ifdef CONFIG_PREEMPT_RT -int sysctl_compact_unevictable_allowed __read_mostly = 0; -#else -int sysctl_compact_unevictable_allowed __read_mostly = 1; -#endif +int sysctl_compact_unevictable_allowed __read_mostly = CONFIG_COMPACT_UNEVICTABLE_DEFAULT; static inline void update_fast_start_pfn(struct compact_control *cc, unsigned long pfn)