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]
Message-ID: <YdeDym9IUghnagrK@carbon.dhcp.thefacebook.com>
Date:   Thu, 6 Jan 2022 16:05:30 -0800
From:   Roman Gushchin <guro@...com>
To:     Muchun Song <songmuchun@...edance.com>
CC:     <willy@...radead.org>, <akpm@...ux-foundation.org>,
        <hannes@...xchg.org>, <mhocko@...nel.org>,
        <vdavydov.dev@...il.com>, <shakeelb@...gle.com>,
        <shy828301@...il.com>, <alexs@...nel.org>,
        <richard.weiyang@...il.com>, <david@...morbit.com>,
        <trond.myklebust@...merspace.com>, <anna.schumaker@...app.com>,
        <jaegeuk@...nel.org>, <chao@...nel.org>,
        <kari.argillander@...il.com>, <linux-fsdevel@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>,
        <linux-nfs@...r.kernel.org>, <zhengqi.arch@...edance.com>,
        <duanxiongchun@...edance.com>, <fam.zheng@...edance.com>,
        <smuchun@...il.com>
Subject: Re: [PATCH v5 01/16] mm: list_lru: optimize memory consumption of
 arrays of per cgroup lists

On Mon, Dec 20, 2021 at 04:56:34PM +0800, Muchun Song wrote:
> The list_lru uses an array (list_lru_memcg->lru) to store pointers
> which point to the list_lru_one. And the array is per memcg per node.
> Therefore, the size of the arrays will be 10K * number_of_node * 8 (
> a pointer size on 64 bits system) when we run 10k containers in the
> system. The memory consumption of the arrays becomes significant. The
> more numa node, the more memory it consumes.
> 
> I have done a simple test, which creates 10K memcg and mount point
> each in a two-node system. The memory consumption of the list_lru
> will be 24464MB. After converting the array from per memcg per node
> to per memcg, the memory consumption is going to be 21957MB. It is
> reduces by 2.5GB. In our AMD servers with 8 numa nodes in those
> sysuem, the memory consumption could be more significant. The savings
> come from the list_lru_one heads, that it also simplifies the
> alloc/dealloc path.
> 
> The new scheme looks like the following.
> 
>   +----------+   mlrus   +----------------+   mlru   +----------------------+
>   | list_lru +---------->| list_lru_memcg +--------->|  list_lru_per_memcg  |
>   +----------+           +----------------+          +----------------------+
>                                                      |  list_lru_per_memcg  |
>                                                      +----------------------+
>                                                      |          ...         |
>                           +--------------+   node    +----------------------+
>                           | list_lru_one |<----------+  list_lru_per_memcg  |
>                           +--------------+           +----------------------+
>                           | list_lru_one |
>                           +--------------+
>                           |      ...     |
>                           +--------------+
>                           | list_lru_one |
>                           +--------------+
> 
> Signed-off-by: Muchun Song <songmuchun@...edance.com>
> Acked-by: Johannes Weiner <hannes@...xchg.org>

As much as I like the code changes (there is indeed a significant simplification!),
I don't like the commit message and title, because I wasn't able to understand
what the patch is doing and some parts look simply questionable. Overall it
sounds like you reduce the number of list_lru_one structures, which is not true.

How about something like this?

--
mm: list_lru: transpose the array of per-node per-memcg lru lists

The current scheme of maintaining per-node per-memcg lru lists looks like:
  struct list_lru {
    struct list_lru_node *node;           (for each node)
      struct list_lru_memcg *memcg_lrus;
        struct list_lru_one *lru[];       (for each memcg)
  }

By effectively transposing the two-dimension array of list_lru_one's structures
(per-node per-memcg => per-memcg per-node) it's possible to save some memory
and simplify alloc/dealloc paths. The new scheme looks like:
  struct list_lru {
    struct list_lru_memcg *mlrus;
      struct list_lru_per_memcg *mlru[];  (for each memcg)
        struct list_lru_one node[0];      (for each node)
  }

Memory savings are coming from having fewer list_lru_memcg structures, which
contain an extra struct rcu_head to handle the destruction process.
--

But what worries me is that memory savings numbers you posted don't do up.
In theory we can save
16 (size of struct rcu_head) * 10000 (number of cgroups) * 2 (number of numa nodes) = 320k
per slab cache. Did you have a ton of mount points? Otherwise I don't understand
where these 2.5Gb are coming from.

Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ