* + mm-memcg-percpu-account-extra-objcg-space-to-memory-cgroups.patch added to -mm tree
@ 2021-11-28 0:04 akpm
2021-11-29 2:57 ` Dennis Zhou
0 siblings, 1 reply; 2+ messages in thread
From: akpm @ 2021-11-28 0:04 UTC (permalink / raw)
To: cl, dennis, mm-commits, songmuchun, tj, zhengqi.arch
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: + mm-memcg-percpu-account-extra-objcg-space-to-memory-cgroups.patch added to -mm tree
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
0 siblings, 0 replies; 2+ messages in thread
From: Dennis Zhou @ 2021-11-29 2:57 UTC (permalink / raw)
To: akpm; +Cc: cl, mm-commits, songmuchun, tj, zhengqi.arch
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-29 2:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.