mbox series

[v2,0/3] percpu: memcg memory accounting rework

Message ID 20210603010931.1472512-1-guro@fb.com (mailing list archive)
Headers show
Series percpu: memcg memory accounting rework | expand

Message

Roman Gushchin June 3, 2021, 1:09 a.m. UTC
This patchset reworks memcg-based accounting of the percpu memory:
instead of using two types of chunks (memcg-aware and non-memcg-aware)
it treats all chunks as memcg-aware. An extra memory used for objcg
arrays will is compensated by a better chunks utilization, so the
total memory footprint should be the same or smaller.

First two patches are preparational changes and cleanups on the memcg side.
The third one is percpu accounting rework.

v2:
  - make all chunks memcg-aware instead of on-demand objcg allocation, by Dennis

v1:
  https://lkml.org/lkml/2021/5/11/1343


Roman Gushchin (3):
  mm, memcg: mark cgroup_memory_nosocket, nokmem and noswap as
    __ro_after_init
  mm, memcg: introduce mem_cgroup_kmem_disabled()
  percpu: rework memcg accounting

 include/linux/memcontrol.h |   5 ++
 mm/memcontrol.c            |  11 ++-
 mm/percpu-internal.h       |  52 +--------------
 mm/percpu-km.c             |   5 +-
 mm/percpu-stats.c          |  46 +++++--------
 mm/percpu-vm.c             |  11 ++-
 mm/percpu.c                | 133 +++++++++++++++----------------------
 7 files changed, 88 insertions(+), 175 deletions(-)

Comments

Dennis Zhou June 4, 2021, 4:10 p.m. UTC | #1
Hello,

On Wed, Jun 02, 2021 at 06:09:28PM -0700, Roman Gushchin wrote:
> This patchset reworks memcg-based accounting of the percpu memory:
> instead of using two types of chunks (memcg-aware and non-memcg-aware)
> it treats all chunks as memcg-aware. An extra memory used for objcg
> arrays will is compensated by a better chunks utilization, so the
> total memory footprint should be the same or smaller.
> 
> First two patches are preparational changes and cleanups on the memcg side.
> The third one is percpu accounting rework.
> 
> v2:
>   - make all chunks memcg-aware instead of on-demand objcg allocation, by Dennis
> 
> v1:
>   https://lkml.org/lkml/2021/5/11/1343
> 
> 
> Roman Gushchin (3):
>   mm, memcg: mark cgroup_memory_nosocket, nokmem and noswap as
>     __ro_after_init
>   mm, memcg: introduce mem_cgroup_kmem_disabled()
>   percpu: rework memcg accounting
> 
>  include/linux/memcontrol.h |   5 ++
>  mm/memcontrol.c            |  11 ++-
>  mm/percpu-internal.h       |  52 +--------------
>  mm/percpu-km.c             |   5 +-
>  mm/percpu-stats.c          |  46 +++++--------
>  mm/percpu-vm.c             |  11 ++-
>  mm/percpu.c                | 133 +++++++++++++++----------------------
>  7 files changed, 88 insertions(+), 175 deletions(-)
> 
> -- 
> 2.31.1
> 

I think I'm pretty happy with this approach. If there is any issue with
the delta of memcg on but kmem accounting off, we can tackle that
separately. I'll need another day or so to review the last patch a
little more carefully though.

Andrew do you mind if I route the first two in my tree too?

Thanks,
Dennis
Andrew Morton June 4, 2021, 8:31 p.m. UTC | #2
On Fri, 4 Jun 2021 16:10:46 +0000 Dennis Zhou <dennis@kernel.org> wrote:

> I think I'm pretty happy with this approach. If there is any issue with
> the delta of memcg on but kmem accounting off, we can tackle that
> separately. I'll need another day or so to review the last patch a
> little more carefully though.
> 
> Andrew do you mind if I route the first two in my tree too?

Please do.
Dennis Zhou June 5, 2021, 9:02 p.m. UTC | #3
Hello,

On Wed, Jun 02, 2021 at 06:09:28PM -0700, Roman Gushchin wrote:
> This patchset reworks memcg-based accounting of the percpu memory:
> instead of using two types of chunks (memcg-aware and non-memcg-aware)
> it treats all chunks as memcg-aware. An extra memory used for objcg
> arrays will is compensated by a better chunks utilization, so the
> total memory footprint should be the same or smaller.
> 
> First two patches are preparational changes and cleanups on the memcg side.
> The third one is percpu accounting rework.
> 
> v2:
>   - make all chunks memcg-aware instead of on-demand objcg allocation, by Dennis
> 
> v1:
>   https://lkml.org/lkml/2021/5/11/1343
> 
> 
> Roman Gushchin (3):
>   mm, memcg: mark cgroup_memory_nosocket, nokmem and noswap as
>     __ro_after_init
>   mm, memcg: introduce mem_cgroup_kmem_disabled()
>   percpu: rework memcg accounting
> 
>  include/linux/memcontrol.h |   5 ++
>  mm/memcontrol.c            |  11 ++-
>  mm/percpu-internal.h       |  52 +--------------
>  mm/percpu-km.c             |   5 +-
>  mm/percpu-stats.c          |  46 +++++--------
>  mm/percpu-vm.c             |  11 ++-
>  mm/percpu.c                | 133 +++++++++++++++----------------------
>  7 files changed, 88 insertions(+), 175 deletions(-)
> 
> -- 
> 2.31.1
> 

Thanks for this! It greatly simplifies the chunk maintenance.

I've applied this to for-5.14.

There is a trivial merge conflict though due to my for-5.14 being based
on torvalds#v5.12-rc7, but that's fine.

Thanks,
Dennis