lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <cah72hewsmrrzyo3tm2eipaw4mrxnncqv4zbbzz35x7ghjxred@lhdtiobg3bjm>
Date: Wed, 20 Mar 2024 17:02:19 +0100
From: Michal Koutný <mkoutny@...e.com>
To: "Jan Kratochvil (Azul)" <jkratochvil@...l.com>
Cc: cgroups@...r.kernel.org, linux-kernel@...r.kernel.org, 
	linux-mm@...ck.org, Waiman Long <longman@...hat.com>
Subject: Re: [PATCH v4] cgroup2: New memory.max.effective like cgroup1
 hierarchical_memory_limit

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@...l.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

Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ