lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 22 Dec 2021 12:15:06 +0800
From:   Muchun Song <songmuchun@...edance.com>
To:     Shakeel Butt <shakeelb@...gle.com>
Cc:     Johannes Weiner <hannes@...xchg.org>,
        Michal Hocko <mhocko@...nel.org>, Roman Gushchin <guro@...com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Linux Memory Management List <linux-mm@...ck.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] memcg: add per-memcg vmalloc stat

On Wed, Dec 22, 2021 at 5:53 AM Shakeel Butt <shakeelb@...gle.com> wrote:
>
> The kvmalloc* allocation functions can fallback to vmalloc allocations
> and more often on long running machines. In addition the kernel does
> have __GFP_ACCOUNT kvmalloc* calls. So, often on long running machines,
> the memory.stat does not tell the complete picture which type of memory
> is charged to the memcg. So add a per-memcg vmalloc stat.
>
> Signed-off-by: Shakeel Butt <shakeelb@...gle.com>
> ---
>  Documentation/admin-guide/cgroup-v2.rst |  3 +++
>  include/linux/memcontrol.h              | 15 +++++++++++++++
>  mm/memcontrol.c                         |  1 +
>  mm/vmalloc.c                            |  5 +++++
>  4 files changed, 24 insertions(+)
>
> diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
> index 82c8dc91b2be..5aa368d165da 100644
> --- a/Documentation/admin-guide/cgroup-v2.rst
> +++ b/Documentation/admin-guide/cgroup-v2.rst
> @@ -1314,6 +1314,9 @@ PAGE_SIZE multiple when read back.
>           sock (npn)
>                 Amount of memory used in network transmission buffers
>
> +         vmalloc (npn)
> +               Amount of memory used for vmap backed memory.
> +
>           shmem
>                 Amount of cached filesystem data that is swap-backed,
>                 such as tmpfs, shm segments, shared anonymous mmap()s
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index d76dad703580..000bfad6ff69 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -33,6 +33,7 @@ enum memcg_stat_item {
>         MEMCG_SWAP = NR_VM_NODE_STAT_ITEMS,
>         MEMCG_SOCK,
>         MEMCG_PERCPU_B,
> +       MEMCG_VMALLOC,
>         MEMCG_NR_STAT,
>  };
>
> @@ -944,6 +945,15 @@ static inline void mod_memcg_state(struct mem_cgroup *memcg,
>         local_irq_restore(flags);
>  }
>
> +static inline void mod_memcg_page_state(struct page *page,
> +                                       int idx, int val)
> +{
> +       struct mem_cgroup *memcg = page_memcg(page);
> +
> +       if (!mem_cgroup_disabled() && memcg)
> +               mod_memcg_state(memcg, idx, val);

It's not safe to access @memcg throughout mod_memcg_state() for the
kmem charged through objcg infrastructure. It's supposed to be safe
to access @memcg under rcu read lock. Otherwise, it looks good to
me.

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ