From: "Michal Koutný" <mkoutny@suse.com>
To: "Jan Kratochvil (Azul)" <jkratochvil@azul.com>
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, Waiman Long <longman@redhat.com>
Subject: Re: [PATCH v4] cgroup2: New memory.max.effective like cgroup1 hierarchical_memory_limit
Date: Wed, 20 Mar 2024 17:02:19 +0100 [thread overview]
Message-ID: <cah72hewsmrrzyo3tm2eipaw4mrxnncqv4zbbzz35x7ghjxred@lhdtiobg3bjm> (raw)
In-Reply-To: <ZcvlhOZ4VBEX9raZ@host1.jankratochvil.net>
[-- Attachment #1: Type: text/plain, Size: 1963 bytes --]
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@azul.com> 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2024-03-20 16:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 21:56 Jan Kratochvil (Azul)
2024-03-20 16:02 ` Michal Koutný [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=cah72hewsmrrzyo3tm2eipaw4mrxnncqv4zbbzz35x7ghjxred@lhdtiobg3bjm \
--to=mkoutny@suse.com \
--cc=cgroups@vger.kernel.org \
--cc=jkratochvil@azul.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=longman@redhat.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