All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Zefan Li <lizefan@huawei.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Vladimir Davydov <vdavydov.dev@gmail.com>,
	Cgroups <cgroups@vger.kernel.org>,
	linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] memcg: Fix memcg_kmem_bypass() for remote memcg charging
Date: Wed, 13 May 2020 11:05:02 +0200	[thread overview]
Message-ID: <20200513090502.GV29153@dhcp22.suse.cz> (raw)
In-Reply-To: <e6927a82-949c-bdfd-d717-0a14743c6759@huawei.com>

On Wed 13-05-20 15:28:28, Li Zefan wrote:
> While trying to use remote memcg charging in an out-of-tree kernel module
> I found it's not working, because the current thread is a workqueue thread.
> 
> Signed-off-by: Zefan Li <lizefan@huawei.com>
> ---
> 
> No need to queue this for v5.7 as currently no upstream users of this memcg
> feature suffer from this bug.
> 
> ---
>  mm/memcontrol.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index a3b97f1..db836fc 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2802,6 +2802,8 @@ static void memcg_schedule_kmem_cache_create(struct mem_cgroup *memcg,
>  
>  static inline bool memcg_kmem_bypass(void)
>  {
> +	if (unlikely(current->active_memcg))
> +		return false;

I am confused. Why the check below is insufficient? It checks for both mm
and PF_KTHREAD?

>  	if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD))
>  		return true;
>  	return false;
> -- 
> 2.7.4

-- 
Michal Hocko
SUSE Labs


WARNING: multiple messages have this Message-ID (diff)
From: Michal Hocko <mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Zefan Li <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>,
	Vladimir Davydov
	<vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Cgroups <cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
	Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Subject: Re: [PATCH] memcg: Fix memcg_kmem_bypass() for remote memcg charging
Date: Wed, 13 May 2020 11:05:02 +0200	[thread overview]
Message-ID: <20200513090502.GV29153@dhcp22.suse.cz> (raw)
In-Reply-To: <e6927a82-949c-bdfd-d717-0a14743c6759-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

On Wed 13-05-20 15:28:28, Li Zefan wrote:
> While trying to use remote memcg charging in an out-of-tree kernel module
> I found it's not working, because the current thread is a workqueue thread.
> 
> Signed-off-by: Zefan Li <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> ---
> 
> No need to queue this for v5.7 as currently no upstream users of this memcg
> feature suffer from this bug.
> 
> ---
>  mm/memcontrol.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index a3b97f1..db836fc 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2802,6 +2802,8 @@ static void memcg_schedule_kmem_cache_create(struct mem_cgroup *memcg,
>  
>  static inline bool memcg_kmem_bypass(void)
>  {
> +	if (unlikely(current->active_memcg))
> +		return false;

I am confused. Why the check below is insufficient? It checks for both mm
and PF_KTHREAD?

>  	if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD))
>  		return true;
>  	return false;
> -- 
> 2.7.4

-- 
Michal Hocko
SUSE Labs

  reply	other threads:[~2020-05-13  9:05 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13  7:28 [PATCH] memcg: Fix memcg_kmem_bypass() for remote memcg charging Zefan Li
2020-05-13  7:28 ` Zefan Li
2020-05-13  9:05 ` Michal Hocko [this message]
2020-05-13  9:05   ` Michal Hocko
2020-05-13 11:19   ` Zefan Li
2020-05-13 11:19     ` Zefan Li
2020-05-13 11:29     ` Michal Hocko
2020-05-13 11:29       ` Michal Hocko
2020-05-13 11:47       ` [PATCH v2] " Zefan Li
2020-05-13 11:47         ` Zefan Li
2020-05-13 12:22         ` Shakeel Butt
2020-05-13 12:22           ` Shakeel Butt
2020-05-13 13:05         ` Johannes Weiner
2020-05-13 13:05           ` Johannes Weiner
2020-05-13 16:11         ` Roman Gushchin
2020-05-13 16:11           ` Roman Gushchin
2020-05-14  1:16           ` Zefan Li
2020-05-14  1:16             ` Zefan Li
2020-05-14 22:52             ` Roman Gushchin
2020-05-14 22:52               ` Roman Gushchin
2020-05-15  6:56               ` Michal Hocko
2020-05-15  6:56                 ` Michal Hocko
2020-05-15  8:20                 ` Zefan Li
2020-05-15  8:20                   ` Zefan Li
2020-05-15  8:34                   ` Michal Hocko
2020-05-15  8:34                     ` Michal Hocko
2020-05-15 16:22                     ` Shakeel Butt
2020-05-15 16:22                       ` Shakeel Butt
2020-05-15 17:31                       ` Roman Gushchin
2020-05-15 17:31                         ` Roman Gushchin
2020-05-18  9:13                       ` Michal Hocko
2020-05-18  9:13                         ` Michal Hocko
2020-05-26  1:25       ` [PATCH v3] " Zefan Li
2020-05-26  1:25         ` Zefan Li
2020-05-26 15:53         ` Roman Gushchin
2020-05-26 15:53           ` Roman Gushchin
2020-05-27 16:50         ` Shakeel Butt
2020-05-27 16:50           ` Shakeel Butt
2020-05-28 14:44         ` Michal Hocko
2020-05-28 14:44           ` Michal Hocko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200513090502.GV29153@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-mm@kvack.org \
    --cc=lizefan@huawei.com \
    --cc=vdavydov.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.