SUNRPC: Ensure memory shrinker doesn't waste time in rpcauth_prune_expired()
The 'cred_unused' list, that is traversed by rpcauth_cache_shrinker is ordered by time. If we hit a credential that is under the 60 second garbage collection moratorium, we should exit because we know at that point that all successive credentials are subject to the same moratorium... Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
@@ -236,10 +236,13 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan)
|
|||||||
|
|
||||||
list_for_each_entry_safe(cred, next, &cred_unused, cr_lru) {
|
list_for_each_entry_safe(cred, next, &cred_unused, cr_lru) {
|
||||||
|
|
||||||
/* Enforce a 60 second garbage collection moratorium */
|
/*
|
||||||
|
* Enforce a 60 second garbage collection moratorium
|
||||||
|
* Note that the cred_unused list must be time-ordered.
|
||||||
|
*/
|
||||||
if (time_in_range(cred->cr_expire, expired, jiffies) &&
|
if (time_in_range(cred->cr_expire, expired, jiffies) &&
|
||||||
test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0)
|
test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0)
|
||||||
continue;
|
return 0;
|
||||||
|
|
||||||
list_del_init(&cred->cr_lru);
|
list_del_init(&cred->cr_lru);
|
||||||
number_cred_unused--;
|
number_cred_unused--;
|
||||||
@@ -258,7 +261,7 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan)
|
|||||||
if (nr_to_scan == 0)
|
if (nr_to_scan == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return nr_to_scan;
|
return (number_cred_unused / 100) * sysctl_vfs_cache_pressure;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -275,8 +278,7 @@ rpcauth_cache_shrinker(int nr_to_scan, gfp_t gfp_mask)
|
|||||||
if (list_empty(&cred_unused))
|
if (list_empty(&cred_unused))
|
||||||
return 0;
|
return 0;
|
||||||
spin_lock(&rpc_credcache_lock);
|
spin_lock(&rpc_credcache_lock);
|
||||||
nr_to_scan = rpcauth_prune_expired(&free, nr_to_scan);
|
res = rpcauth_prune_expired(&free, nr_to_scan);
|
||||||
res = (number_cred_unused / 100) * sysctl_vfs_cache_pressure;
|
|
||||||
spin_unlock(&rpc_credcache_lock);
|
spin_unlock(&rpc_credcache_lock);
|
||||||
rpcauth_destroy_credlist(&free);
|
rpcauth_destroy_credlist(&free);
|
||||||
return res;
|
return res;
|
||||||
|
Reference in New Issue
Block a user