From: Dennis Zhou <dennis@kernel.org>
To: akpm@linux-foundation.org
Cc: cl@linux.com, mm-commits@vger.kernel.org,
songmuchun@bytedance.com, tj@kernel.org,
zhengqi.arch@bytedance.com
Subject: Re: + mm-memcg-percpu-account-extra-objcg-space-to-memory-cgroups.patch added to -mm tree
Date: Sun, 28 Nov 2021 21:57:39 -0500 [thread overview]
Message-ID: <YaRBo5kyc7dLJPtc@fedora> (raw)
In-Reply-To: <20211128000426.z-EdzU3AU%akpm@linux-foundation.org>
On Sat, Nov 27, 2021 at 04:04:26PM -0800, akpm@linux-foundation.org wrote:
>
> The patch titled
> Subject: mm: memcg/percpu: account extra objcg space to memory cgroups
> has been added to the -mm tree. Its filename is
> mm-memcg-percpu-account-extra-objcg-space-to-memory-cgroups.patch
>
> This patch should soon appear at
> https://ozlabs.org/~akpm/mmots/broken-out/mm-memcg-percpu-account-extra-objcg-space-to-memory-cgroups.patch
> and later at
> https://ozlabs.org/~akpm/mmotm/broken-out/mm-memcg-percpu-account-extra-objcg-space-to-memory-cgroups.patch
>
> Before you just go and hit "reply", please:
> a) Consider who else should be cc'ed
> b) Prefer to cc a suitable mailing list as well
> c) Ideally: find the original patch on the mailing list and do a
> reply-to-all to that, adding suitable additional cc's
>
> *** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
>
> The -mm tree is included into linux-next and is updated
> there every 3-4 working days
>
> ------------------------------------------------------
> From: Qi Zheng <zhengqi.arch@bytedance.com>
> Subject: mm: memcg/percpu: account extra objcg space to memory cgroups
>
> Similar to slab memory allocator, for each accounted percpu object there
> is an extra space which is used to store obj_cgroup membership. Charge it
> too.
>
> Link: https://lkml.kernel.org/r/20211126040606.97836-1-zhengqi.arch@bytedance.com
> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
> Cc: Dennis Zhou <dennis@kernel.org>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Christoph Lameter <cl@linux.com>
> Cc: Muchun Song <songmuchun@bytedance.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
> mm/percpu-internal.h | 17 +++++++++++++++++
> mm/percpu.c | 10 +++++-----
> 2 files changed, 22 insertions(+), 5 deletions(-)
>
> --- a/mm/percpu.c~mm-memcg-percpu-account-extra-objcg-space-to-memory-cgroups
> +++ a/mm/percpu.c
> @@ -1635,7 +1635,7 @@ static bool pcpu_memcg_pre_alloc_hook(si
> if (!objcg)
> return true;
>
> - if (obj_cgroup_charge(objcg, gfp, size * num_possible_cpus())) {
> + if (obj_cgroup_charge(objcg, gfp, pcpu_obj_full_size(size))) {
> obj_cgroup_put(objcg);
> return false;
> }
> @@ -1656,10 +1656,10 @@ static void pcpu_memcg_post_alloc_hook(s
>
> rcu_read_lock();
> mod_memcg_state(obj_cgroup_memcg(objcg), MEMCG_PERCPU_B,
> - size * num_possible_cpus());
> + pcpu_obj_full_size(size));
> rcu_read_unlock();
> } else {
> - obj_cgroup_uncharge(objcg, size * num_possible_cpus());
> + obj_cgroup_uncharge(objcg, pcpu_obj_full_size(size));
> obj_cgroup_put(objcg);
> }
> }
> @@ -1676,11 +1676,11 @@ static void pcpu_memcg_free_hook(struct
> return;
> chunk->obj_cgroups[off >> PCPU_MIN_ALLOC_SHIFT] = NULL;
>
> - obj_cgroup_uncharge(objcg, size * num_possible_cpus());
> + obj_cgroup_uncharge(objcg, pcpu_obj_full_size(size));
>
> rcu_read_lock();
> mod_memcg_state(obj_cgroup_memcg(objcg), MEMCG_PERCPU_B,
> - -(size * num_possible_cpus()));
> + -pcpu_obj_full_size(size));
> rcu_read_unlock();
>
> obj_cgroup_put(objcg);
> --- a/mm/percpu-internal.h~mm-memcg-percpu-account-extra-objcg-space-to-memory-cgroups
> +++ a/mm/percpu-internal.h
> @@ -113,6 +113,23 @@ static inline int pcpu_chunk_map_bits(st
> return pcpu_nr_pages_to_map_bits(chunk->nr_pages);
> }
>
> +#ifdef CONFIG_MEMCG_KMEM
> +/**
> + * pcpu_obj_full_size - helper to calculate size of each accounted object
> + * @size: size of area to allocate in bytes
> + *
> + * For each accounted object there is an extra space which is used to store
> + * obj_cgroup membership. Charge it too.
> + */
> +static inline size_t pcpu_obj_full_size(size_t size)
> +{
> + size_t extra_size =
> + size / PCPU_MIN_ALLOC_SIZE * sizeof(struct obj_cgroup *);
> +
> + return size * num_possible_cpus() + extra_size;
> +}
> +#endif /* CONFIG_MEMCG_KMEM */
> +
> #ifdef CONFIG_PERCPU_STATS
>
> #include <linux/spinlock.h>
> _
>
> Patches currently in -mm which might be from zhengqi.arch@bytedance.com are
>
> mm-remove-redundant-check-about-fault_flag_allow_retry-bit.patch
> mm-memcg-percpu-account-extra-objcg-space-to-memory-cgroups.patch
>
Hi Andrew,
I understand I've been a bit slow and it's easy for you to pull
relatively small changes, so please add:
Acked-by: Dennis Zhou <dennis@kernel.org>
But I don't think I've gotten resolution on what's going on with mm/cpu
hotplug in [1]. Can we continue that conversation over there?
[1] https://lore.kernel.org/mm-commits/20211108205031.UxDPHBZWa%25akpm@linux-foundation.org/
Thanks,
Dennis
prev parent reply other threads:[~2021-11-29 2:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-28 0:04 + mm-memcg-percpu-account-extra-objcg-space-to-memory-cgroups.patch added to -mm tree akpm
2021-11-29 2:57 ` Dennis Zhou [this message]
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=YaRBo5kyc7dLJPtc@fedora \
--to=dennis@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=songmuchun@bytedance.com \
--cc=tj@kernel.org \
--cc=zhengqi.arch@bytedance.com \
/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