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: <4ed23d48-6c83-d703-57a4-24cf9cc34eb9@oracle.com>
Date:   Thu, 13 Oct 2022 12:14:10 +0530
From:   Kamalesh Babulal <kamalesh.babulal@...cle.com>
To:     Michal Hocko <mhocko@...e.com>
Cc:     Johannes Weiner <hannes@...xchg.org>,
        Roman Gushchin <roman.gushchin@...ux.dev>,
        Shakeel Butt <shakeelb@...gle.com>,
        Muchun Song <songmuchun@...edance.com>,
        Tom Hromatka <tom.hromatka@...cle.com>,
        cgroups@...r.kernel.org, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH] mm: memcontrol: use mem_cgroup_is_root() helper

+cc: Andrew Morton
Sorry, had missed akpm in the original patch.

On 10/3/22 13:28, Michal Hocko wrote:
> On Fri 30-09-22 19:14:33, Kamalesh Babulal wrote:
>> Replace the checks for memcg is root memcg, with mem_cgroup_is_root()
>> helper.
>>
>> Signed-off-by: Kamalesh Babulal <kamalesh.babulal@...cle.com>
> 
> Acked-by: Michal Hocko <mhocko@...e.com>
> Thanks!
> 

Michal Hocko/Muchun Song,

Thank you so much for the review.

>> ---
>>  mm/memcontrol.c | 20 ++++++++++----------
>>  1 file changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>> index b69979c9ced5..99b3d0cbd426 100644
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -1148,7 +1148,7 @@ static void invalidate_reclaim_iterators(struct mem_cgroup *dead_memcg)
>>  	 * cgroup root (root_mem_cgroup). So we have to handle
>>  	 * dead_memcg from cgroup root separately.
>>  	 */
>> -	if (last != root_mem_cgroup)
>> +	if (!mem_cgroup_is_root(last))
>>  		__invalidate_reclaim_iterators(root_mem_cgroup,
>>  						dead_memcg);
>>  }
>> @@ -1172,7 +1172,7 @@ int mem_cgroup_scan_tasks(struct mem_cgroup *memcg,
>>  	struct mem_cgroup *iter;
>>  	int ret = 0;
>>  
>> -	BUG_ON(memcg == root_mem_cgroup);
>> +	BUG_ON(mem_cgroup_is_root(memcg));
>>  
>>  	for_each_mem_cgroup_tree(iter, memcg) {
>>  		struct css_task_iter it;
>> @@ -1201,7 +1201,7 @@ void lruvec_memcg_debug(struct lruvec *lruvec, struct folio *folio)
>>  	memcg = folio_memcg(folio);
>>  
>>  	if (!memcg)
>> -		VM_BUG_ON_FOLIO(lruvec_memcg(lruvec) != root_mem_cgroup, folio);
>> +		VM_BUG_ON_FOLIO(!mem_cgroup_is_root(lruvec_memcg(lruvec)), folio);
>>  	else
>>  		VM_BUG_ON_FOLIO(lruvec_memcg(lruvec) != memcg, folio);
>>  }
>> @@ -1982,7 +1982,7 @@ struct mem_cgroup *mem_cgroup_get_oom_group(struct task_struct *victim,
>>  	rcu_read_lock();
>>  
>>  	memcg = mem_cgroup_from_task(victim);
>> -	if (memcg == root_mem_cgroup)
>> +	if (mem_cgroup_is_root(memcg))
>>  		goto out;
>>  
>>  	/*
>> @@ -2940,7 +2940,7 @@ static struct obj_cgroup *__get_obj_cgroup_from_memcg(struct mem_cgroup *memcg)
>>  {
>>  	struct obj_cgroup *objcg = NULL;
>>  
>> -	for (; memcg != root_mem_cgroup; memcg = parent_mem_cgroup(memcg)) {
>> +	for (; !mem_cgroup_is_root(memcg); memcg = parent_mem_cgroup(memcg)) {
>>  		objcg = rcu_dereference(memcg->objcg);
>>  		if (objcg && obj_cgroup_tryget(objcg))
>>  			break;
>> @@ -7073,7 +7073,7 @@ void mem_cgroup_sk_alloc(struct sock *sk)
>>  
>>  	rcu_read_lock();
>>  	memcg = mem_cgroup_from_task(current);
>> -	if (memcg == root_mem_cgroup)
>> +	if (mem_cgroup_is_root(memcg))
>>  		goto out;
>>  	if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !memcg->tcpmem_active)
>>  		goto out;
>> @@ -7208,7 +7208,7 @@ static struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg)
>>  		 * The root cgroup cannot be destroyed, so it's refcount must
>>  		 * always be >= 1.
>>  		 */
>> -		if (WARN_ON_ONCE(memcg == root_mem_cgroup)) {
>> +		if (WARN_ON_ONCE(mem_cgroup_is_root(memcg))) {
>>  			VM_BUG_ON(1);
>>  			break;
>>  		}
>> @@ -7369,7 +7369,7 @@ long mem_cgroup_get_nr_swap_pages(struct mem_cgroup *memcg)
>>  
>>  	if (cgroup_memory_noswap || !cgroup_subsys_on_dfl(memory_cgrp_subsys))
>>  		return nr_swap_pages;
>> -	for (; memcg != root_mem_cgroup; memcg = parent_mem_cgroup(memcg))
>> +	for (; !mem_cgroup_is_root(memcg); memcg = parent_mem_cgroup(memcg))
>>  		nr_swap_pages = min_t(long, nr_swap_pages,
>>  				      READ_ONCE(memcg->swap.max) -
>>  				      page_counter_read(&memcg->swap));
>> @@ -7391,7 +7391,7 @@ bool mem_cgroup_swap_full(struct page *page)
>>  	if (!memcg)
>>  		return false;
>>  
>> -	for (; memcg != root_mem_cgroup; memcg = parent_mem_cgroup(memcg)) {
>> +	for (; !mem_cgroup_is_root(memcg); memcg = parent_mem_cgroup(memcg)) {
>>  		unsigned long usage = page_counter_read(&memcg->swap);
>>  
>>  		if (usage * 2 >= READ_ONCE(memcg->swap.high) ||
>> @@ -7556,7 +7556,7 @@ bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)
>>  		return true;
>>  
>>  	original_memcg = get_mem_cgroup_from_objcg(objcg);
>> -	for (memcg = original_memcg; memcg != root_mem_cgroup;
>> +	for (memcg = original_memcg; !mem_cgroup_is_root(memcg);
>>  	     memcg = parent_mem_cgroup(memcg)) {
>>  		unsigned long max = READ_ONCE(memcg->zswap_max);
>>  		unsigned long pages;
>>
>> base-commit: 987a926c1d8a40e4256953b04771fbdb63bc7938
>> -- 
>> 2.34.3
> 

-- 
Thanks,
Kamalesh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ