mbox series

[0/2] memcg: add pagetable comsumption to memory.stat

Message ID 20201126005603.1293012-1-shakeelb@google.com (mailing list archive)
Headers show
Series memcg: add pagetable comsumption to memory.stat | expand

Message

Shakeel Butt Nov. 26, 2020, 12:56 a.m. UTC
Many workloads consumes significant amount of memory in pagetables. This
patch series exposes the pagetable comsumption for each memory cgroup.

Shakeel Butt (2):
  mm: move lruvec stats update functions to vmstat.h
  mm: memcontrol: account pagetables per node

 Documentation/admin-guide/cgroup-v2.rst |   3 +
 arch/nds32/mm/mm-nds32.c                |   6 +-
 drivers/base/node.c                     |   2 +-
 fs/proc/meminfo.c                       |   2 +-
 include/linux/memcontrol.h              | 112 ------------------------
 include/linux/mm.h                      |  11 ++-
 include/linux/mmzone.h                  |   2 +-
 include/linux/vmstat.h                  | 104 ++++++++++++++++++++++
 mm/memcontrol.c                         |  19 ++++
 mm/page_alloc.c                         |   6 +-
 10 files changed, 142 insertions(+), 125 deletions(-)

Comments

Roman Gushchin Nov. 30, 2020, 8:34 p.m. UTC | #1
On Wed, Nov 25, 2020 at 04:56:01PM -0800, Shakeel Butt wrote:
> Many workloads consumes significant amount of memory in pagetables. This
> patch series exposes the pagetable comsumption for each memory cgroup.

Hi Shakeel!

The code looks good to me. However I'm not sure I understand what's the
use case for the new statistics? Can you, please, elaborate a bit more here?

From a very first glance, the size of pagetables should be _roughly_ equal
to the size_of(pte)/PAGE_SIZE*(size of a cgroup) and should not exceed 1%
of the cgroup size. So for all but very large cgroups the value will be
in the noise of per-cpu counters. Perhaps I'm missing some important cases?

Thanks!

> 
> Shakeel Butt (2):
>   mm: move lruvec stats update functions to vmstat.h
>   mm: memcontrol: account pagetables per node
> 
>  Documentation/admin-guide/cgroup-v2.rst |   3 +
>  arch/nds32/mm/mm-nds32.c                |   6 +-
>  drivers/base/node.c                     |   2 +-
>  fs/proc/meminfo.c                       |   2 +-
>  include/linux/memcontrol.h              | 112 ------------------------
>  include/linux/mm.h                      |  11 ++-
>  include/linux/mmzone.h                  |   2 +-
>  include/linux/vmstat.h                  | 104 ++++++++++++++++++++++
>  mm/memcontrol.c                         |  19 ++++
>  mm/page_alloc.c                         |   6 +-
>  10 files changed, 142 insertions(+), 125 deletions(-)
> 
> -- 
> 2.29.2.454.gaff20da3a2-goog
>
Shakeel Butt Nov. 30, 2020, 9:01 p.m. UTC | #2
On Mon, Nov 30, 2020 at 12:34 PM Roman Gushchin <guro@fb.com> wrote:
>
> On Wed, Nov 25, 2020 at 04:56:01PM -0800, Shakeel Butt wrote:
> > Many workloads consumes significant amount of memory in pagetables. This
> > patch series exposes the pagetable comsumption for each memory cgroup.
>
> Hi Shakeel!
>
> The code looks good to me. However I'm not sure I understand what's the
> use case for the new statistics? Can you, please, elaborate a bit more here?
>
> From a very first glance, the size of pagetables should be _roughly_ equal
> to the size_of(pte)/PAGE_SIZE*(size of a cgroup) and should not exceed 1%
> of the cgroup size. So for all but very large cgroups the value will be
> in the noise of per-cpu counters. Perhaps I'm missing some important cases?
>

I think this is in general a good metric to have but one specific
use-case we have is the user space network driver which mmaps the
memory of the applications for zero copy data transfers. This driver
can consume a large amount of memory in page tables. So, this metric
becomes really useful here.

Shakeel
Roman Gushchin Nov. 30, 2020, 9:10 p.m. UTC | #3
On Mon, Nov 30, 2020 at 01:01:18PM -0800, Shakeel Butt wrote:
> On Mon, Nov 30, 2020 at 12:34 PM Roman Gushchin <guro@fb.com> wrote:
> >
> > On Wed, Nov 25, 2020 at 04:56:01PM -0800, Shakeel Butt wrote:
> > > Many workloads consumes significant amount of memory in pagetables. This
> > > patch series exposes the pagetable comsumption for each memory cgroup.
> >
> > Hi Shakeel!
> >
> > The code looks good to me. However I'm not sure I understand what's the
> > use case for the new statistics? Can you, please, elaborate a bit more here?
> >
> > From a very first glance, the size of pagetables should be _roughly_ equal
> > to the size_of(pte)/PAGE_SIZE*(size of a cgroup) and should not exceed 1%
> > of the cgroup size. So for all but very large cgroups the value will be
> > in the noise of per-cpu counters. Perhaps I'm missing some important cases?
> >
> 
> I think this is in general a good metric to have but one specific
> use-case we have is the user space network driver which mmaps the
> memory of the applications for zero copy data transfers. This driver
> can consume a large amount of memory in page tables. So, this metric
> becomes really useful here.

Got it, thank you for the explanation!
Would you mind to add this text to the cover letter as an example?

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

Thanks!
Shakeel Butt Nov. 30, 2020, 9:13 p.m. UTC | #4
On Mon, Nov 30, 2020 at 1:10 PM Roman Gushchin <guro@fb.com> wrote:
>
> On Mon, Nov 30, 2020 at 01:01:18PM -0800, Shakeel Butt wrote:
> > On Mon, Nov 30, 2020 at 12:34 PM Roman Gushchin <guro@fb.com> wrote:
> > >
> > > On Wed, Nov 25, 2020 at 04:56:01PM -0800, Shakeel Butt wrote:
> > > > Many workloads consumes significant amount of memory in pagetables. This
> > > > patch series exposes the pagetable comsumption for each memory cgroup.
> > >
> > > Hi Shakeel!
> > >
> > > The code looks good to me. However I'm not sure I understand what's the
> > > use case for the new statistics? Can you, please, elaborate a bit more here?
> > >
> > > From a very first glance, the size of pagetables should be _roughly_ equal
> > > to the size_of(pte)/PAGE_SIZE*(size of a cgroup) and should not exceed 1%
> > > of the cgroup size. So for all but very large cgroups the value will be
> > > in the noise of per-cpu counters. Perhaps I'm missing some important cases?
> > >
> >
> > I think this is in general a good metric to have but one specific
> > use-case we have is the user space network driver which mmaps the
> > memory of the applications for zero copy data transfers. This driver
> > can consume a large amount of memory in page tables. So, this metric
> > becomes really useful here.
>
> Got it, thank you for the explanation!
> Would you mind to add this text to the cover letter as an example?

Sure.

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

Thanks for the review.