linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memcg: Remove the lockdep assert from __mod_objcg_mlstate().
@ 2024-05-28 12:19 Sebastian Andrzej Siewior
  2024-05-28 12:34 ` Vlastimil Babka (SUSE)
  0 siblings, 1 reply; 13+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-05-28 12:19 UTC (permalink / raw)
  To: Vlastimil Babka (SUSE)
  Cc: Shakeel Butt, Andrew Morton, Johannes Weiner, Michal Hocko,
	Roman Gushchin, Muchun Song, linux-mm, linux-kernel,
	Thomas Gleixner

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(-)

--- 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);


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] memcg: Remove the lockdep assert from __mod_objcg_mlstate().
  2024-05-28 12:19 [PATCH] memcg: Remove the lockdep assert from __mod_objcg_mlstate() Sebastian Andrzej Siewior
@ 2024-05-28 12:34 ` Vlastimil Babka (SUSE)
  2024-05-28 13:40   ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 13+ messages in thread
From: Vlastimil Babka (SUSE) @ 2024-05-28 12:34 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Shakeel Butt, Andrew Morton, Johannes Weiner, Michal Hocko,
	Roman Gushchin, Muchun Song, linux-mm, linux-kernel,
	Thomas Gleixner

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);



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] memcg: Remove the lockdep assert from __mod_objcg_mlstate().
  2024-05-28 12:34 ` Vlastimil Babka (SUSE)
@ 2024-05-28 13:40   ` Sebastian Andrzej Siewior
  2024-05-28 13:44     ` Vlastimil Babka (SUSE)
  0 siblings, 1 reply; 13+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-05-28 13:40 UTC (permalink / raw)
  To: Vlastimil Babka (SUSE)
  Cc: Shakeel Butt, Andrew Morton, Johannes Weiner, Michal Hocko,
	Roman Gushchin, Muchun Song, linux-mm, linux-kernel,
	Thomas Gleixner

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] memcg: Remove the lockdep assert from __mod_objcg_mlstate().
  2024-05-28 13:40   ` Sebastian Andrzej Siewior
@ 2024-05-28 13:44     ` Vlastimil Babka (SUSE)
  2024-05-28 14:13       ` [PATCH v2] " Sebastian Andrzej Siewior
  0 siblings, 1 reply; 13+ messages in thread
From: Vlastimil Babka (SUSE) @ 2024-05-28 13:44 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Shakeel Butt, Andrew Morton, Johannes Weiner, Michal Hocko,
	Roman Gushchin, Muchun Song, linux-mm, linux-kernel,
	Thomas Gleixner

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



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2] memcg: Remove the lockdep assert from __mod_objcg_mlstate().
  2024-05-28 13:44     ` Vlastimil Babka (SUSE)
@ 2024-05-28 14:13       ` Sebastian Andrzej Siewior
  2024-05-28 14:19         ` Vlastimil Babka (SUSE)
                           ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-05-28 14:13 UTC (permalink / raw)
  To: Vlastimil Babka (SUSE)
  Cc: Shakeel Butt, Andrew Morton, Johannes Weiner, Michal Hocko,
	Roman Gushchin, Muchun Song, linux-mm, linux-kernel,
	Thomas Gleixner

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")
Link: https://lore.kernel.org/r/20240528121928.i-Gu7Jvg@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
On 2024-05-28 15:44:51 [+0200], Vlastimil Babka (SUSE) wrote:
> 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(-)

--- 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);


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2] memcg: Remove the lockdep assert from __mod_objcg_mlstate().
  2024-05-28 14:13       ` [PATCH v2] " Sebastian Andrzej Siewior
@ 2024-05-28 14:19         ` Vlastimil Babka (SUSE)
  2024-05-28 14:59         ` Shakeel Butt
                           ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: Vlastimil Babka (SUSE) @ 2024-05-28 14:19 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Shakeel Butt, Andrew Morton, Johannes Weiner, Michal Hocko,
	Roman Gushchin, Muchun Song, linux-mm, linux-kernel,
	Thomas Gleixner

On 5/28/24 4:13 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 __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")
> Link: https://lore.kernel.org/r/20240528121928.i-Gu7Jvg@linutronix.de
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

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

mm-hotfixes as it's a rc1 regression

> ---
> On 2024-05-28 15:44:51 [+0200], Vlastimil Babka (SUSE) wrote:
>> 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(-)
> 
> --- 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);



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2] memcg: Remove the lockdep assert from __mod_objcg_mlstate().
  2024-05-28 14:13       ` [PATCH v2] " Sebastian Andrzej Siewior
  2024-05-28 14:19         ` Vlastimil Babka (SUSE)
@ 2024-05-28 14:59         ` Shakeel Butt
  2024-05-28 15:07           ` Vlastimil Babka (SUSE)
  2024-05-28 15:08           ` Sebastian Andrzej Siewior
  2024-05-28 16:21         ` Shakeel Butt
  2024-05-29  9:16         ` Michal Hocko
  3 siblings, 2 replies; 13+ messages in thread
From: Shakeel Butt @ 2024-05-28 14:59 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Vlastimil Babka (SUSE),
	Andrew Morton, Johannes Weiner, Michal Hocko, Roman Gushchin,
	Muchun Song, linux-mm, linux-kernel, Thomas Gleixner

On Tue, May 28, 2024 at 04:13:41PM GMT, 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 __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?

> 
> Remove the lockdep assert from __mod_objcg_mlstate().
> 
> Fixes: 91882c1617c15 ("memcg: simple cleanup of stats update functions")
> Link: https://lore.kernel.org/r/20240528121928.i-Gu7Jvg@linutronix.de
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> On 2024-05-28 15:44:51 [+0200], Vlastimil Babka (SUSE) wrote:
> > 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(-)
> 
> --- 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);


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2] memcg: Remove the lockdep assert from __mod_objcg_mlstate().
  2024-05-28 14:59         ` Shakeel Butt
@ 2024-05-28 15:07           ` Vlastimil Babka (SUSE)
  2024-05-28 16:21             ` Shakeel Butt
  2024-05-28 15:08           ` Sebastian Andrzej Siewior
  1 sibling, 1 reply; 13+ messages in thread
From: Vlastimil Babka (SUSE) @ 2024-05-28 15:07 UTC (permalink / raw)
  To: Shakeel Butt, Sebastian Andrzej Siewior
  Cc: Andrew Morton, Johannes Weiner, Michal Hocko, Roman Gushchin,
	Muchun Song, linux-mm, linux-kernel, Thomas Gleixner

On 5/28/24 4:59 PM, Shakeel Butt wrote:
> On Tue, May 28, 2024 at 04:13:41PM GMT, 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 __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 :)

>> 
>> Remove the lockdep assert from __mod_objcg_mlstate().
>> 
>> Fixes: 91882c1617c15 ("memcg: simple cleanup of stats update functions")
>> Link: https://lore.kernel.org/r/20240528121928.i-Gu7Jvg@linutronix.de
>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>> ---
>> On 2024-05-28 15:44:51 [+0200], Vlastimil Babka (SUSE) wrote:
>> > 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(-)
>> 
>> --- 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);



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2] memcg: Remove the lockdep assert from __mod_objcg_mlstate().
  2024-05-28 14:59         ` Shakeel Butt
  2024-05-28 15:07           ` Vlastimil Babka (SUSE)
@ 2024-05-28 15:08           ` Sebastian Andrzej Siewior
  2024-05-28 16:20             ` Shakeel Butt
  1 sibling, 1 reply; 13+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-05-28 15:08 UTC (permalink / raw)
  To: Shakeel Butt
  Cc: Vlastimil Babka (SUSE),
	Andrew Morton, Johannes Weiner, Michal Hocko, Roman Gushchin,
	Muchun Song, linux-mm, linux-kernel, Thomas Gleixner

On 2024-05-28 07:59:57 [-0700], Shakeel Butt wrote:
> 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2] memcg: Remove the lockdep assert from __mod_objcg_mlstate().
  2024-05-28 15:08           ` Sebastian Andrzej Siewior
@ 2024-05-28 16:20             ` Shakeel Butt
  0 siblings, 0 replies; 13+ messages in thread
From: Shakeel Butt @ 2024-05-28 16:20 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Vlastimil Babka (SUSE),
	Andrew Morton, Johannes Weiner, Michal Hocko, Roman Gushchin,
	Muchun Song, linux-mm, linux-kernel, Thomas Gleixner

On Tue, May 28, 2024 at 05:08:56PM GMT, Sebastian Andrzej Siewior wrote:
> On 2024-05-28 07:59:57 [-0700], Shakeel Butt wrote:
> > 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 {…"

Thanks for the explanation.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2] memcg: Remove the lockdep assert from __mod_objcg_mlstate().
  2024-05-28 15:07           ` Vlastimil Babka (SUSE)
@ 2024-05-28 16:21             ` Shakeel Butt
  0 siblings, 0 replies; 13+ messages in thread
From: Shakeel Butt @ 2024-05-28 16:21 UTC (permalink / raw)
  To: Vlastimil Babka (SUSE)
  Cc: Sebastian Andrzej Siewior, Andrew Morton, Johannes Weiner,
	Michal Hocko, Roman Gushchin, Muchun Song, linux-mm,
	linux-kernel, Thomas Gleixner

On Tue, May 28, 2024 at 05:07:06PM GMT, Vlastimil Babka (SUSE) wrote:
> On 5/28/24 4:59 PM, Shakeel Butt wrote:
> > On Tue, May 28, 2024 at 04:13:41PM GMT, 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 __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 :)

Thanks for the explanation.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2] memcg: Remove the lockdep assert from __mod_objcg_mlstate().
  2024-05-28 14:13       ` [PATCH v2] " Sebastian Andrzej Siewior
  2024-05-28 14:19         ` Vlastimil Babka (SUSE)
  2024-05-28 14:59         ` Shakeel Butt
@ 2024-05-28 16:21         ` Shakeel Butt
  2024-05-29  9:16         ` Michal Hocko
  3 siblings, 0 replies; 13+ messages in thread
From: Shakeel Butt @ 2024-05-28 16:21 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Vlastimil Babka (SUSE),
	Andrew Morton, Johannes Weiner, Michal Hocko, Roman Gushchin,
	Muchun Song, linux-mm, linux-kernel, Thomas Gleixner

On Tue, May 28, 2024 at 04:13:41PM GMT, 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 __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")
> Link: https://lore.kernel.org/r/20240528121928.i-Gu7Jvg@linutronix.de
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2] memcg: Remove the lockdep assert from __mod_objcg_mlstate().
  2024-05-28 14:13       ` [PATCH v2] " Sebastian Andrzej Siewior
                           ` (2 preceding siblings ...)
  2024-05-28 16:21         ` Shakeel Butt
@ 2024-05-29  9:16         ` Michal Hocko
  3 siblings, 0 replies; 13+ messages in thread
From: Michal Hocko @ 2024-05-29  9:16 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Vlastimil Babka (SUSE),
	Shakeel Butt, Andrew Morton, Johannes Weiner, Roman Gushchin,
	Muchun Song, linux-mm, linux-kernel, Thomas Gleixner

On Tue 28-05-24 16:13:41, 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 __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")
> Link: https://lore.kernel.org/r/20240528121928.i-Gu7Jvg@linutronix.de
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Acked-by: Michal Hocko <mhocko@suse.com>

-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-05-29  9:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-28 12:19 [PATCH] memcg: Remove the lockdep assert from __mod_objcg_mlstate() Sebastian Andrzej Siewior
2024-05-28 12:34 ` Vlastimil Babka (SUSE)
2024-05-28 13:40   ` Sebastian Andrzej Siewior
2024-05-28 13:44     ` Vlastimil Babka (SUSE)
2024-05-28 14:13       ` [PATCH v2] " Sebastian Andrzej Siewior
2024-05-28 14:19         ` Vlastimil Babka (SUSE)
2024-05-28 14:59         ` Shakeel Butt
2024-05-28 15:07           ` Vlastimil Babka (SUSE)
2024-05-28 16:21             ` Shakeel Butt
2024-05-28 15:08           ` Sebastian Andrzej Siewior
2024-05-28 16:20             ` Shakeel Butt
2024-05-28 16:21         ` Shakeel Butt
2024-05-29  9:16         ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox