Re: [PATCH v4] cgroup2: New memory.max.effective like cgroup1 hierarchical_memory_limit
From: Michal Koutný
Date: Wed Mar 20 2024 - 12:02:33 EST
Hello.
I have some advise about patch desription and only nitpick about
implementation.
On Wed, Feb 14, 2024 at 05:56:20AM +0800, "Jan Kratochvil (Azul)" <jkratochvil@xxxxxxxx> wrote:
> which are useful for userland to easily and performance-wise find out the
> effective cgroup limits being applied.
I think this is a weak reasoning for in-kernel implementation.
It may be faster but how often do you need to read that limit?
> Otherwise userland has to
Userland is at loss when running inside cgroupns with limited ancestors
out of the cgroupns. Thus I think this is the reason why kernel can
provide such an effective value. (And be subject line of the commit, I
think bringing up cgroup1 is misleading.)
> For cgroup1 it was implemented by:
> memcg: show real limit under hierarchy mode
> https://github.com/torvalds/linux/commit/fee7b548e6f2bd4bfd03a1a45d3afd593de7d5e9
> Date: Wed Jan 7 18:08:26 2009 -0800
FTR, commits are usually referenced more concisely like
fee7b548e6f2 ("memcg: show real limit under hierarchy mode")
(the document Waiman linked previously has some tips how to get this
from git).
> +static int memory_max_effective_show(struct seq_file *m, void *v)
> +{
> + unsigned long memory;
> + struct mem_cgroup *mi;
> +
> + /* Hierarchical information */
> + memory = PAGE_COUNTER_MAX;
> + for (mi = mem_cgroup_from_seq(m); mi; mi = parent_mem_cgroup(mi))
> + memory = min(memory, READ_ONCE(mi->memory.max));
root_mem_cgroup is never charged (thus limited), so you can terminate
the iteration on !mem_cgroup_is_root(mi), one level earlier
> +static int swap_max_effective_show(struct seq_file *m, void *v)
> +{
> + unsigned long swap;
> + struct mem_cgroup *mi;
> +
> + /* Hierarchical information */
> + swap = PAGE_COUNTER_MAX;
> + for (mi = mem_cgroup_from_seq(m); mi; mi = parent_mem_cgroup(mi))
> + swap = min(swap, READ_ONCE(mi->swap.max));
ditto
HTH,
Michal
Attachment:
signature.asc
Description: PGP signature