diff mbox series

memcg: Remove the lockdep assert from __mod_objcg_mlstate().

Message ID 20240528121928.i-Gu7Jvg@linutronix.de (mailing list archive)
State New
Headers show
Series memcg: Remove the lockdep assert from __mod_objcg_mlstate(). | expand

Commit Message

Sebastian Andrzej Siewior May 28, 2024, 12:19 p.m. UTC
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")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 mm/memcontrol.c |    2 --
 1 file changed, 2 deletions(-)

Comments

Vlastimil Babka (SUSE) May 28, 2024, 12:34 p.m. UTC | #1
On 5/28/24 2:19 PM, Sebastian Andrzej Siewior wrote:
> 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.

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

> Remove the lockdep assert from __mod_objcg_mlstate().
> 
> Fixes: 91882c1617c15 ("memcg: simple cleanup of stats update functions")
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

mm-hotfixes as it's a rc1 regression

> ---
>  mm/memcontrol.c |    2 --
>  1 file changed, 2 deletions(-)
> 
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -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);
Sebastian Andrzej Siewior May 28, 2024, 1:40 p.m. UTC | #2
On 2024-05-28 14:34:55 [+0200], Vlastimil Babka (SUSE) wrote:
> > 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
Vlastimil Babka (SUSE) May 28, 2024, 1:44 p.m. UTC | #3
On 5/28/24 3:40 PM, Sebastian Andrzej Siewior wrote:
> On 2024-05-28 14:34:55 [+0200], Vlastimil Babka (SUSE) wrote:
>> > 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?

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?

> Sebastian
diff mbox series

Patch

--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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);