All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Shakeel Butt <shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: Zefan Li <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
	Roman Gushchin <guro-b10kYP2dOMg@public.gmane.org>,
	Johannes Weiner <hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org>,
	Vladimir Davydov
	<vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Cgroups <cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Linux MM <linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org>,
	Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Subject: Re: [PATCH v2] memcg: Fix memcg_kmem_bypass() for remote memcg charging
Date: Mon, 18 May 2020 11:13:38 +0200	[thread overview]
Message-ID: <20200518091338.GA32497@dhcp22.suse.cz> (raw)
In-Reply-To: <CALvZod64-Yc0firp9C8MNhEaF6FTiKmSx2B3HOrvi8GkyOD-7g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Fri 15-05-20 09:22:25, Shakeel Butt wrote:
> On Fri, May 15, 2020 at 1:35 AM Michal Hocko <mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> >
> > On Fri 15-05-20 16:20:04, Li Zefan wrote:
> > > On 2020/5/15 14:56, Michal Hocko wrote:
> > > > On Thu 14-05-20 15:52:59, Roman Gushchin wrote:
> > [...]
> > > >>> I thought the user should ensure not do this, but now I think it makes sense to just bypass
> > > >>> the interrupt case.
> > > >>
> > > >> I think now it's mostly a legacy of the opt-out kernel memory accounting.
> > > >> Actually we can relax this requirement by forcibly overcommit the memory cgroup
> > > >> if the allocation is happening from the irq context, and punish it afterwards.
> > > >> Idk how much we wanna this, hopefully nobody is allocating large non-temporarily
> > > >> objects from an irq.
> > > >
> > > > I do not think we want to pretend that remote charging from the IRQ
> > > > context is supported. Why don't we simply WARN_ON(in_interrupt()) there?
> > > >
> > >
> > > How about:
> > >
> > > static inline bool memcg_kmem_bypass(void)
> > > {
> > >         if (in_interrupt()) {
> > >                 WARN_ON(current->active_memcg);
> > >                 return true;
> > >         }
> >
> > Why not simply
> >
> >         if (WARN_ON_ONCE(in_interrupt())
> >                 return true;
> >
> > the idea is that we want to catch any __GFP_ACCOUNT user from IRQ
> > context because this just doesn't work and we do not plan to support it
> > for now and foreseeable future. If this is reduced only to active_memcg
> > then we are only getting a partial picture.
> >
> 
> There are SLAB_ACCOUNT kmem caches which do allocations in IRQ context
> (see sk_prot_alloc()), so, either we make charging work in IRQ or no
> warnings at all.

OK, I see. I wasn't aware that those caches are used from IRQ context.

-- 
Michal Hocko
SUSE Labs

WARNING: multiple messages have this Message-ID (diff)
From: Michal Hocko <mhocko@kernel.org>
To: Shakeel Butt <shakeelb@google.com>
Cc: Zefan Li <lizefan@huawei.com>, Roman Gushchin <guro@fb.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Vladimir Davydov <vdavydov.dev@gmail.com>,
	Cgroups <cgroups@vger.kernel.org>, Linux MM <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v2] memcg: Fix memcg_kmem_bypass() for remote memcg charging
Date: Mon, 18 May 2020 11:13:38 +0200	[thread overview]
Message-ID: <20200518091338.GA32497@dhcp22.suse.cz> (raw)
In-Reply-To: <CALvZod64-Yc0firp9C8MNhEaF6FTiKmSx2B3HOrvi8GkyOD-7g@mail.gmail.com>

On Fri 15-05-20 09:22:25, Shakeel Butt wrote:
> On Fri, May 15, 2020 at 1:35 AM Michal Hocko <mhocko@kernel.org> wrote:
> >
> > On Fri 15-05-20 16:20:04, Li Zefan wrote:
> > > On 2020/5/15 14:56, Michal Hocko wrote:
> > > > On Thu 14-05-20 15:52:59, Roman Gushchin wrote:
> > [...]
> > > >>> I thought the user should ensure not do this, but now I think it makes sense to just bypass
> > > >>> the interrupt case.
> > > >>
> > > >> I think now it's mostly a legacy of the opt-out kernel memory accounting.
> > > >> Actually we can relax this requirement by forcibly overcommit the memory cgroup
> > > >> if the allocation is happening from the irq context, and punish it afterwards.
> > > >> Idk how much we wanna this, hopefully nobody is allocating large non-temporarily
> > > >> objects from an irq.
> > > >
> > > > I do not think we want to pretend that remote charging from the IRQ
> > > > context is supported. Why don't we simply WARN_ON(in_interrupt()) there?
> > > >
> > >
> > > How about:
> > >
> > > static inline bool memcg_kmem_bypass(void)
> > > {
> > >         if (in_interrupt()) {
> > >                 WARN_ON(current->active_memcg);
> > >                 return true;
> > >         }
> >
> > Why not simply
> >
> >         if (WARN_ON_ONCE(in_interrupt())
> >                 return true;
> >
> > the idea is that we want to catch any __GFP_ACCOUNT user from IRQ
> > context because this just doesn't work and we do not plan to support it
> > for now and foreseeable future. If this is reduced only to active_memcg
> > then we are only getting a partial picture.
> >
> 
> There are SLAB_ACCOUNT kmem caches which do allocations in IRQ context
> (see sk_prot_alloc()), so, either we make charging work in IRQ or no
> warnings at all.

OK, I see. I wasn't aware that those caches are used from IRQ context.

-- 
Michal Hocko
SUSE Labs


  parent reply	other threads:[~2020-05-18  9:13 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
     [not found] ` <e6927a82-949c-bdfd-d717-0a14743c6759-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2020-05-13  9:05   ` Michal Hocko
2020-05-13  9:05     ` Michal Hocko
     [not found]     ` <20200513090502.GV29153-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2020-05-13 11:19       ` Zefan Li
2020-05-13 11:19         ` Zefan Li
     [not found]         ` <76f71776-d049-7407-8574-86b6e9d80704-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2020-05-13 11:29           ` Michal Hocko
2020-05-13 11:29             ` Michal Hocko
     [not found]             ` <20200513112905.GX29153-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2020-05-13 11:47               ` [PATCH v2] " Zefan Li
2020-05-13 11:47                 ` Zefan Li
     [not found]                 ` <3a721f62-5a66-8bc5-247b-5c8b7c51c555-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
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
     [not found]                     ` <20200513161110.GA70427-lLJQVQxiE4uLfgCeKHXN1g2O0Ztt9esIQQ4Iyu8u01E@public.gmane.org>
2020-05-14  1:16                       ` Zefan Li
2020-05-14  1:16                         ` Zefan Li
     [not found]                         ` <20e89344-cf00-8b0c-64c3-0ac7efd601e6-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2020-05-14 22:52                           ` Roman Gushchin
2020-05-14 22:52                             ` Roman Gushchin
     [not found]                             ` <20200514225259.GA81563-cx5fftMpWqeCjSd+JxjunQ2O0Ztt9esIQQ4Iyu8u01E@public.gmane.org>
2020-05-15  6:56                               ` Michal Hocko
2020-05-15  6:56                                 ` Michal Hocko
     [not found]                                 ` <20200515065645.GD29153-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2020-05-15  8:20                                   ` Zefan Li
2020-05-15  8:20                                     ` Zefan Li
     [not found]                                     ` <bad0e16b-7141-94c0-45f6-6ed03926b5f8-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2020-05-15  8:34                                       ` Michal Hocko
2020-05-15  8:34                                         ` Michal Hocko
     [not found]                                         ` <20200515083458.GK29153-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2020-05-15 16:22                                           ` Shakeel Butt
2020-05-15 16:22                                             ` Shakeel Butt
     [not found]                                             ` <CALvZod64-Yc0firp9C8MNhEaF6FTiKmSx2B3HOrvi8GkyOD-7g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-05-15 17:31                                               ` Roman Gushchin
2020-05-15 17:31                                                 ` Roman Gushchin
2020-05-18  9:13                                               ` Michal Hocko [this message]
2020-05-18  9:13                                                 ` Michal Hocko
2020-05-26  1:25               ` [PATCH v3] " Zefan Li
2020-05-26  1:25                 ` Zefan Li
     [not found]                 ` <1d202a12-26fe-0012-ea14-f025ddcd044a-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
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=20200518091338.GA32497@dhcp22.suse.cz \
    --to=mhocko-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=guro-b10kYP2dOMg@public.gmane.org \
    --cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    --cc=shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /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.