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: <9fb84281-19ce-8a39-b87b-fcadf9d265d1@shopee.com>
Date:   Thu, 20 Apr 2023 10:25:25 +0800
From:   Haifeng Xu <haifeng.xu@...pee.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     mhocko@...e.com, hannes@...xchg.org, roman.gushchin@...ux.dev,
        shakeelb@...gle.com, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm, vmpressure: remove redundant check in vmpressure()



On 2023/4/20 04:03, Andrew Morton wrote:
> On Wed, 19 Apr 2023 09:20:07 +0000 Haifeng Xu <haifeng.xu@...pee.com> wrote:
> 
>> There are three places, vmpressure_prio(), shrink_node_memcgs() and
>> shrink_node(), which invoke vmpressure(). But only shrink_node_memcgs()
>> sets tree to false and the memcg used in it is not NULL, so we don't
>> check it again in vmpressure().
>>
>> ...
>>
>> --- a/mm/vmpressure.c
>> +++ b/mm/vmpressure.c
>> @@ -284,7 +284,7 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
>>  		enum vmpressure_levels level;
>>  
>>  		/* For now, no users for root-level efficiency */
>> -		if (!memcg || mem_cgroup_is_root(memcg))
>> +		if (mem_cgroup_is_root(memcg))
>>  			return;
>>  
>>  		spin_lock(&vmpr->sr_lock);
> 
> try_to_free_pages()->
>   do_try_to_free_pages()->
>     vmpressure_prio()-> 
>       vmpressure()->
>         crash
> 
> what am I missing here?
> 
> 

vmpressure_prio() set tree to true, so the crash won't happen.

> It does appear that vmpressure() could be simplified with
> 
> 	if (!memcg)
> 		memcg = root_mem_cgroup;
> 
> so the test you identified goes away and the memcg_to_vmpressure() call
> becomes simpler.  But that's such a small change it doesn't seem worth
> the effort.

memcg_to_vmpressure() has taken this case that the memcg is NULL into account and 
we do not need to change it.

The test I identified is in the branch that the tree is set to false. In this branch,
memcg can never be NULL because only shrink_node_memcgs() will step into it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ