From: Michal Hocko <mhocko-IBi9RG/b67k@public.gmane.org>
To: Muchun Song <songmuchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
Cc: hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org,
vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
guro-b10kYP2dOMg@public.gmane.org,
sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org,
alexander.h.duyck-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
chris-6Bi1550iOqEnzZ6mRAm98g@public.gmane.org,
laoar.shao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org
Subject: Re: [PATCH] mm: memcontrol: optimize per-lruvec stats counter memory usage
Date: Mon, 7 Dec 2020 13:36:05 +0100 [thread overview]
Message-ID: <20201207123605.GH25569@dhcp22.suse.cz> (raw)
In-Reply-To: <20201206085639.12627-1-songmuchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
On Sun 06-12-20 16:56:39, Muchun Song wrote:
> The vmstat threshold is 32 (MEMCG_CHARGE_BATCH), so the type of s32
> of lruvec_stat_cpu is enough. And introduce struct per_cpu_lruvec_stat
> to optimize memory usage.
How much savings are we talking about here? I am not deeply familiar
with the pcp allocator but can it compact smaller data types much
better?
> Signed-off-by: Muchun Song <songmuchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
> ---
> include/linux/memcontrol.h | 6 +++++-
> mm/memcontrol.c | 2 +-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index f9a496c4eac7..34cf119976b1 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -92,6 +92,10 @@ struct lruvec_stat {
> long count[NR_VM_NODE_STAT_ITEMS];
> };
>
> +struct per_cpu_lruvec_stat {
> + s32 count[NR_VM_NODE_STAT_ITEMS];
> +};
> +
> /*
> * Bitmap of shrinker::id corresponding to memcg-aware shrinkers,
> * which have elements charged to this memcg.
> @@ -111,7 +115,7 @@ struct mem_cgroup_per_node {
> struct lruvec_stat __percpu *lruvec_stat_local;
>
> /* Subtree VM stats (batched updates) */
> - struct lruvec_stat __percpu *lruvec_stat_cpu;
> + struct per_cpu_lruvec_stat __percpu *lruvec_stat_cpu;
> atomic_long_t lruvec_stat[NR_VM_NODE_STAT_ITEMS];
>
> unsigned long lru_zone_size[MAX_NR_ZONES][NR_LRU_LISTS];
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 49fbcf003bf5..c874ea37b05d 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -5184,7 +5184,7 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)
> return 1;
> }
>
> - pn->lruvec_stat_cpu = alloc_percpu_gfp(struct lruvec_stat,
> + pn->lruvec_stat_cpu = alloc_percpu_gfp(struct per_cpu_lruvec_stat,
> GFP_KERNEL_ACCOUNT);
> if (!pn->lruvec_stat_cpu) {
> free_percpu(pn->lruvec_stat_local);
> --
> 2.11.0
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2020-12-07 12:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-06 8:56 [PATCH] mm: memcontrol: optimize per-lruvec stats counter memory usage Muchun Song
[not found] ` <20201206085639.12627-1-songmuchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org>
2020-12-07 12:36 ` Michal Hocko [this message]
2020-12-07 12:56 ` [External] " Muchun Song
[not found] ` <CAMZfGtUhG26cTgbSmg4g+rwOtEFhgbE3QXPR_LUf3FS-s=YbOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-12-07 15:09 ` Michal Hocko
[not found] ` <20201207150847.GM25569-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2020-12-07 15:19 ` Muchun Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201207123605.GH25569@dhcp22.suse.cz \
--to=mhocko-ibi9rg/b67k@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=alexander.h.duyck-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=chris-6Bi1550iOqEnzZ6mRAm98g@public.gmane.org \
--cc=guro-b10kYP2dOMg@public.gmane.org \
--cc=hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org \
--cc=laoar.shao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org \
--cc=shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=songmuchun-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org \
--cc=vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox