[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABdmKX1LyubDhin5B_PxOrxHKyEsanZnW3yfd7+OyJG6am5ucg@mail.gmail.com>
Date: Fri, 26 Jul 2024 09:46:47 -0700
From: "T.J. Mercier" <tjmercier@...gle.com>
To: Shakeel Butt <shakeel.butt@...ux.dev>
Cc: Andrew Morton <akpm@...ux-foundation.org>, Johannes Weiner <hannes@...xchg.org>,
Michal Hocko <mhocko@...nel.org>, Roman Gushchin <roman.gushchin@...ux.dev>,
Muchun Song <muchun.song@...ux.dev>, Greg Thelen <gthelen@...gle.com>,
Facebook Kernel Team <kernel-team@...a.com>, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH] memcg: expose children memory usage for root
On Fri, Jul 26, 2024 at 8:47 AM Shakeel Butt <shakeel.butt@...ux.dev> wrote:
>
> Hi T.J.
>
> On Thu, Jul 25, 2024 at 04:12:12PM GMT, T.J. Mercier wrote:
> > On Mon, Jul 22, 2024 at 3:53 PM Shakeel Butt <shakeel.butt@...ux.dev> wrote:
> > >
> > > Linux kernel does not expose memory.current on the root memcg and there
> > > are applications which have to traverse all the top level memcgs to
> > > calculate the total memory charged in the system. This is more expensive
> > > (directory traversal and multiple open and reads) and is racy on a busy
> > > machine. As the kernel already have the needed information i.e. root's
> > > memory.current, why not expose that?
> > >
> > > However root's memory.current will have a different semantics than the
> > > non-root's memory.current as the kernel skips the charging for root, so
> > > maybe it is better to have a different named interface for the root.
> > > Something like memory.children_usage only for root memcg.
> > >
> > > Now there is still a question that why the kernel does not expose
> > > memory.current for the root. The historical reason was that the memcg
> > > charging was expensice and to provide the users to bypass the memcg
> > > charging by letting them run in the root. However do we still want to
> > > have this exception today? What is stopping us to start charging the
> > > root memcg as well. Of course the root will not have limits but the
> > > allocations will go through memcg charging and then the memory.current
> > > of root and non-root will have the same semantics.
> > >
> > > This is an RFC to start a discussion on memcg charging for root.
> >
> > Hi Shakeel,
> >
> > Since the root already has a page_counter I'm not opposed to this new
> > file as it doesn't increase the page_counter depth for children.
> > However I don't currently have any use-cases for it that wouldn't be
> > met by memory.stat in the root.
>
> I think difference would be getting a single number versus accumulating
> different fields in memory.stat to get that number (memory used by
> root's children) which might be a bit error prone.
Yeah that makes sense, I get how it'd be nicer to do just one read in
the root instead of digging into all the children. I just meant to say
that when looking at the root, currently I only care about a
particular stat (e.g. file_mapped) instead of the whole usage.
> > As far as charging, I've only ever seen kthreads and init in the root.
> > You have workloads that run there?
>
> No workloads in root. The charging is only to make the semanctics of
> root's memory.current same as its descendants.
>
> Thanks,
> Shakeel
Powered by blists - more mailing lists