From patchwork Wed Aug 17 16:26:55 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: 12946243 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 D1D87C3F6B0 for ; Wed, 17 Aug 2022 16:27:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D29218D000A; Wed, 17 Aug 2022 12:27:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD4968D0005; Wed, 17 Aug 2022 12:27:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B74428D000A; Wed, 17 Aug 2022 12:27:40 -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 A72268D0005 for ; Wed, 17 Aug 2022 12:27:40 -0400 (EDT) Received: from smtpin31.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 830FAA16E8 for ; Wed, 17 Aug 2022 16:27:40 +0000 (UTC) X-FDA: 79809615480.31.29805E7 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf31.hostedemail.com (Postfix) with ESMTP id 729D5201D6 for ; Wed, 17 Aug 2022 16:27:38 +0000 (UTC) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1660753656; 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=wiRzqGd4tF+H6l5Mpr46iPb7Iqjo75nyCRDmhTMfrBU=; b=q8KvGO/BxuB0m+9l8pbSRGxWaSIsfwgo/OI7ry39vBOkoqPWERrWsH75Dn5BlgsdwY6cYO USAWE72Uet8ZT6/Tjk0HKWLJeR/E6R9gKCE7rW1B3MjGDdb4AOQGCZEFAGN8la5QrYoadO rhVnmDufo2AuPuHxz6uMHkWS01BxpOk8h/yBQEVvFk8FZXfJlZy/UgjV/mNfuPUskjVQpl ot+Z+JAKtbnOGw7mqxpNJWdjPIiUkHpACE8ds73O6jcVweHre7dgtXg/97kPK5OUcU5Sjj ETY24DRJy65Sul1qjGAA6u/3AL//cw8pj4pTFOMU2MMaiBETekdC+uDmLCCzcQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1660753656; 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=wiRzqGd4tF+H6l5Mpr46iPb7Iqjo75nyCRDmhTMfrBU=; b=W/30GvMvGlOlQIUvbaTWlnADOD2PKDbdwCvsDvpT8PIE9hDi9tNJue2Jum01uAmt4IMFBc sMHHIVmCW86MpoAQ== To: linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Peter Zijlstra , Steven Rostedt , Linus Torvalds , Matthew Wilcox , Andrew Morton , Christoph Lameter , David Rientjes , Joonsoo Kim , Pekka Enberg , Vlastimil Babka , linux-mm@kvack.org, Sebastian Andrzej Siewior Subject: [PATCH 1/9] slub: Make PREEMPT_RT support less convoluted Date: Wed, 17 Aug 2022 18:26:55 +0200 Message-Id: <20220817162703.728679-2-bigeasy@linutronix.de> In-Reply-To: <20220817162703.728679-1-bigeasy@linutronix.de> References: <20220817162703.728679-1-bigeasy@linutronix.de> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b="q8KvGO/B"; dkim=pass header.d=linutronix.de header.s=2020e header.b="W/30GvMv"; spf=pass (imf31.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=1660753659; a=rsa-sha256; cv=none; b=OXvpgQHPG9KnRJ+68WuKwXcGLkaCjgzIcFkwJc+eeU6W0vnE6/qdNpnWVkP3d3tlBpTJg0 ZOpxi+ncrIym33J/sG4aCNP1MKJ28Yxstk0VElLXBkHJOpIE2jU3dP135/9frIeQRPGiBA seRuE0HxnJGolOf7U55n2f7f+xAUAbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660753659; 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=wiRzqGd4tF+H6l5Mpr46iPb7Iqjo75nyCRDmhTMfrBU=; b=7NvMk5lPmljiF0CtxQX3v7ZHFPlwGBqKoVsISqntriKoF4NRAfAcDhot/ItPJUiIrO2/NT Knnd3jM+gIsZOqoQ+5lepL9a6jN9aMOBoAsghD2Lt19vR9ArCzaTDnojsICPXpYG7xmbMN KXG5QuodoZbLxL+RvIY9p2DIjp/WNzc= Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b="q8KvGO/B"; dkim=pass header.d=linutronix.de header.s=2020e header.b="W/30GvMv"; spf=pass (imf31.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-Rspamd-Server: rspam12 X-Stat-Signature: beueg8tr3qrb1r3j3c97y5jr514kgk3q X-Rspamd-Queue-Id: 729D5201D6 X-HE-Tag: 1660753658-3577 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 The slub code already has a few helpers depending on PREEMPT_RT. Add a few more and get rid of the CONFIG_PREEMPT_RT conditionals all over the place. No functional change. Signed-off-by: Thomas Gleixner Cc: Andrew Morton Cc: Christoph Lameter Cc: David Rientjes Cc: Joonsoo Kim Cc: Pekka Enberg Cc: Vlastimil Babka Cc: linux-mm@kvack.org Signed-off-by: Sebastian Andrzej Siewior --- mm/slub.c | 66 +++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 862dbd9af4f52..5f7c5b5bd49f9 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -100,9 +100,11 @@ * except the stat counters. This is a percpu structure manipulated only by * the local cpu, so the lock protects against being preempted or interrupted * by an irq. Fast path operations rely on lockless operations instead. - * On PREEMPT_RT, the local lock does not actually disable irqs (and thus - * prevent the lockless operations), so fastpath operations also need to take - * the lock and are no longer lockless. + * + * On PREEMPT_RT, the local lock neither disables interrupts nor preemption + * which means the lockless fastpath cannot be used as it might interfere with + * an in-progress slow path operations. In this case the local lock is always + * taken but it still utilizes the freelist for the common operations. * * lockless fastpaths * @@ -163,8 +165,11 @@ * function call even on !PREEMPT_RT, use inline preempt_disable() there. */ #ifndef CONFIG_PREEMPT_RT -#define slub_get_cpu_ptr(var) get_cpu_ptr(var) -#define slub_put_cpu_ptr(var) put_cpu_ptr(var) +#define slub_get_cpu_ptr(var) get_cpu_ptr(var) +#define slub_put_cpu_ptr(var) put_cpu_ptr(var) +#define use_lockless_fast_path() (true) +#define slub_local_irq_save(flags) local_irq_save(flags) +#define slub_local_irq_restore(flags) local_irq_restore(flags) #else #define slub_get_cpu_ptr(var) \ ({ \ @@ -176,6 +181,9 @@ do { \ (void)(var); \ migrate_enable(); \ } while (0) +#define use_lockless_fast_path() (false) +#define slub_local_irq_save(flags) do { } while (0) +#define slub_local_irq_restore(flags) do { } while (0) #endif #ifdef CONFIG_SLUB_DEBUG @@ -460,16 +468,14 @@ static __always_inline void __slab_unlock(struct slab *slab) static __always_inline void slab_lock(struct slab *slab, unsigned long *flags) { - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - local_irq_save(*flags); + slub_local_irq_save(*flags); __slab_lock(slab); } static __always_inline void slab_unlock(struct slab *slab, unsigned long *flags) { __slab_unlock(slab); - if (IS_ENABLED(CONFIG_PREEMPT_RT)) - local_irq_restore(*flags); + slub_local_irq_restore(*flags); } /* @@ -482,7 +488,7 @@ static inline bool __cmpxchg_double_slab(struct kmem_cache *s, struct slab *slab void *freelist_new, unsigned long counters_new, const char *n) { - if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + if (use_lockless_fast_path()) lockdep_assert_irqs_disabled(); #if defined(CONFIG_HAVE_CMPXCHG_DOUBLE) && \ defined(CONFIG_HAVE_ALIGNED_STRUCT_PAGE) @@ -3197,14 +3203,8 @@ static __always_inline void *slab_alloc_node(struct kmem_cache *s, struct list_l object = c->freelist; slab = c->slab; - /* - * We cannot use the lockless fastpath on PREEMPT_RT because if a - * slowpath has taken the local_lock_irqsave(), it is not protected - * against a fast path operation in an irq handler. So we need to take - * the slow path which uses local_lock. It is still relatively fast if - * there is a suitable cpu freelist. - */ - if (IS_ENABLED(CONFIG_PREEMPT_RT) || + + if (!use_lockless_fast_path() || unlikely(!object || !slab || !node_match(slab, node))) { object = __slab_alloc(s, gfpflags, node, addr, c); } else { @@ -3463,6 +3463,7 @@ static __always_inline void do_slab_free(struct kmem_cache *s, void *tail_obj = tail ? : head; struct kmem_cache_cpu *c; unsigned long tid; + void **freelist; redo: /* @@ -3477,9 +3478,13 @@ static __always_inline void do_slab_free(struct kmem_cache *s, /* Same with comment on barrier() in slab_alloc_node() */ barrier(); - if (likely(slab == c->slab)) { -#ifndef CONFIG_PREEMPT_RT - void **freelist = READ_ONCE(c->freelist); + if (unlikely(slab != c->slab)) { + __slab_free(s, slab, head, tail_obj, cnt, addr); + return; + } + + if (use_lockless_fast_path()) { + freelist = READ_ONCE(c->freelist); set_freepointer(s, tail_obj, freelist); @@ -3491,16 +3496,8 @@ static __always_inline void do_slab_free(struct kmem_cache *s, note_cmpxchg_failure("slab_free", s, tid); goto redo; } -#else /* CONFIG_PREEMPT_RT */ - /* - * We cannot use the lockless fastpath on PREEMPT_RT because if - * a slowpath has taken the local_lock_irqsave(), it is not - * protected against a fast path operation in an irq handler. So - * we need to take the local_lock. We shouldn't simply defer to - * __slab_free() as that wouldn't use the cpu freelist at all. - */ - void **freelist; - + } else { + /* Update the free list under the local lock */ local_lock(&s->cpu_slab->lock); c = this_cpu_ptr(s->cpu_slab); if (unlikely(slab != c->slab)) { @@ -3515,11 +3512,8 @@ static __always_inline void do_slab_free(struct kmem_cache *s, c->tid = next_tid(tid); local_unlock(&s->cpu_slab->lock); -#endif - stat(s, FREE_FASTPATH); - } else - __slab_free(s, slab, head, tail_obj, cnt, addr); - + } + stat(s, FREE_FASTPATH); } static __always_inline void slab_free(struct kmem_cache *s, struct slab *slab, From patchwork Wed Aug 17 16:26:58 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: 12946239 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 6DD9CC25B08 for ; Wed, 17 Aug 2022 16:27:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 954598D0006; Wed, 17 Aug 2022 12:27:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9035E8D0005; Wed, 17 Aug 2022 12:27:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CB028D0006; Wed, 17 Aug 2022 12:27:39 -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 6EF048D0005 for ; Wed, 17 Aug 2022 12:27:39 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 465731A1712 for ; Wed, 17 Aug 2022 16:27:39 +0000 (UTC) X-FDA: 79809615438.30.998A0CB Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf01.hostedemail.com (Postfix) with ESMTP id 65D4F401CC for ; Wed, 17 Aug 2022 16:27:38 +0000 (UTC) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1660753657; 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=uD14oDgx3FWYy2lpa5ke4a7FAfpDJmqbWQP4XZyslYQ=; b=pwMEWV1ORtsBhWwUa8v7DjvJNCSvXYXfvaI1nzWmFzO34axX2YU1OwIEv00HeOxx9EskLh n+X76iezbyBUafup4Bs87iFbG7f4r2MULKgdyTvJq2kbNQ2tZDpIyJqLJ72ZwmkNQT59QD 5y2qy0qOmjLmW1nRTLrHlwYrnBUfe4IV0pdjgIh1shupwHaZTqPkgTXGR/Q7SveBeNCjlt qXEqH/eXj2NqFfKLq/rYcI9lCgqib3CTeGepPoQMDcTGRJ5ZVlpVKAGEhBZYoOs69OQ61e RIcQp/kgnY+LkE3zxJWz14klf9oOPJMCpCQ7jJ1k271/8RS1qLUBQnKfblyOrw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1660753657; 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=uD14oDgx3FWYy2lpa5ke4a7FAfpDJmqbWQP4XZyslYQ=; b=w/DxSHF39+Tt6W/BvI0ZfDJidVshXYBpD/T6BXvbSwmFZMmR2HP2P4v1x02SJAGzL+riKK Df1TwmEPcoJlPPBA== 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 4/9] mm/vmstat: Use preempt_[dis|en]able_nested() Date: Wed, 17 Aug 2022 18:26:58 +0200 Message-Id: <20220817162703.728679-5-bigeasy@linutronix.de> In-Reply-To: <20220817162703.728679-1-bigeasy@linutronix.de> References: <20220817162703.728679-1-bigeasy@linutronix.de> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660753658; a=rsa-sha256; cv=none; b=xXMVq9mjFjhJ3caBj8K76O1T6/6WUuuK5d5XNFu9WdphAS8R/cHOpQJwtS5i81RBYZFGTi nHcL2wpmmf9nQcWxd9zlTLSRWrBNbLMaKZaPE/3dEtxzzVgj2ASsO4avsF4wFzj9n0lzS3 Zt2QT24BodBorp1UaFpHftMqv0WFZn8= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=pwMEWV1O; dkim=pass header.d=linutronix.de header.s=2020e header.b="w/DxSHF3"; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf01.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660753658; 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=uD14oDgx3FWYy2lpa5ke4a7FAfpDJmqbWQP4XZyslYQ=; b=Td060NkJ7aqopeC+23p0JAfpkaSimzK1PpURBlAgfpyx21x73ZxWs9BI4mrvPLw7QZcf9R tg0yCsmK5ypJNvGkR8AvUYpqx3Z99y45KUCrNTGKc3mbCHmo25UoK+jQKLvqpunj7aI0Zc K5OfU52+XJAoMRxbQSd1Q43lGv7ih8E= X-Stat-Signature: ymp54u43wk8nweucxyqh6uy771i8pzju X-Rspamd-Queue-Id: 65D4F401CC Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=pwMEWV1O; dkim=pass header.d=linutronix.de header.s=2020e header.b="w/DxSHF3"; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf01.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-Server: rspam10 X-HE-Tag: 1660753658-325894 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 --- 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 Wed Aug 17 16:26:59 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: 12946240 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 30968C32771 for ; Wed, 17 Aug 2022 16:27:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 116FA8D0007; Wed, 17 Aug 2022 12:27:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C7198D0005; Wed, 17 Aug 2022 12:27:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6F168D0005; Wed, 17 Aug 2022 12:27:39 -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 DA7D28D0005 for ; Wed, 17 Aug 2022 12:27:39 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A25001C4F3E for ; Wed, 17 Aug 2022 16:27:39 +0000 (UTC) X-FDA: 79809615438.27.F51C729 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf18.hostedemail.com (Postfix) with ESMTP id 03F4D1C01B4 for ; Wed, 17 Aug 2022 16:27:38 +0000 (UTC) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1660753657; 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=pKc+6HUSNpaxlBjXSX1XTp4QrP/t25TRKhHhhX/hF54=; b=FpU5qd203NglSjouxtHxwHoFNL1T2ZLmljndcWC4FtmBFWjgUqwHAjv7zQvsovs6hCxhlX JoHA0FMFOkBHqqoKdp7EjJdeRWc5Rn4pgzL62l1FMpBxxWCZ+0csVl9GHyvibFAee9cf9n OSA1Tb0ugOTGnMu1nFM4VKdTkKVezo30Ta4GQ3squD4pDt0OHMXmNMcw+ygtvY66XPLoMK vg5p1TnDFQA7yOOLOnrjP/QULpMws95kTgxqnbYqy2ioH17zW3J3ui+pCgV/JZX9xHJe5+ ZLk6Mz/fYw8wN5r5rvTm83XCKdbXLKNlarnAneLdFP+vrPc4BYaxzimqyBEPDA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1660753657; 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=pKc+6HUSNpaxlBjXSX1XTp4QrP/t25TRKhHhhX/hF54=; b=VeiXr1hZu9YMVGXyrDrMs79lKviokSPPt/kOD1hYDXn1qxwRf9t8Nj70PwNgMW7CRyMxjK iYibp+Y7KobngcAQ== 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 5/9] mm/debug: Provide VM_WARN_ON_IRQS_ENABLED() Date: Wed, 17 Aug 2022 18:26:59 +0200 Message-Id: <20220817162703.728679-6-bigeasy@linutronix.de> In-Reply-To: <20220817162703.728679-1-bigeasy@linutronix.de> References: <20220817162703.728679-1-bigeasy@linutronix.de> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=FpU5qd20; dkim=pass header.d=linutronix.de header.s=2020e header.b=VeiXr1hZ; spf=pass (imf18.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=1660753659; a=rsa-sha256; cv=none; b=O+mjbHRJ4va4d91vmVD+XnlilD/D5x4wTb0Pds/RP8DQHG7aeIQJ04KWI0o1CHocd7b7Nq gvJqXthA0aQ7pjyxxYB4ibHKF37rieo2zFEgWDdScMjEqbPeXm+6RTTQN0CWUhMX/qClkQ C+FbZSiEOVTf6wgLEQXAw1W2MfSg5ic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660753659; 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=pKc+6HUSNpaxlBjXSX1XTp4QrP/t25TRKhHhhX/hF54=; b=YBF9UVgqqPZH++5S7hkjK8ju6yjqBj4rJ7HL0Ikaxf6YDRY/kZZVax7kITflpVoyf/v731 Ar3E7tYHvvdGW3jyoqr9OCrueVu3Bt51SdpPtMTxAfmIrWCBO0L5OYU1IdNMTcDCx2AJFp /l7B7/Ko8ScvxxcrEXOde4gm834zV40= Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=FpU5qd20; dkim=pass header.d=linutronix.de header.s=2020e header.b=VeiXr1hZ; spf=pass (imf18.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-Rspamd-Server: rspam12 X-Stat-Signature: f9hosdbxxffqgn8r53w33xumfc58ayi3 X-Rspamd-Queue-Id: 03F4D1C01B4 X-HE-Tag: 1660753658-595397 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 --- 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 Wed Aug 17 16:27:00 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: 12946242 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 52E49C32771 for ; Wed, 17 Aug 2022 16:27:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F9008D0009; Wed, 17 Aug 2022 12:27:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A4A98D0005; Wed, 17 Aug 2022 12:27:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 644698D0009; Wed, 17 Aug 2022 12:27:40 -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 539B28D0005 for ; Wed, 17 Aug 2022 12:27:40 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2E01A161756 for ; Wed, 17 Aug 2022 16:27:40 +0000 (UTC) X-FDA: 79809615480.01.5F63EEB Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf24.hostedemail.com (Postfix) with ESMTP id 4D9551801E4 for ; Wed, 17 Aug 2022 16:27:39 +0000 (UTC) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1660753657; 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=icKYkzOEkU10wqYj/AO1hlieqfsCO6opQIYue93MICc=; b=WUwxVW+uGIaO0szg7BxOu1wCzapAwDdXZYNPFf3kiI2xBtu8Es480fO/5T71TMYiQKTjL2 Y5lWxIQqJ7x7BoSnhKaFZCzRhG7+8yHeQ5/tmMMThFpP2L1agJ4szHQY5JVMPUakod0IbE yIc6Gl3i758gJbuMjFnB7KmeyFMZ5xJ0mfQb/Ikck/iVjEeodnOdRlmZ/pr1p0eX5sgM4R M4paCBlURfexAPIOmkPU+fjGxjbUG3Dnqp+YkiX1A4mHylwtylhelH9PtNbQGgVaw0NytL acYvZri+GlxU9tb6ucjTkjxdrXJYjietaE0V6tqA4Eq9vmaflVkD4q9k8U95TQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1660753657; 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=icKYkzOEkU10wqYj/AO1hlieqfsCO6opQIYue93MICc=; b=500tFezzQJcGWrboXp6CHY0SHvmE+zDVA//pAXoHOs0Jh0IxU+Aa1gSbSy/Lv6WZU3qbC3 94vz4DsO75E0UxCQ== 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 6/9] mm/memcontrol: Replace the PREEMPT_RT conditionals Date: Wed, 17 Aug 2022 18:27:00 +0200 Message-Id: <20220817162703.728679-7-bigeasy@linutronix.de> In-Reply-To: <20220817162703.728679-1-bigeasy@linutronix.de> References: <20220817162703.728679-1-bigeasy@linutronix.de> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660753659; a=rsa-sha256; cv=none; b=4Gu5gAY+uYpnE184wpE/YnGp2lo3RzDzfkQ+ZSH/15Ahozzm7duTfQxGiRIQIpg0TjNskO F4gwyYk8Ru5Dv5LjHownyn2FZB2j5HxfyZ5JkRS3duz5Wwo/td66gxyFDGBKaFBYi7zgxw htPpuzk8GfeeZ859sw8+epEcauN9vPU= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=WUwxVW+u; dkim=pass header.d=linutronix.de header.s=2020e header.b=500tFezz; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf24.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660753659; 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=icKYkzOEkU10wqYj/AO1hlieqfsCO6opQIYue93MICc=; b=u9VYrkygzVLcO0eMu9gZo3fF9e67fK89EhmFwywZuwwRjoxMGnUk7j9ig06J2a0Mle10rt cfvAurglK3gQk8yMrFdTwwfkM5QMR2oKJMO9Z/xZjbnAh8tldGQ7mwZJuMc7+zwJS0RbRf XbcfyJH+UjRaQNg2MKRQ1KE3v24Atxo= X-Stat-Signature: h9rmn6q9rtykwxfgtj5woxs9zn88abcd X-Rspamd-Queue-Id: 4D9551801E4 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=WUwxVW+u; dkim=pass header.d=linutronix.de header.s=2020e header.b=500tFezz; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf24.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-Server: rspam10 X-HE-Tag: 1660753659-532900 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 --- 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 Wed Aug 17 16:27:01 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: 12946241 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 92BB0C32772 for ; Wed, 17 Aug 2022 16:27:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 363148D0008; Wed, 17 Aug 2022 12:27:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2156C8E0001; Wed, 17 Aug 2022 12:27:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0783C8D0008; Wed, 17 Aug 2022 12:27:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E26AA8D0007 for ; Wed, 17 Aug 2022 12:27:39 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B73D4C16FA for ; Wed, 17 Aug 2022 16:27:39 +0000 (UTC) X-FDA: 79809615438.12.F326052 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf05.hostedemail.com (Postfix) with ESMTP id 1DE661001BC for ; Wed, 17 Aug 2022 16:27:38 +0000 (UTC) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1660753658; 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=F9l7y3m8zkOiNy05wS2hSJk+waPS7nO5NnqSs6GtD6Q=; b=ahVLd9nL3dCq1i5nadi2s73phgxk46U/cAa/JGm1oBcNYwokEpPrfwAB5Lp8ZJORaH1smt ZYwfZrkBmj22GkgDrGdyC/aHgVNIEZEDpcUaMSwto7T7OLlZal2MdwREue2Bz+8KTPCyFp /TRn6vY7nem5QbWT6tHzSw15B66Y7md6oGuMmI+7/KLDsGZ14FFiC3QTUecsGOB9A7hLCU 8sPjta8aon+QUj27nhHmP1S8g9DL0Yr8+ZZ/wn5InvTm/9e5GFQX3Pj3Uc+qQqGdEAvHqm dHT6Yf1fco8y91x+kaPu74FobZPLuro1Fyd6S4pQgt0ee3pTDes3A1zJL3L8+A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1660753658; 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=F9l7y3m8zkOiNy05wS2hSJk+waPS7nO5NnqSs6GtD6Q=; b=KHC1BnhWzRoSCVIlYh78XhedbXu636S/1THUCnmQGK5a+5dok80bN92jiqq/g3b6OU1xoA htdYRwUhK/B08uDg== 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 7/9] mm/compaction: Get rid of RT ifdeffery Date: Wed, 17 Aug 2022 18:27:01 +0200 Message-Id: <20220817162703.728679-8-bigeasy@linutronix.de> In-Reply-To: <20220817162703.728679-1-bigeasy@linutronix.de> References: <20220817162703.728679-1-bigeasy@linutronix.de> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660753659; a=rsa-sha256; cv=none; b=XJ710BNZMnooiZS3gnzJeQDLwyPGqKbkf8Uyl7HMwtUXD8Ib0Y+IbvbNxvbq1NpAzDaDZA SkGd8+UEqKfwyzuZZxazmUekS9oFYmFfOM4lu5gESAwLzogWvhHSq4J9ed5FfWaPVbOg0p d7S+Tnvh8+HKB238Yi5N5yj44VTq6V0= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=ahVLd9nL; dkim=pass header.d=linutronix.de header.s=2020e header.b=KHC1BnhW; spf=pass (imf05.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=1660753659; 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=F9l7y3m8zkOiNy05wS2hSJk+waPS7nO5NnqSs6GtD6Q=; b=7qLuCLWKKhyUJZwG5sKicqi1WRlRpQLUjmw0ofPdXI7qzBZTFDImgksSvRgTUwXl90b9vU jT/g51AFI4BhJ/ewJarGmzmqnXRKlObtRf9R7Hh/tiXJRlDih8Mv0lK3zzAresy7JGMqJk OQ/Ut1/3+1IbYGlmMW3+Q1ZUHFNCxPQ= X-Stat-Signature: urze7sx1qm8pk88mkgzns9js77ugzfjz X-Rspamd-Queue-Id: 1DE661001BC Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=ahVLd9nL; dkim=pass header.d=linutronix.de header.s=2020e header.b=KHC1BnhW; spf=pass (imf05.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-Rspamd-Server: rspam03 X-HE-Tag: 1660753658-578854 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 --- mm/Kconfig | 5 +++++ mm/compaction.c | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index 0331f1461f81c..a0506a54a4f3f 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -579,6 +579,11 @@ config COMPACTION it and then we would be really interested to hear about that at linux-mm@kvack.org. +config COMPACT_UNEVICTABLE_DEFAULT + int + 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)