All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-09  8:03 ` Vasily Averin
  0 siblings, 0 replies; 24+ messages in thread
From: Vasily Averin @ 2021-03-09  8:03 UTC (permalink / raw)
  To: cgroups, linux-mm; +Cc: Johannes Weiner, Michal Hocko, Vladimir Davydov

in_interrupt() check in memcg_kmem_bypass() is incorrect because
it does not allow to account memory allocation called from task context
with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 845eec0..568f2cb 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1076,7 +1076,7 @@ static __always_inline bool memcg_kmem_bypass(void)
 		return false;
 
 	/* Memcg to charge can't be determined. */
-	if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD))
+	if (!in_task() || !current->mm || (current->flags & PF_KTHREAD))
 		return true;
 
 	return false;
-- 
1.8.3.1



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

* [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-09  8:03 ` Vasily Averin
  0 siblings, 0 replies; 24+ messages in thread
From: Vasily Averin @ 2021-03-09  8:03 UTC (permalink / raw)
  To: cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg
  Cc: Johannes Weiner, Michal Hocko, Vladimir Davydov

in_interrupt() check in memcg_kmem_bypass() is incorrect because
it does not allow to account memory allocation called from task context
with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections

Signed-off-by: Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 845eec0..568f2cb 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1076,7 +1076,7 @@ static __always_inline bool memcg_kmem_bypass(void)
 		return false;
 
 	/* Memcg to charge can't be determined. */
-	if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD))
+	if (!in_task() || !current->mm || (current->flags & PF_KTHREAD))
 		return true;
 
 	return false;
-- 
1.8.3.1


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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-09 14:57   ` Michal Hocko
  0 siblings, 0 replies; 24+ messages in thread
From: Michal Hocko @ 2021-03-09 14:57 UTC (permalink / raw)
  To: Vasily Averin; +Cc: cgroups, linux-mm, Johannes Weiner, Vladimir Davydov

On Tue 09-03-21 11:03:48, Vasily Averin wrote:
> in_interrupt() check in memcg_kmem_bypass() is incorrect because
> it does not allow to account memory allocation called from task context
> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections

Is there any existing user in the tree? Or is this more of a preparatory
patch for a later one which will need it? In other words, is this a bug
fix or a preparatory work.

> Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
> ---
>  mm/memcontrol.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 845eec0..568f2cb 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1076,7 +1076,7 @@ static __always_inline bool memcg_kmem_bypass(void)
>  		return false;
>  
>  	/* Memcg to charge can't be determined. */
> -	if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD))
> +	if (!in_task() || !current->mm || (current->flags & PF_KTHREAD))
>  		return true;
>  
>  	return false;
> -- 
> 1.8.3.1

-- 
Michal Hocko
SUSE Labs


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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-09 14:57   ` Michal Hocko
  0 siblings, 0 replies; 24+ messages in thread
From: Michal Hocko @ 2021-03-09 14:57 UTC (permalink / raw)
  To: Vasily Averin
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg,
	Johannes Weiner, Vladimir Davydov

On Tue 09-03-21 11:03:48, Vasily Averin wrote:
> in_interrupt() check in memcg_kmem_bypass() is incorrect because
> it does not allow to account memory allocation called from task context
> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections

Is there any existing user in the tree? Or is this more of a preparatory
patch for a later one which will need it? In other words, is this a bug
fix or a preparatory work.

> Signed-off-by: Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
> ---
>  mm/memcontrol.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 845eec0..568f2cb 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1076,7 +1076,7 @@ static __always_inline bool memcg_kmem_bypass(void)
>  		return false;
>  
>  	/* Memcg to charge can't be determined. */
> -	if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD))
> +	if (!in_task() || !current->mm || (current->flags & PF_KTHREAD))
>  		return true;
>  
>  	return false;
> -- 
> 1.8.3.1

-- 
Michal Hocko
SUSE Labs

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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-09 19:39   ` Shakeel Butt
  0 siblings, 0 replies; 24+ messages in thread
From: Shakeel Butt @ 2021-03-09 19:39 UTC (permalink / raw)
  To: Vasily Averin
  Cc: Cgroups, Linux MM, Johannes Weiner, Michal Hocko, Vladimir Davydov

On Tue, Mar 9, 2021 at 12:04 AM Vasily Averin <vvs@virtuozzo.com> wrote:
>
> in_interrupt() check in memcg_kmem_bypass() is incorrect because
> it does not allow to account memory allocation called from task context
> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
>
> Signed-off-by: Vasily Averin <vvs@virtuozzo.com>

In that file in_interrupt() is used at other places too. Should we
change those too?

> ---
>  mm/memcontrol.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 845eec0..568f2cb 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1076,7 +1076,7 @@ static __always_inline bool memcg_kmem_bypass(void)
>                 return false;
>
>         /* Memcg to charge can't be determined. */
> -       if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD))
> +       if (!in_task() || !current->mm || (current->flags & PF_KTHREAD))
>                 return true;
>
>         return false;
> --
> 1.8.3.1
>


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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-09 19:39   ` Shakeel Butt
  0 siblings, 0 replies; 24+ messages in thread
From: Shakeel Butt @ 2021-03-09 19:39 UTC (permalink / raw)
  To: Vasily Averin
  Cc: Cgroups, Linux MM, Johannes Weiner, Michal Hocko, Vladimir Davydov

On Tue, Mar 9, 2021 at 12:04 AM Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org> wrote:
>
> in_interrupt() check in memcg_kmem_bypass() is incorrect because
> it does not allow to account memory allocation called from task context
> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
>
> Signed-off-by: Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>

In that file in_interrupt() is used at other places too. Should we
change those too?

> ---
>  mm/memcontrol.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 845eec0..568f2cb 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1076,7 +1076,7 @@ static __always_inline bool memcg_kmem_bypass(void)
>                 return false;
>
>         /* Memcg to charge can't be determined. */
> -       if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD))
> +       if (!in_task() || !current->mm || (current->flags & PF_KTHREAD))
>                 return true;
>
>         return false;
> --
> 1.8.3.1
>

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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-09 20:18     ` Roman Gushchin
  0 siblings, 0 replies; 24+ messages in thread
From: Roman Gushchin @ 2021-03-09 20:18 UTC (permalink / raw)
  To: Shakeel Butt
  Cc: Vasily Averin, Cgroups, Linux MM, Johannes Weiner, Michal Hocko,
	Vladimir Davydov

On Tue, Mar 09, 2021 at 11:39:41AM -0800, Shakeel Butt wrote:
> On Tue, Mar 9, 2021 at 12:04 AM Vasily Averin <vvs@virtuozzo.com> wrote:
> >
> > in_interrupt() check in memcg_kmem_bypass() is incorrect because
> > it does not allow to account memory allocation called from task context
> > with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
> >
> > Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
> 
> In that file in_interrupt() is used at other places too. Should we
> change those too?

Yes, it seems so. Let me prepare a fix (it seems like most of them were
introduced by me).

Thanks!


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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-09 20:18     ` Roman Gushchin
  0 siblings, 0 replies; 24+ messages in thread
From: Roman Gushchin @ 2021-03-09 20:18 UTC (permalink / raw)
  To: Shakeel Butt
  Cc: Vasily Averin, Cgroups, Linux MM, Johannes Weiner, Michal Hocko,
	Vladimir Davydov

On Tue, Mar 09, 2021 at 11:39:41AM -0800, Shakeel Butt wrote:
> On Tue, Mar 9, 2021 at 12:04 AM Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org> wrote:
> >
> > in_interrupt() check in memcg_kmem_bypass() is incorrect because
> > it does not allow to account memory allocation called from task context
> > with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
> >
> > Signed-off-by: Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
> 
> In that file in_interrupt() is used at other places too. Should we
> change those too?

Yes, it seems so. Let me prepare a fix (it seems like most of them were
introduced by me).

Thanks!

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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-09 20:39   ` Roman Gushchin
  0 siblings, 0 replies; 24+ messages in thread
From: Roman Gushchin @ 2021-03-09 20:39 UTC (permalink / raw)
  To: Vasily Averin
  Cc: cgroups, linux-mm, Johannes Weiner, Michal Hocko, Vladimir Davydov

On Tue, Mar 09, 2021 at 11:03:48AM +0300, Vasily Averin wrote:
> in_interrupt() check in memcg_kmem_bypass() is incorrect because
> it does not allow to account memory allocation called from task context
> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
> 
> Signed-off-by: Vasily Averin <vvs@virtuozzo.com>

Good catch!

It looks like the bug was there for years: in_interrupt() was there since
the commit 7ae1e1d0f8ac ("memcg: kmem controller infrastructure") from 2012!
So I guess there is no point for a stable fix, but it's definitely nice to
have it fixed.

Acked-by: Roman Gushchin <guro@fb.com>

for this patch and the rest of the series.

Thank you!

> ---
>  mm/memcontrol.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 845eec0..568f2cb 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1076,7 +1076,7 @@ static __always_inline bool memcg_kmem_bypass(void)
>  		return false;
>  
>  	/* Memcg to charge can't be determined. */
> -	if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD))
> +	if (!in_task() || !current->mm || (current->flags & PF_KTHREAD))
>  		return true;
>  
>  	return false;
> -- 
> 1.8.3.1
> 


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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-09 20:39   ` Roman Gushchin
  0 siblings, 0 replies; 24+ messages in thread
From: Roman Gushchin @ 2021-03-09 20:39 UTC (permalink / raw)
  To: Vasily Averin
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg,
	Johannes Weiner, Michal Hocko, Vladimir Davydov

On Tue, Mar 09, 2021 at 11:03:48AM +0300, Vasily Averin wrote:
> in_interrupt() check in memcg_kmem_bypass() is incorrect because
> it does not allow to account memory allocation called from task context
> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
> 
> Signed-off-by: Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>

Good catch!

It looks like the bug was there for years: in_interrupt() was there since
the commit 7ae1e1d0f8ac ("memcg: kmem controller infrastructure") from 2012!
So I guess there is no point for a stable fix, but it's definitely nice to
have it fixed.

Acked-by: Roman Gushchin <guro-b10kYP2dOMg@public.gmane.org>

for this patch and the rest of the series.

Thank you!

> ---
>  mm/memcontrol.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 845eec0..568f2cb 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1076,7 +1076,7 @@ static __always_inline bool memcg_kmem_bypass(void)
>  		return false;
>  
>  	/* Memcg to charge can't be determined. */
> -	if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD))
> +	if (!in_task() || !current->mm || (current->flags & PF_KTHREAD))
>  		return true;
>  
>  	return false;
> -- 
> 1.8.3.1
> 

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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10  9:11     ` Vasily Averin
  0 siblings, 0 replies; 24+ messages in thread
From: Vasily Averin @ 2021-03-10  9:11 UTC (permalink / raw)
  To: Michal Hocko; +Cc: cgroups, linux-mm, Johannes Weiner, Vladimir Davydov

On 3/9/21 5:57 PM, Michal Hocko wrote:
> On Tue 09-03-21 11:03:48, Vasily Averin wrote:
>> in_interrupt() check in memcg_kmem_bypass() is incorrect because
>> it does not allow to account memory allocation called from task context
>> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
> 
> Is there any existing user in the tree? Or is this more of a preparatory
> patch for a later one which will need it? In other words, is this a bug
> fix or a preparatory work.

struct fib6_node objects are allocated by this way
net/ipv6/route.c::__ip6_ins_rt()
...        write_lock_bh(&table->tb6_lock);
        err = fib6_add(&table->tb6_root, rt, info, mxc);
        write_unlock_bh(&table->tb6_lock);

I spend some time to understand why properly entries from properly configured cache
was not accounted to container's memcg.

Thank you,
	Vasily Averin


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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10  9:11     ` Vasily Averin
  0 siblings, 0 replies; 24+ messages in thread
From: Vasily Averin @ 2021-03-10  9:11 UTC (permalink / raw)
  To: Michal Hocko
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg,
	Johannes Weiner, Vladimir Davydov

On 3/9/21 5:57 PM, Michal Hocko wrote:
> On Tue 09-03-21 11:03:48, Vasily Averin wrote:
>> in_interrupt() check in memcg_kmem_bypass() is incorrect because
>> it does not allow to account memory allocation called from task context
>> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
> 
> Is there any existing user in the tree? Or is this more of a preparatory
> patch for a later one which will need it? In other words, is this a bug
> fix or a preparatory work.

struct fib6_node objects are allocated by this way
net/ipv6/route.c::__ip6_ins_rt()
...        write_lock_bh(&table->tb6_lock);
        err = fib6_add(&table->tb6_root, rt, info, mxc);
        write_unlock_bh(&table->tb6_lock);

I spend some time to understand why properly entries from properly configured cache
was not accounted to container's memcg.

Thank you,
	Vasily Averin

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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10  9:17     ` Vasily Averin
  0 siblings, 0 replies; 24+ messages in thread
From: Vasily Averin @ 2021-03-10  9:17 UTC (permalink / raw)
  To: Shakeel Butt
  Cc: Cgroups, Linux MM, Johannes Weiner, Michal Hocko, Vladimir Davydov

On 3/9/21 10:39 PM, Shakeel Butt wrote:
> On Tue, Mar 9, 2021 at 12:04 AM Vasily Averin <vvs@virtuozzo.com> wrote:
>>
>> in_interrupt() check in memcg_kmem_bypass() is incorrect because
>> it does not allow to account memory allocation called from task context
>> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
>>
>> Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
> 
> In that file in_interrupt() is used at other places too. Should we
> change those too?

Yes, you're right, in_interrupt() is used incorrectly in other places too,
but 
1) these cases are not so critical as this one,
2) and are not related to current patch set

They can be replaced later without urgency
(unless I missed something imporant).

thank you,
	Vasily Averin

>> ---
>>  mm/memcontrol.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>> index 845eec0..568f2cb 100644
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -1076,7 +1076,7 @@ static __always_inline bool memcg_kmem_bypass(void)
>>                 return false;
>>
>>         /* Memcg to charge can't be determined. */
>> -       if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD))
>> +       if (!in_task() || !current->mm || (current->flags & PF_KTHREAD))
>>                 return true;
>>
>>         return false;
>> --
>> 1.8.3.1
>>



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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10  9:17     ` Vasily Averin
  0 siblings, 0 replies; 24+ messages in thread
From: Vasily Averin @ 2021-03-10  9:17 UTC (permalink / raw)
  To: Shakeel Butt
  Cc: Cgroups, Linux MM, Johannes Weiner, Michal Hocko, Vladimir Davydov

On 3/9/21 10:39 PM, Shakeel Butt wrote:
> On Tue, Mar 9, 2021 at 12:04 AM Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org> wrote:
>>
>> in_interrupt() check in memcg_kmem_bypass() is incorrect because
>> it does not allow to account memory allocation called from task context
>> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
>>
>> Signed-off-by: Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
> 
> In that file in_interrupt() is used at other places too. Should we
> change those too?

Yes, you're right, in_interrupt() is used incorrectly in other places too,
but 
1) these cases are not so critical as this one,
2) and are not related to current patch set

They can be replaced later without urgency
(unless I missed something imporant).

thank you,
	Vasily Averin

>> ---
>>  mm/memcontrol.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>> index 845eec0..568f2cb 100644
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -1076,7 +1076,7 @@ static __always_inline bool memcg_kmem_bypass(void)
>>                 return false;
>>
>>         /* Memcg to charge can't be determined. */
>> -       if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD))
>> +       if (!in_task() || !current->mm || (current->flags & PF_KTHREAD))
>>                 return true;
>>
>>         return false;
>> --
>> 1.8.3.1
>>


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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10  9:21       ` Vasily Averin
  0 siblings, 0 replies; 24+ messages in thread
From: Vasily Averin @ 2021-03-10  9:21 UTC (permalink / raw)
  To: Roman Gushchin, Shakeel Butt
  Cc: Cgroups, Linux MM, Johannes Weiner, Michal Hocko, Vladimir Davydov

On 3/9/21 11:18 PM, Roman Gushchin wrote:
> On Tue, Mar 09, 2021 at 11:39:41AM -0800, Shakeel Butt wrote:
>> On Tue, Mar 9, 2021 at 12:04 AM Vasily Averin <vvs@virtuozzo.com> wrote:
>>>
>>> in_interrupt() check in memcg_kmem_bypass() is incorrect because
>>> it does not allow to account memory allocation called from task context
>>> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
>>>
>>> Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
>>
>> In that file in_interrupt() is used at other places too. Should we
>> change those too?
> 
> Yes, it seems so. Let me prepare a fix (it seems like most of them were
> introduced by me).

No objects from my side, just keep me informed and add me in "Reported-by:" in your patches. 

Thank you,
	Vasily Averin


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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10  9:21       ` Vasily Averin
  0 siblings, 0 replies; 24+ messages in thread
From: Vasily Averin @ 2021-03-10  9:21 UTC (permalink / raw)
  To: Roman Gushchin, Shakeel Butt
  Cc: Cgroups, Linux MM, Johannes Weiner, Michal Hocko, Vladimir Davydov

On 3/9/21 11:18 PM, Roman Gushchin wrote:
> On Tue, Mar 09, 2021 at 11:39:41AM -0800, Shakeel Butt wrote:
>> On Tue, Mar 9, 2021 at 12:04 AM Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org> wrote:
>>>
>>> in_interrupt() check in memcg_kmem_bypass() is incorrect because
>>> it does not allow to account memory allocation called from task context
>>> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
>>>
>>> Signed-off-by: Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
>>
>> In that file in_interrupt() is used at other places too. Should we
>> change those too?
> 
> Yes, it seems so. Let me prepare a fix (it seems like most of them were
> introduced by me).

No objects from my side, just keep me informed and add me in "Reported-by:" in your patches. 

Thank you,
	Vasily Averin

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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10  9:26     ` Vasily Averin
  0 siblings, 0 replies; 24+ messages in thread
From: Vasily Averin @ 2021-03-10  9:26 UTC (permalink / raw)
  To: Roman Gushchin
  Cc: cgroups, linux-mm, Johannes Weiner, Michal Hocko, Vladimir Davydov

On 3/9/21 11:39 PM, Roman Gushchin wrote:
> On Tue, Mar 09, 2021 at 11:03:48AM +0300, Vasily Averin wrote:
>> in_interrupt() check in memcg_kmem_bypass() is incorrect because
>> it does not allow to account memory allocation called from task context
>> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
>>
>> Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
> 
> Good catch!
> 
> It looks like the bug was there for years: in_interrupt() was there since
> the commit 7ae1e1d0f8ac ("memcg: kmem controller infrastructure") from 2012!
> So I guess there is no point for a stable fix, but it's definitely nice to
> have it fixed.

I did not noticed that this problem affect existing allocation,
I just found that it blocked accounting of "struct fib6_node" in __ip6_ins_rt() 
added in my current patch set. So I do not think it should went to stable@.

Thank you,
	Vasily Averin


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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10  9:26     ` Vasily Averin
  0 siblings, 0 replies; 24+ messages in thread
From: Vasily Averin @ 2021-03-10  9:26 UTC (permalink / raw)
  To: Roman Gushchin
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg,
	Johannes Weiner, Michal Hocko, Vladimir Davydov

On 3/9/21 11:39 PM, Roman Gushchin wrote:
> On Tue, Mar 09, 2021 at 11:03:48AM +0300, Vasily Averin wrote:
>> in_interrupt() check in memcg_kmem_bypass() is incorrect because
>> it does not allow to account memory allocation called from task context
>> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
>>
>> Signed-off-by: Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
> 
> Good catch!
> 
> It looks like the bug was there for years: in_interrupt() was there since
> the commit 7ae1e1d0f8ac ("memcg: kmem controller infrastructure") from 2012!
> So I guess there is no point for a stable fix, but it's definitely nice to
> have it fixed.

I did not noticed that this problem affect existing allocation,
I just found that it blocked accounting of "struct fib6_node" in __ip6_ins_rt() 
added in my current patch set. So I do not think it should went to stable@.

Thank you,
	Vasily Averin

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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10  9:40       ` Michal Hocko
  0 siblings, 0 replies; 24+ messages in thread
From: Michal Hocko @ 2021-03-10  9:40 UTC (permalink / raw)
  To: Vasily Averin; +Cc: cgroups, linux-mm, Johannes Weiner, Vladimir Davydov

On Wed 10-03-21 12:11:26, Vasily Averin wrote:
> On 3/9/21 5:57 PM, Michal Hocko wrote:
> > On Tue 09-03-21 11:03:48, Vasily Averin wrote:
> >> in_interrupt() check in memcg_kmem_bypass() is incorrect because
> >> it does not allow to account memory allocation called from task context
> >> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
> > 
> > Is there any existing user in the tree? Or is this more of a preparatory
> > patch for a later one which will need it? In other words, is this a bug
> > fix or a preparatory work.
> 
> struct fib6_node objects are allocated by this way
> net/ipv6/route.c::__ip6_ins_rt()
> ...        write_lock_bh(&table->tb6_lock);
>         err = fib6_add(&table->tb6_root, rt, info, mxc);
>         write_unlock_bh(&table->tb6_lock);
> 
> I spend some time to understand why properly entries from properly configured cache
> was not accounted to container's memcg.

OK, that is a valuable information. If there are no other users
currently then I would recommend squashing this patch into the one which
introduces accounting for fib6_node cache (patch 2, IIUC).
-- 
Michal Hocko
SUSE Labs


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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10  9:40       ` Michal Hocko
  0 siblings, 0 replies; 24+ messages in thread
From: Michal Hocko @ 2021-03-10  9:40 UTC (permalink / raw)
  To: Vasily Averin
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg,
	Johannes Weiner, Vladimir Davydov

On Wed 10-03-21 12:11:26, Vasily Averin wrote:
> On 3/9/21 5:57 PM, Michal Hocko wrote:
> > On Tue 09-03-21 11:03:48, Vasily Averin wrote:
> >> in_interrupt() check in memcg_kmem_bypass() is incorrect because
> >> it does not allow to account memory allocation called from task context
> >> with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
> > 
> > Is there any existing user in the tree? Or is this more of a preparatory
> > patch for a later one which will need it? In other words, is this a bug
> > fix or a preparatory work.
> 
> struct fib6_node objects are allocated by this way
> net/ipv6/route.c::__ip6_ins_rt()
> ...        write_lock_bh(&table->tb6_lock);
>         err = fib6_add(&table->tb6_root, rt, info, mxc);
>         write_unlock_bh(&table->tb6_lock);
> 
> I spend some time to understand why properly entries from properly configured cache
> was not accounted to container's memcg.

OK, that is a valuable information. If there are no other users
currently then I would recommend squashing this patch into the one which
introduces accounting for fib6_node cache (patch 2, IIUC).
-- 
Michal Hocko
SUSE Labs

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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10  9:42       ` Michal Hocko
  0 siblings, 0 replies; 24+ messages in thread
From: Michal Hocko @ 2021-03-10  9:42 UTC (permalink / raw)
  To: Roman Gushchin
  Cc: Shakeel Butt, Vasily Averin, Cgroups, Linux MM, Johannes Weiner,
	Vladimir Davydov

On Tue 09-03-21 12:18:28, Roman Gushchin wrote:
> On Tue, Mar 09, 2021 at 11:39:41AM -0800, Shakeel Butt wrote:
> > On Tue, Mar 9, 2021 at 12:04 AM Vasily Averin <vvs@virtuozzo.com> wrote:
> > >
> > > in_interrupt() check in memcg_kmem_bypass() is incorrect because
> > > it does not allow to account memory allocation called from task context
> > > with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
> > >
> > > Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
> > 
> > In that file in_interrupt() is used at other places too. Should we
> > change those too?
> 
> Yes, it seems so. Let me prepare a fix (it seems like most of them were
> introduced by me).

Does this affect any existing in-tree users?
-- 
Michal Hocko
SUSE Labs


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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10  9:42       ` Michal Hocko
  0 siblings, 0 replies; 24+ messages in thread
From: Michal Hocko @ 2021-03-10  9:42 UTC (permalink / raw)
  To: Roman Gushchin
  Cc: Shakeel Butt, Vasily Averin, Cgroups, Linux MM, Johannes Weiner,
	Vladimir Davydov

On Tue 09-03-21 12:18:28, Roman Gushchin wrote:
> On Tue, Mar 09, 2021 at 11:39:41AM -0800, Shakeel Butt wrote:
> > On Tue, Mar 9, 2021 at 12:04 AM Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org> wrote:
> > >
> > > in_interrupt() check in memcg_kmem_bypass() is incorrect because
> > > it does not allow to account memory allocation called from task context
> > > with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
> > >
> > > Signed-off-by: Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
> > 
> > In that file in_interrupt() is used at other places too. Should we
> > change those too?
> 
> Yes, it seems so. Let me prepare a fix (it seems like most of them were
> introduced by me).

Does this affect any existing in-tree users?
-- 
Michal Hocko
SUSE Labs

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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10 19:09         ` Roman Gushchin
  0 siblings, 0 replies; 24+ messages in thread
From: Roman Gushchin @ 2021-03-10 19:09 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Shakeel Butt, Vasily Averin, Cgroups, Linux MM, Johannes Weiner,
	Vladimir Davydov

On Wed, Mar 10, 2021 at 10:42:29AM +0100, Michal Hocko wrote:
> On Tue 09-03-21 12:18:28, Roman Gushchin wrote:
> > On Tue, Mar 09, 2021 at 11:39:41AM -0800, Shakeel Butt wrote:
> > > On Tue, Mar 9, 2021 at 12:04 AM Vasily Averin <vvs@virtuozzo.com> wrote:
> > > >
> > > > in_interrupt() check in memcg_kmem_bypass() is incorrect because
> > > > it does not allow to account memory allocation called from task context
> > > > with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
> > > >
> > > > Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
> > > 
> > > In that file in_interrupt() is used at other places too. Should we
> > > change those too?
> > 
> > Yes, it seems so. Let me prepare a fix (it seems like most of them were
> > introduced by me).
> 
> Does this affect any existing in-tree users?

I'll double check this, but I doubt. We should fix it anyway, but I don't think
we need any stable backports.


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

* Re: [PATCH 1/9] memcg: accounting for allocations called with disabled BH
@ 2021-03-10 19:09         ` Roman Gushchin
  0 siblings, 0 replies; 24+ messages in thread
From: Roman Gushchin @ 2021-03-10 19:09 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Shakeel Butt, Vasily Averin, Cgroups, Linux MM, Johannes Weiner,
	Vladimir Davydov

On Wed, Mar 10, 2021 at 10:42:29AM +0100, Michal Hocko wrote:
> On Tue 09-03-21 12:18:28, Roman Gushchin wrote:
> > On Tue, Mar 09, 2021 at 11:39:41AM -0800, Shakeel Butt wrote:
> > > On Tue, Mar 9, 2021 at 12:04 AM Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org> wrote:
> > > >
> > > > in_interrupt() check in memcg_kmem_bypass() is incorrect because
> > > > it does not allow to account memory allocation called from task context
> > > > with disabled BH, i.e. inside spin_lock_bh()/spin_unlock_bh() sections
> > > >
> > > > Signed-off-by: Vasily Averin <vvs-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
> > > 
> > > In that file in_interrupt() is used at other places too. Should we
> > > change those too?
> > 
> > Yes, it seems so. Let me prepare a fix (it seems like most of them were
> > introduced by me).
> 
> Does this affect any existing in-tree users?

I'll double check this, but I doubt. We should fix it anyway, but I don't think
we need any stable backports.

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

end of thread, other threads:[~2021-03-10 19:09 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09  8:03 [PATCH 1/9] memcg: accounting for allocations called with disabled BH Vasily Averin
2021-03-09  8:03 ` Vasily Averin
2021-03-09 14:57 ` Michal Hocko
2021-03-09 14:57   ` Michal Hocko
2021-03-10  9:11   ` Vasily Averin
2021-03-10  9:11     ` Vasily Averin
2021-03-10  9:40     ` Michal Hocko
2021-03-10  9:40       ` Michal Hocko
2021-03-09 19:39 ` Shakeel Butt
2021-03-09 19:39   ` Shakeel Butt
2021-03-09 20:18   ` Roman Gushchin
2021-03-09 20:18     ` Roman Gushchin
2021-03-10  9:21     ` Vasily Averin
2021-03-10  9:21       ` Vasily Averin
2021-03-10  9:42     ` Michal Hocko
2021-03-10  9:42       ` Michal Hocko
2021-03-10 19:09       ` Roman Gushchin
2021-03-10 19:09         ` Roman Gushchin
2021-03-10  9:17   ` Vasily Averin
2021-03-10  9:17     ` Vasily Averin
2021-03-09 20:39 ` Roman Gushchin
2021-03-09 20:39   ` Roman Gushchin
2021-03-10  9:26   ` Vasily Averin
2021-03-10  9:26     ` Vasily Averin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.