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: <20251008000014.2845-1-sj@kernel.org>
Date: Tue,  7 Oct 2025 17:00:14 -0700
From: SeongJae Park <sj@...nel.org>
To: SeongJae Park <sj@...nel.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
	damon@...ts.linux.dev,
	kernel-team@...a.com,
	linux-kernel@...r.kernel.org,
	linux-mm@...ck.org
Subject: Re: [RFC PATCH 03/11] mm/damon/core: implement DAMOS_QUOTA_NODE_MEMCG_USED_BP

On Thu, 19 Jun 2025 15:00:15 -0700 SeongJae Park <sj@...nel.org> wrote:

> Implement the behavior of DAMOS_QUOTA_NODE_MEMCG_USED_BP.  It uses sum
> of active/inactive anon/file pages of a given cgroup on a given NUMA
> node as the value of the metric.
> 
> Signed-off-by: SeongJae Park <sj@...nel.org>
> ---
>  mm/damon/core.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index d675dd932a23..1481b43f2710 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
[...]
> +static unsigned long damos_get_node_memcg_used_bp(
> +		struct damos_quota_goal *goal)
> +{
> +	struct mem_cgroup *memcg;
> +	struct lruvec *lruvec;
> +	unsigned long used_pages;
> +	struct sysinfo i;
> +
> +	rcu_read_lock();
> +	memcg = mem_cgroup_from_id(goal->memcg_id);
> +	mem_cgroup_flush_stats(memcg);
> +	lruvec = mem_cgroup_lruvec(memcg, NODE_DATA(goal->nid));
> +	used_pages = lruvec_page_state(lruvec, NR_ACTIVE_ANON);
> +	used_pages += lruvec_page_state(lruvec, NR_INACTIVE_ANON);
> +	used_pages += lruvec_page_state(lruvec, NR_ACTIVE_FILE);
> +	used_pages += lruvec_page_state(lruvec, NR_INACTIVE_FILE);
> +	rcu_read_unlock();

mem_cgroup_flush_stats() calls css_rstat_flush() which may block.  But the
above diff is putting it inside an RCU read-side critical section.  Actually
only mem_cgroup_from_id() needs to be called inside an RCU read-side critical
section.  I will revise the next version to call rcu_read_unlock() right after
mem_cgroup_from_id().

Also, mem_cgroup_from_id() could return NULL if the memcg is removeed while
DAMON is running, but this diff is not checking the NULL return case.  I will
add the handling in the next version.

> +
> +	si_meminfo_node(&i, goal->nid);
> +	return used_pages * PAGE_SIZE * 10000 / i.totalram;

i.totalram is in number of pages unit, but the above code is assuming it is in
bytes unit.  This makes the result significantly wrong.  I will fix this in the
next version.


Thanks,
SJ

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ