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]
Date:   Mon, 28 Mar 2022 21:15:25 +0800
From:   Miaohe Lin <linmiaohe@...wei.com>
To:     Michal Hocko <mhocko@...e.com>
CC:     <hannes@...xchg.org>, <roman.gushchin@...ux.dev>,
        <shakeelb@...gle.com>, <akpm@...ux-foundation.org>,
        <cgroups@...r.kernel.org>, <linux-mm@...ck.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mm/memcg: remove unneeded nr_scanned

On 2022/3/28 20:01, Michal Hocko wrote:
> On Mon 28-03-22 19:41:44, Miaohe Lin wrote:
>> The local variable nr_scanned is unneeded as mem_cgroup_soft_reclaim always
>> does *total_scanned += nr_scanned. So we can pass total_scanned directly to
>> the mem_cgroup_soft_reclaim to simplify the code and save some cpu cycles
>> of adding nr_scanned to total_scanned.
> 
> Maybe the compiler could be clever enough to generate a good code.
> mem_cgroup_soft_reclaim doesn't have other caller so it could be
> inlined. But I do agree that the change makes sense because it makes the
> code more consistent as mem_cgroup_soft_limit_reclaim already uses
> total_scanned this way.

Many thanks for your comment and Acked-by tag. :)

> 
>> Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
> 
> Acked-by: Michal Hocko <mhocko@...e.com>
> 
> Thanks
> 
>> ---
>>  mm/memcontrol.c | 5 +----
>>  1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>> index b686ec4f42c6..79341365ec90 100644
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -3384,7 +3384,6 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
>>  	int loop = 0;
>>  	struct mem_cgroup_tree_per_node *mctz;
>>  	unsigned long excess;
>> -	unsigned long nr_scanned;
>>  
>>  	if (order > 0)
>>  		return 0;
>> @@ -3412,11 +3411,9 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
>>  		if (!mz)
>>  			break;
>>  
>> -		nr_scanned = 0;
>>  		reclaimed = mem_cgroup_soft_reclaim(mz->memcg, pgdat,
>> -						    gfp_mask, &nr_scanned);
>> +						    gfp_mask, total_scanned);
>>  		nr_reclaimed += reclaimed;
>> -		*total_scanned += nr_scanned;
>>  		spin_lock_irq(&mctz->lock);
>>  		__mem_cgroup_remove_exceeded(mz, mctz);
>>  
>> -- 
>> 2.23.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ