* [PATCH v2 3/8] mm/vmstat: Use preempt_[dis|en]able_nested()
[not found] <20220825164131.402717-1-bigeasy@linutronix.de>
@ 2022-08-25 16:41 ` Sebastian Andrzej Siewior
2022-09-01 14:41 ` Michal Hocko
2022-08-25 16:41 ` [PATCH v2 4/8] mm/debug: Provide VM_WARN_ON_IRQS_ENABLED() Sebastian Andrzej Siewior
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Sebastian Andrzej Siewior @ 2022-08-25 16:41 UTC (permalink / raw)
To: linux-kernel
Cc: Thomas Gleixner, Peter Zijlstra, Steven Rostedt, Linus Torvalds,
Matthew Wilcox, Andrew Morton, linux-mm,
Sebastian Andrzej Siewior
From: Thomas Gleixner <tglx@linutronix.de>
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 <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
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)
--
2.37.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/8] mm/debug: Provide VM_WARN_ON_IRQS_ENABLED()
[not found] <20220825164131.402717-1-bigeasy@linutronix.de>
2022-08-25 16:41 ` [PATCH v2 3/8] mm/vmstat: Use preempt_[dis|en]able_nested() Sebastian Andrzej Siewior
@ 2022-08-25 16:41 ` Sebastian Andrzej Siewior
2022-09-01 14:41 ` Michal Hocko
2022-08-25 16:41 ` [PATCH v2 5/8] mm/memcontrol: Replace the PREEMPT_RT conditionals Sebastian Andrzej Siewior
2022-08-25 16:41 ` [PATCH v2 6/8] mm/compaction: Get rid of RT ifdeffery Sebastian Andrzej Siewior
3 siblings, 1 reply; 7+ messages in thread
From: Sebastian Andrzej Siewior @ 2022-08-25 16:41 UTC (permalink / raw)
To: linux-kernel
Cc: Thomas Gleixner, Peter Zijlstra, Steven Rostedt, Linus Torvalds,
Matthew Wilcox, Andrew Morton, linux-mm,
Sebastian Andrzej Siewior
From: Thomas Gleixner <tglx@linutronix.de>
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 <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
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
--
2.37.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 5/8] mm/memcontrol: Replace the PREEMPT_RT conditionals
[not found] <20220825164131.402717-1-bigeasy@linutronix.de>
2022-08-25 16:41 ` [PATCH v2 3/8] mm/vmstat: Use preempt_[dis|en]able_nested() Sebastian Andrzej Siewior
2022-08-25 16:41 ` [PATCH v2 4/8] mm/debug: Provide VM_WARN_ON_IRQS_ENABLED() Sebastian Andrzej Siewior
@ 2022-08-25 16:41 ` Sebastian Andrzej Siewior
2022-09-01 14:45 ` Michal Hocko
2022-08-25 16:41 ` [PATCH v2 6/8] mm/compaction: Get rid of RT ifdeffery Sebastian Andrzej Siewior
3 siblings, 1 reply; 7+ messages in thread
From: Sebastian Andrzej Siewior @ 2022-08-25 16:41 UTC (permalink / raw)
To: linux-kernel
Cc: Thomas Gleixner, Peter Zijlstra, Steven Rostedt, Linus Torvalds,
Matthew Wilcox, Johannes Weiner, Michal Hocko, Roman Gushchin,
Shakeel Butt, Muchun Song, cgroups, linux-mm,
Sebastian Andrzej Siewior
From: Thomas Gleixner <tglx@linutronix.de>
Use VM_WARN_ON_IRQS_ENABLED() and preempt_disable/enable_nested() to
replace the CONFIG_PREEMPT_RT #ifdeffery.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: cgroups@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
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();
}
}
--
2.37.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 6/8] mm/compaction: Get rid of RT ifdeffery
[not found] <20220825164131.402717-1-bigeasy@linutronix.de>
` (2 preceding siblings ...)
2022-08-25 16:41 ` [PATCH v2 5/8] mm/memcontrol: Replace the PREEMPT_RT conditionals Sebastian Andrzej Siewior
@ 2022-08-25 16:41 ` Sebastian Andrzej Siewior
3 siblings, 0 replies; 7+ messages in thread
From: Sebastian Andrzej Siewior @ 2022-08-25 16:41 UTC (permalink / raw)
To: linux-kernel
Cc: Thomas Gleixner, Peter Zijlstra, Steven Rostedt, Linus Torvalds,
Matthew Wilcox, Andrew Morton, Nick Terrell, linux-mm,
Sebastian Andrzej Siewior
From: Thomas Gleixner <tglx@linutronix.de>
Move the RT dependency for the initial value of
sysctl_compact_unevictable_allowed into Kconfig.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Terrell <terrelln@fb.com>
Cc: linux-mm@kvack.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
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)
--
2.37.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/8] mm/vmstat: Use preempt_[dis|en]able_nested()
2022-08-25 16:41 ` [PATCH v2 3/8] mm/vmstat: Use preempt_[dis|en]able_nested() Sebastian Andrzej Siewior
@ 2022-09-01 14:41 ` Michal Hocko
0 siblings, 0 replies; 7+ messages in thread
From: Michal Hocko @ 2022-09-01 14:41 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-kernel, Thomas Gleixner, Peter Zijlstra, Steven Rostedt,
Linus Torvalds, Matthew Wilcox, Andrew Morton, linux-mm
On Thu 25-08-22 18:41:26, Sebastian Andrzej Siewior wrote:
> From: Thomas Gleixner <tglx@linutronix.de>
>
> 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 <tglx@linutronix.de>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: linux-mm@kvack.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Thanks!
> ---
> 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)
> --
> 2.37.2
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 4/8] mm/debug: Provide VM_WARN_ON_IRQS_ENABLED()
2022-08-25 16:41 ` [PATCH v2 4/8] mm/debug: Provide VM_WARN_ON_IRQS_ENABLED() Sebastian Andrzej Siewior
@ 2022-09-01 14:41 ` Michal Hocko
0 siblings, 0 replies; 7+ messages in thread
From: Michal Hocko @ 2022-09-01 14:41 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-kernel, Thomas Gleixner, Peter Zijlstra, Steven Rostedt,
Linus Torvalds, Matthew Wilcox, Andrew Morton, linux-mm
On Thu 25-08-22 18:41:27, Sebastian Andrzej Siewior wrote:
> From: Thomas Gleixner <tglx@linutronix.de>
>
> 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 <tglx@linutronix.de>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: linux-mm@kvack.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Thanks!
> ---
> 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
> --
> 2.37.2
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 5/8] mm/memcontrol: Replace the PREEMPT_RT conditionals
2022-08-25 16:41 ` [PATCH v2 5/8] mm/memcontrol: Replace the PREEMPT_RT conditionals Sebastian Andrzej Siewior
@ 2022-09-01 14:45 ` Michal Hocko
0 siblings, 0 replies; 7+ messages in thread
From: Michal Hocko @ 2022-09-01 14:45 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-kernel, Thomas Gleixner, Peter Zijlstra, Steven Rostedt,
Linus Torvalds, Matthew Wilcox, Johannes Weiner, Roman Gushchin,
Shakeel Butt, Muchun Song, cgroups, linux-mm
On Thu 25-08-22 18:41:28, Sebastian Andrzej Siewior wrote:
> From: Thomas Gleixner <tglx@linutronix.de>
>
> Use VM_WARN_ON_IRQS_ENABLED() and preempt_disable/enable_nested() to
> replace the CONFIG_PREEMPT_RT #ifdeffery.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: Roman Gushchin <roman.gushchin@linux.dev>
> Cc: Shakeel Butt <shakeelb@google.com>
> Cc: Muchun Song <songmuchun@bytedance.com>
> Cc: cgroups@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>
> Reviewed-by: Muchun Song <songmuchun@bytedance.com>
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Thanks!
> ---
> 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();
> }
> }
>
> --
> 2.37.2
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-09-01 14:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20220825164131.402717-1-bigeasy@linutronix.de>
2022-08-25 16:41 ` [PATCH v2 3/8] mm/vmstat: Use preempt_[dis|en]able_nested() Sebastian Andrzej Siewior
2022-09-01 14:41 ` Michal Hocko
2022-08-25 16:41 ` [PATCH v2 4/8] mm/debug: Provide VM_WARN_ON_IRQS_ENABLED() Sebastian Andrzej Siewior
2022-09-01 14:41 ` Michal Hocko
2022-08-25 16:41 ` [PATCH v2 5/8] mm/memcontrol: Replace the PREEMPT_RT conditionals Sebastian Andrzej Siewior
2022-09-01 14:45 ` Michal Hocko
2022-08-25 16:41 ` [PATCH v2 6/8] mm/compaction: Get rid of RT ifdeffery Sebastian Andrzej Siewior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).