[Devel] [PATCH RHEL7] mm: Reduce access frequency to shrinker_rwsem during shrink_slab

Andrey Ryabinin aryabinin at virtuozzo.com
Thu Aug 20 13:46:30 MSK 2020



On 8/20/20 11:32 AM, Valeriy Vdovin wrote:

> @@ -565,14 +588,16 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
>  		 * memcg_expand_one_shrinker_map if new shrinkers
>  		 * were registred in the meanwhile.
>  		 */
> -		if (!down_read_trylock(&shrinker_rwsem)) {
> -			freed = freed ? : 1;
> +		if (is_nfs) {
> +			if (!down_read_trylock(&shrinker_rwsem)) {
> +				freed = freed ? : 1;
> +				put_shrinker(shrinker);
> +				return freed;
> +			}
>  			put_shrinker(shrinker);
> -			return freed;
> +			map = memcg_nid_shrinker_map(memcg, nid);
> +			nr_max = min(shrinker_nr_max, map->nr_max);
>  		}

Need to add rwsem_is_contended() check back. It was here before commit 9e9e35d05

		else if (rwsem_is_contended(&shrinker_rwsem)) {
			freed = freed ? : 1;
			break;
		}



> -		put_shrinker(shrinker);
> -		map = memcg_nid_shrinker_map(memcg, nid);
> -		nr_max = min(shrinker_nr_max, map->nr_max);
>  	}
>  unlock:
>  	up_read(&shrinker_rwsem);


More information about the Devel mailing list