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] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZkNwthw5vJrnQSLL@tiehlicka>
Date: Tue, 14 May 2024 16:09:58 +0200
From: Michal Hocko <mhocko@...e.com>
To: Xiu Jianfeng <xiujianfeng@...wei.com>
Cc: hannes@...xchg.org, roman.gushchin@...ux.dev, shakeel.butt@...ux.dev,
	muchun.song@...ux.dev, akpm@...ux-foundation.org,
	cgroups@...r.kernel.org, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH -next] memcg: don't handle event_list for v2 when
 offlining

On Tue 14-05-24 13:11:06, Xiu Jianfeng wrote:
> The event_list for memcg is only valid for v1 and not used for v2,
> so it's unnessesary to handle event_list for v2.

You are right but the code as is works just fine. The list will be
empty. It is true that we do not need to take event_list_lock lock but
nobody should be using this lock anyway. Also the offline callback is
not particularly hot path. So why do we want to change the code?

> 
> Signed-off-by: Xiu Jianfeng <xiujianfeng@...wei.com>
> ---
>  mm/memcontrol.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index d127c9c5fabf..4254f9cd05f4 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -5881,12 +5881,14 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
>  	 * Notify userspace about cgroup removing only after rmdir of cgroup
>  	 * directory to avoid race between userspace and kernelspace.
>  	 */
> -	spin_lock_irq(&memcg->event_list_lock);
> -	list_for_each_entry_safe(event, tmp, &memcg->event_list, list) {
> -		list_del_init(&event->list);
> -		schedule_work(&event->remove);
> +	if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) {
> +		spin_lock_irq(&memcg->event_list_lock);
> +		list_for_each_entry_safe(event, tmp, &memcg->event_list, list) {
> +			list_del_init(&event->list);
> +			schedule_work(&event->remove);
> +		}
> +		spin_unlock_irq(&memcg->event_list_lock);
>  	}
> -	spin_unlock_irq(&memcg->event_list_lock);
>  
>  	page_counter_set_min(&memcg->memory, 0);
>  	page_counter_set_low(&memcg->memory, 0);
> -- 
> 2.34.1

-- 
Michal Hocko
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ