Re: [PATCH 1/9] mm: vmscan: simplify nr_deferred update code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 02, 2020 at 10:27:17AM -0800, Yang Shi wrote:
> Currently if (next_deferred - scanned) = 0, the code would just read the current
> nr_deferred otherwise add the delta back.  Both needs atomic operation anyway,

But atomic_read() is usually way cheaper than any atomic write.

> it
> seems there is not too much gain by distinguishing the two cases, so just add the
> delta back even though the delta is 0.  This would simply the code for the following
> patches too.
> 
> Signed-off-by: Yang Shi <shy828301@xxxxxxxxx>
> ---
>  mm/vmscan.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 7b4e31eac2cf..7d6186a07daf 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -528,14 +528,10 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
>  		next_deferred = 0;
>  	/*
>  	 * move the unused scan count back into the shrinker in a
> -	 * manner that handles concurrent updates. If we exhausted the
> -	 * scan, there is no need to do an update.
> +	 * manner that handles concurrent updates.
>  	 */
> -	if (next_deferred > 0)
> -		new_nr = atomic_long_add_return(next_deferred,
> -						&shrinker->nr_deferred[nid]);
> -	else
> -		new_nr = atomic_long_read(&shrinker->nr_deferred[nid]);
> +	new_nr = atomic_long_add_return(next_deferred,
> +					&shrinker->nr_deferred[nid]);

So looking at this patch standalone, it's a bit hard to buy in. Maybe it's better to
merge the change into other patch, if it will make more obvious why this change is
required. Or just leave things as they are.



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux