Skip to contentSkip to conversation

memcg: Remove the lockdep assert from __mod_objcg_mlstate().

PATCH Superseded Sebastian Andrzej Siewior 4 participants 13 messages May 28, 2024 – May 29, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memcg: Remove the lockdep assert from __mod_objcg_mlstate().

The assert was introduced in the commit cited below as an insurance that the semantic is the same after the local_irq_save() has been removed and the function has been made static.

The original requirement to disable interrupt was due the modification of per-CPU counters which require interrupts to be disabled because the counter update operation is not atomic and some of the counters are updated from interrupt context.

All callers of __mod_objcg_mlstate() acquire a lock (memcg_stock.stock_lock) which disables interrupts on !PREEMPT_RT and the lockdep assert is satisfied. On PREEMPT_RT the interrupts are not disabled and the assert triggers.

The safety of the counter update is already ensured by VM_WARN_ON_IRQS_ENABLED() which is part of memcg_stats_lock() and does not require yet another check.

Remove the lockdep assert from __mod_objcg_mlstate().

Fixes 91882c1617c15 ("memcg: simple cleanup of stats update functions")
---
 mm/memcontrol.c |    2 --
 1 file changed, 2 deletions(-)
mm/memcontrol.c +0 -2
@@ -3147,8 +3147,6 @@ static inline void __mod_objcg_mlstate(s
 	struct mem_cgroup *memcg;
 	struct lruvec *lruvec;
 
-	lockdep_assert_irqs_disabled();
-
 	rcu_read_lock();
 	memcg = obj_cgroup_memcg(objcg);
 	lruvec = mem_cgroup_lruvec(memcg, pgdat);
Acked-by Vlastimil Babka on v1 1/1
#1 lore raw
Quoted 9 lines · Sebastian Andrzej Siewior

The assert was introduced in the commit cited below as an insurance that the semantic is the same after the local_irq_save() has been removed and the function has been made static.

The original requirement to disable interrupt was due the modification of per-CPU counters which require interrupts to be disabled because the counter update operation is not atomic and some of the counters are updated from interrupt context.

Quoted 8 lines

All callers of __mod_objcg_mlstate() acquire a lock (memcg_stock.stock_lock) which disables interrupts on !PREEMPT_RT and the lockdep assert is satisfied. On PREEMPT_RT the interrupts are not disabled and the assert triggers.

The safety of the counter update is already ensured by VM_WARN_ON_IRQS_ENABLED() which is part of memcg_stats_lock() and does not require yet another check.

I think here it's __mod_memcg_lruvec_state() doing the VM_WARN_ON_ as we don't go through memcg_stats_lock()?

Quoted 4 lines

Remove the lockdep assert from __mod_objcg_mlstate().

Fixes 91882c1617c15 ("memcg: simple cleanup of stats update functions")

mm-hotfixes as it's a rc1 regression

Quoted 15 lines
---
 mm/memcontrol.c |    2 --
 1 file changed, 2 deletions(-)
mm/memcontrol.c +0 -2
@@ -3147,8 +3147,6 @@ static inline void __mod_objcg_mlstate(s
 	struct mem_cgroup *memcg;
 	struct lruvec *lruvec;
 
-	lockdep_assert_irqs_disabled();
-
 	rcu_read_lock();
 	memcg = obj_cgroup_memcg(objcg);
 	lruvec = mem_cgroup_lruvec(memcg, pgdat);
#2 lore raw
Quoted 6 lines · Vlastimil Babka (SUSE)
Quoted 3 lines

The safety of the counter update is already ensured by VM_WARN_ON_IRQS_ENABLED() which is part of memcg_stats_lock() and does not require yet another check.

I think here it's __mod_memcg_lruvec_state() doing the VM_WARN_ON_ as we don't go through memcg_stats_lock()?

It is either VM_WARN_ON_IRQS_ENABLED() directly as in __mod_memcg_lruvec_state() (which is special) or memcg_stats_lock().

Do you want me to rephrase this part?

Sebastian

#3 lore raw
Quoted 5 lines · Sebastian Andrzej Siewior
Quoted 4 lines · Vlastimil Babka (SUSE)
Quoted 3 lines

The safety of the counter update is already ensured by VM_WARN_ON_IRQS_ENABLED() which is part of memcg_stats_lock() and does not require yet another check.

Quoted 7 lines
Quoted 2 lines

I think here it's __mod_memcg_lruvec_state() doing the VM_WARN_ON_ as we don't go through memcg_stats_lock()?

It is either VM_WARN_ON_IRQS_ENABLED() directly as in __mod_memcg_lruvec_state() (which is special) or memcg_stats_lock().

Do you want me to rephrase this part?

I think just s/memcg_stats_lock()/__mod_memcg_lruvec_state()/ in your phrasing, since we are removing the lockdep assert from path that calls __mod_memcg_lruvec_state() and not memcg_stats_lock()?
Or am I missing something?

Quoted 1 line

Sebastian

#4 lore raw

PATCH v2 1/1 memcg: Remove the lockdep assert from __mod_objcg_mlstate().

The assert was introduced in the commit cited below as an insurance that the semantic is the same after the local_irq_save() has been removed and the function has been made static.

The original requirement to disable interrupt was due the modification of per-CPU counters which require interrupts to be disabled because the counter update operation is not atomic and some of the counters are updated from interrupt context.

All callers of __mod_objcg_mlstate() acquire a lock (memcg_stock.stock_lock) which disables interrupts on !PREEMPT_RT and the lockdep assert is satisfied. On PREEMPT_RT the interrupts are not disabled and the assert triggers.

The safety of the counter update is already ensured by VM_WARN_ON_IRQS_ENABLED() which is part of __mod_memcg_lruvec_state() and does not require yet another check.

Remove the lockdep assert from __mod_objcg_mlstate().

Fixes 91882c1617c15 ("memcg: simple cleanup of stats update functions")

---

Quoted 4 lines · Vlastimil Babka (SUSE)

I think just s/memcg_stats_lock()/__mod_memcg_lruvec_state()/ in your phrasing, since we are removing the lockdep assert from path that calls __mod_memcg_lruvec_state() and not memcg_stats_lock()?
Or am I missing something?

Yeah, makes sense.

 mm/memcontrol.c |    2 --
 1 file changed, 2 deletions(-)
mm/memcontrol.c +0 -2
@@ -3147,8 +3147,6 @@ static inline void __mod_objcg_mlstate(s
 	struct mem_cgroup *memcg;
 	struct lruvec *lruvec;
 
-	lockdep_assert_irqs_disabled();
-
 	rcu_read_lock();
 	memcg = obj_cgroup_memcg(objcg);
 	lruvec = mem_cgroup_lruvec(memcg, pgdat);
Acked-by Vlastimil Babka on v2 1/1
#5 lore raw
Quoted 18 lines · Sebastian Andrzej Siewior

The assert was introduced in the commit cited below as an insurance that the semantic is the same after the local_irq_save() has been removed and the function has been made static.

The original requirement to disable interrupt was due the modification of per-CPU counters which require interrupts to be disabled because the counter update operation is not atomic and some of the counters are updated from interrupt context.

All callers of __mod_objcg_mlstate() acquire a lock (memcg_stock.stock_lock) which disables interrupts on !PREEMPT_RT and the lockdep assert is satisfied. On PREEMPT_RT the interrupts are not disabled and the assert triggers.

The safety of the counter update is already ensured by VM_WARN_ON_IRQS_ENABLED() which is part of __mod_memcg_lruvec_state() and does not require yet another check.

Quoted 5 lines

Remove the lockdep assert from __mod_objcg_mlstate().

Fixes 91882c1617c15 ("memcg: simple cleanup of stats update functions")

mm-hotfixes as it's a rc1 regression

Quoted 23 lines

---

Quoted 4 lines · Vlastimil Babka (SUSE)

I think just s/memcg_stats_lock()/__mod_memcg_lruvec_state()/ in your phrasing, since we are removing the lockdep assert from path that calls __mod_memcg_lruvec_state() and not memcg_stats_lock()?
Or am I missing something?

Yeah, makes sense.

 mm/memcontrol.c |    2 --
 1 file changed, 2 deletions(-)
mm/memcontrol.c +0 -2
@@ -3147,8 +3147,6 @@ static inline void __mod_objcg_mlstate(s
 	struct mem_cgroup *memcg;
 	struct lruvec *lruvec;
 
-	lockdep_assert_irqs_disabled();
-
 	rcu_read_lock();
 	memcg = obj_cgroup_memcg(objcg);
 	lruvec = mem_cgroup_lruvec(memcg, pgdat);
maintainer
#6 lore raw
In reply to Sebastian Andrzej Siewior
Quoted 9 lines · Sebastian Andrzej Siewior

The assert was introduced in the commit cited below as an insurance that the semantic is the same after the local_irq_save() has been removed and the function has been made static.

The original requirement to disable interrupt was due the modification of per-CPU counters which require interrupts to be disabled because the counter update operation is not atomic and some of the counters are updated from interrupt context.

Quoted 8 lines

All callers of __mod_objcg_mlstate() acquire a lock (memcg_stock.stock_lock) which disables interrupts on !PREEMPT_RT and the lockdep assert is satisfied. On PREEMPT_RT the interrupts are not disabled and the assert triggers.

The safety of the counter update is already ensured by VM_WARN_ON_IRQS_ENABLED() which is part of __mod_memcg_lruvec_state() and does not require yet another check.

One question on VM_WARN_ON_IRQS_ENABLED() in __mod_memcg_lruvec_state(). On a PREEMPT_RT kernel with CONFIG_DEBUG_VM, will that VM_WARN_ON_IRQS_ENABLED() cause a splat or VM_WARN_ON_IRQS_ENABLED is special on PREEMPT_RT kernels?

Quoted 29 lines

Remove the lockdep assert from __mod_objcg_mlstate().

Fixes 91882c1617c15 ("memcg: simple cleanup of stats update functions")

---

Quoted 4 lines · Vlastimil Babka (SUSE)

I think just s/memcg_stats_lock()/__mod_memcg_lruvec_state()/ in your phrasing, since we are removing the lockdep assert from path that calls __mod_memcg_lruvec_state() and not memcg_stats_lock()?
Or am I missing something?

Yeah, makes sense.

 mm/memcontrol.c |    2 --
 1 file changed, 2 deletions(-)
mm/memcontrol.c +0 -2
@@ -3147,8 +3147,6 @@ static inline void __mod_objcg_mlstate(s
 	struct mem_cgroup *memcg;
 	struct lruvec *lruvec;
 
-	lockdep_assert_irqs_disabled();
-
 	rcu_read_lock();
 	memcg = obj_cgroup_memcg(objcg);
 	lruvec = mem_cgroup_lruvec(memcg, pgdat);
#7 lore raw
Quoted 15 lines · Shakeel Butt
Quoted 14 lines · Sebastian Andrzej Siewior

The assert was introduced in the commit cited below as an insurance that the semantic is the same after the local_irq_save() has been removed and the function has been made static.

The original requirement to disable interrupt was due the modification of per-CPU counters which require interrupts to be disabled because the counter update operation is not atomic and some of the counters are updated from interrupt context.

All callers of __mod_objcg_mlstate() acquire a lock (memcg_stock.stock_lock) which disables interrupts on !PREEMPT_RT and the lockdep assert is satisfied. On PREEMPT_RT the interrupts are not disabled and the assert triggers.

Quoted 8 lines
Quoted 3 lines

The safety of the counter update is already ensured by VM_WARN_ON_IRQS_ENABLED() which is part of __mod_memcg_lruvec_state() and does not require yet another check.

One question on VM_WARN_ON_IRQS_ENABLED() in __mod_memcg_lruvec_state(). On a PREEMPT_RT kernel with CONFIG_DEBUG_VM, will that VM_WARN_ON_IRQS_ENABLED() cause a splat or VM_WARN_ON_IRQS_ENABLED is special on PREEMPT_RT kernels?

It only does something with CONFIG_DEBUG_VM_IRQSOFF and that's disabled by dependencies on PREEMPT_RT :)

Quoted 29 lines
Quoted 29 lines

Remove the lockdep assert from __mod_objcg_mlstate().

Fixes 91882c1617c15 ("memcg: simple cleanup of stats update functions")

---

Quoted 4 lines · Vlastimil Babka (SUSE)

I think just s/memcg_stats_lock()/__mod_memcg_lruvec_state()/ in your phrasing, since we are removing the lockdep assert from path that calls __mod_memcg_lruvec_state() and not memcg_stats_lock()?
Or am I missing something?

Yeah, makes sense.

 mm/memcontrol.c |    2 --
 1 file changed, 2 deletions(-)
mm/memcontrol.c +0 -2
@@ -3147,8 +3147,6 @@ static inline void __mod_objcg_mlstate(s
 	struct mem_cgroup *memcg;
 	struct lruvec *lruvec;
 
-	lockdep_assert_irqs_disabled();
-
 	rcu_read_lock();
 	memcg = obj_cgroup_memcg(objcg);
 	lruvec = mem_cgroup_lruvec(memcg, pgdat);
maintainer
#8 lore raw
Quoted 20 lines · Vlastimil Babka (SUSE)
Quoted 19 lines · Shakeel Butt
Quoted 17 lines · Sebastian Andrzej Siewior

The assert was introduced in the commit cited below as an insurance that the semantic is the same after the local_irq_save() has been removed and the function has been made static.

The original requirement to disable interrupt was due the modification of per-CPU counters which require interrupts to be disabled because the counter update operation is not atomic and some of the counters are updated from interrupt context.

All callers of __mod_objcg_mlstate() acquire a lock (memcg_stock.stock_lock) which disables interrupts on !PREEMPT_RT and the lockdep assert is satisfied. On PREEMPT_RT the interrupts are not disabled and the assert triggers.

The safety of the counter update is already ensured by VM_WARN_ON_IRQS_ENABLED() which is part of __mod_memcg_lruvec_state() and does not require yet another check.

Quoted 7 lines
Quoted 4 lines

One question on VM_WARN_ON_IRQS_ENABLED() in __mod_memcg_lruvec_state(). On a PREEMPT_RT kernel with CONFIG_DEBUG_VM, will that VM_WARN_ON_IRQS_ENABLED() cause a splat or VM_WARN_ON_IRQS_ENABLED is special on PREEMPT_RT kernels?

It only does something with CONFIG_DEBUG_VM_IRQSOFF and that's disabled by dependencies on PREEMPT_RT :)

Thanks for the explanation.

#9 lore raw
In reply to Shakeel Butt
Quoted 4 lines · Shakeel Butt

One question on VM_WARN_ON_IRQS_ENABLED() in __mod_memcg_lruvec_state(). On a PREEMPT_RT kernel with CONFIG_DEBUG_VM, will that VM_WARN_ON_IRQS_ENABLED() cause a splat or VM_WARN_ON_IRQS_ENABLED is special on PREEMPT_RT kernels?

we have the following in the header file:

| #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

and this in Kconfig:

| config DEBUG_VM_IRQSOFF
|         def_bool DEBUG_VM && !PREEMPT_RT
|

which means on PREEMPT_RT we end up with "do {…"

Sebastian

maintainer
#10 lore raw
Quoted 14 lines · Sebastian Andrzej Siewior
Quoted 4 lines · Shakeel Butt

One question on VM_WARN_ON_IRQS_ENABLED() in __mod_memcg_lruvec_state(). On a PREEMPT_RT kernel with CONFIG_DEBUG_VM, will that VM_WARN_ON_IRQS_ENABLED() cause a splat or VM_WARN_ON_IRQS_ENABLED is special on PREEMPT_RT kernels?

we have the following in the header file:

| #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
Quoted 6 lines

and this in Kconfig:

| config DEBUG_VM_IRQSOFF
|         def_bool DEBUG_VM && !PREEMPT_RT
|

which means on PREEMPT_RT we end up with "do {…"

Thanks for the explanation.

maintainer Acked-by on v2 1/1
#11 lore raw
In reply to Sebastian Andrzej Siewior
Quoted 18 lines · Sebastian Andrzej Siewior

The assert was introduced in the commit cited below as an insurance that the semantic is the same after the local_irq_save() has been removed and the function has been made static.

The original requirement to disable interrupt was due the modification of per-CPU counters which require interrupts to be disabled because the counter update operation is not atomic and some of the counters are updated from interrupt context.

All callers of __mod_objcg_mlstate() acquire a lock (memcg_stock.stock_lock) which disables interrupts on !PREEMPT_RT and the lockdep assert is satisfied. On PREEMPT_RT the interrupts are not disabled and the assert triggers.

The safety of the counter update is already ensured by VM_WARN_ON_IRQS_ENABLED() which is part of __mod_memcg_lruvec_state() and does not require yet another check.

Quoted 5 lines

Remove the lockdep assert from __mod_objcg_mlstate().

Fixes 91882c1617c15 ("memcg: simple cleanup of stats update functions")
Acked-by on v2 1/1
#12 lore raw
In reply to Sebastian Andrzej Siewior
Quoted 18 lines · Sebastian Andrzej Siewior

The assert was introduced in the commit cited below as an insurance that the semantic is the same after the local_irq_save() has been removed and the function has been made static.

The original requirement to disable interrupt was due the modification of per-CPU counters which require interrupts to be disabled because the counter update operation is not atomic and some of the counters are updated from interrupt context.

All callers of __mod_objcg_mlstate() acquire a lock (memcg_stock.stock_lock) which disables interrupts on !PREEMPT_RT and the lockdep assert is satisfied. On PREEMPT_RT the interrupts are not disabled and the assert triggers.

The safety of the counter update is already ensured by VM_WARN_ON_IRQS_ENABLED() which is part of __mod_memcg_lruvec_state() and does not require yet another check.

Quoted 5 lines

Remove the lockdep assert from __mod_objcg_mlstate().

Fixes 91882c1617c15 ("memcg: simple cleanup of stats update functions")
Signature · 2 lines
Michal Hocko
SUSE Labs